mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-19 05:31:32 +01:00
Only create PermissibleBase instance in CraftEntity the first time it is actually needed. Fixes static test cases for subclasses failing when perm field was instantiated.
By: Matthew <stteg@hotmail.com>
This commit is contained in:
parent
15f22a7986
commit
07a80cec7f
1 changed files with 32 additions and 25 deletions
|
@ -25,18 +25,7 @@ import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||||
private static final PermissibleBase perm = new PermissibleBase(new ServerOperator() {
|
private static PermissibleBase perm;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOp() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setOp(boolean value) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
protected final CraftServer server;
|
protected final CraftServer server;
|
||||||
protected Entity entity;
|
protected Entity entity;
|
||||||
|
@ -487,67 +476,67 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPermissionSet(String name) {
|
public boolean isPermissionSet(String name) {
|
||||||
return perm.isPermissionSet(name);
|
return getPermissibleBase().isPermissionSet(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPermissionSet(Permission perm) {
|
public boolean isPermissionSet(Permission perm) {
|
||||||
return CraftEntity.perm.isPermissionSet(perm);
|
return CraftEntity.getPermissibleBase().isPermissionSet(perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String name) {
|
public boolean hasPermission(String name) {
|
||||||
return perm.hasPermission(name);
|
return getPermissibleBase().hasPermission(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(Permission perm) {
|
public boolean hasPermission(Permission perm) {
|
||||||
return this.perm.hasPermission(perm);
|
return getPermissibleBase().hasPermission(perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
|
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
|
||||||
return perm.addAttachment(plugin, name, value);
|
return getPermissibleBase().addAttachment(plugin, name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionAttachment addAttachment(Plugin plugin) {
|
public PermissionAttachment addAttachment(Plugin plugin) {
|
||||||
return perm.addAttachment(plugin);
|
return getPermissibleBase().addAttachment(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
|
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
|
||||||
return perm.addAttachment(plugin, name, value, ticks);
|
return getPermissibleBase().addAttachment(plugin, name, value, ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
|
public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
|
||||||
return perm.addAttachment(plugin, ticks);
|
return getPermissibleBase().addAttachment(plugin, ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeAttachment(PermissionAttachment attachment) {
|
public void removeAttachment(PermissionAttachment attachment) {
|
||||||
perm.removeAttachment(attachment);
|
getPermissibleBase().removeAttachment(attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recalculatePermissions() {
|
public void recalculatePermissions() {
|
||||||
perm.recalculatePermissions();
|
getPermissibleBase().recalculatePermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||||
return perm.getEffectivePermissions();
|
return getPermissibleBase().getEffectivePermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOp() {
|
public boolean isOp() {
|
||||||
return perm.isOp();
|
return getPermissibleBase().isOp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOp(boolean value) {
|
public void setOp(boolean value) {
|
||||||
perm.setOp(value);
|
getPermissibleBase().setOp(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -563,4 +552,22 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||||
public boolean isGlowing() {
|
public boolean isGlowing() {
|
||||||
return getHandle().glowing;
|
return getHandle().glowing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static PermissibleBase getPermissibleBase() {
|
||||||
|
if (perm == null) {
|
||||||
|
perm = new PermissibleBase(new ServerOperator() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOp() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOp(boolean value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return perm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue