Cache the creation of Sponge proxy subject classes (#1005)
This commit is contained in:
parent
ed3b5a3cf1
commit
f4882c1c14
@ -61,6 +61,8 @@ public abstract class HolderSubject<T extends PermissionHolder> implements LPSub
|
||||
private final HolderSubjectData subjectData;
|
||||
private final HolderSubjectData transientSubjectData;
|
||||
|
||||
private Subject spongeSubject = null;
|
||||
|
||||
HolderSubject(LPSpongePlugin plugin, T parent) {
|
||||
this.parent = parent;
|
||||
this.plugin = plugin;
|
||||
@ -78,8 +80,11 @@ public abstract class HolderSubject<T extends PermissionHolder> implements LPSub
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subject sponge() {
|
||||
return ProxyFactory.toSponge(this);
|
||||
public synchronized Subject sponge() {
|
||||
if (this.spongeSubject == null) {
|
||||
this.spongeSubject = ProxyFactory.toSponge(this);
|
||||
}
|
||||
return this.spongeSubject;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,6 +62,8 @@ public class PersistedSubject extends CalculatedSubject implements LPSubject {
|
||||
private final PersistedSubjectData subjectData;
|
||||
private final CalculatedSubjectData transientSubjectData;
|
||||
|
||||
private Subject spongeSubject = null;
|
||||
|
||||
/**
|
||||
* The save buffer instance for saving changes to disk
|
||||
*/
|
||||
@ -124,7 +126,10 @@ public class PersistedSubject extends CalculatedSubject implements LPSubject {
|
||||
|
||||
@Override
|
||||
public Subject sponge() {
|
||||
return ProxyFactory.toSponge(this);
|
||||
if (this.spongeSubject == null) {
|
||||
this.spongeSubject = ProxyFactory.toSponge(this);
|
||||
}
|
||||
return this.spongeSubject;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user