diff options
author | Matthew <stteg@hotmail.com> | 2016-03-21 18:51:07 -0400 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-03-23 07:32:34 +1100 |
commit | c5d27c5f6fcaf184d7d9c913bb3ac463e354991e (patch) | |
tree | c220ffe5dcfdd9ded99d9065a93083d7236ad72a | |
parent | 5fe510da591a009c9550678d50a9fc0b1072b6f3 (diff) | |
download | craftbukkit-c5d27c5f6fcaf184d7d9c913bb3ac463e354991e.tar craftbukkit-c5d27c5f6fcaf184d7d9c913bb3ac463e354991e.tar.gz craftbukkit-c5d27c5f6fcaf184d7d9c913bb3ac463e354991e.tar.lz craftbukkit-c5d27c5f6fcaf184d7d9c913bb3ac463e354991e.tar.xz craftbukkit-c5d27c5f6fcaf184d7d9c913bb3ac463e354991e.zip |
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.
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 27c1851a..5572ac1d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -25,18 +25,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.util.Vector; public abstract class CraftEntity implements org.bukkit.entity.Entity { - private static final PermissibleBase perm = new PermissibleBase(new ServerOperator() { - - @Override - public boolean isOp() { - return false; - } - - @Override - public void setOp(boolean value) { - - } - }); + private static PermissibleBase perm; protected final CraftServer server; protected Entity entity; @@ -487,67 +476,67 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public boolean isPermissionSet(String name) { - return perm.isPermissionSet(name); + return getPermissibleBase().isPermissionSet(name); } @Override public boolean isPermissionSet(Permission perm) { - return CraftEntity.perm.isPermissionSet(perm); + return CraftEntity.getPermissibleBase().isPermissionSet(perm); } @Override public boolean hasPermission(String name) { - return perm.hasPermission(name); + return getPermissibleBase().hasPermission(name); } @Override public boolean hasPermission(Permission perm) { - return this.perm.hasPermission(perm); + return getPermissibleBase().hasPermission(perm); } @Override public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) { - return perm.addAttachment(plugin, name, value); + return getPermissibleBase().addAttachment(plugin, name, value); } @Override public PermissionAttachment addAttachment(Plugin plugin) { - return perm.addAttachment(plugin); + return getPermissibleBase().addAttachment(plugin); } @Override 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 public PermissionAttachment addAttachment(Plugin plugin, int ticks) { - return perm.addAttachment(plugin, ticks); + return getPermissibleBase().addAttachment(plugin, ticks); } @Override public void removeAttachment(PermissionAttachment attachment) { - perm.removeAttachment(attachment); + getPermissibleBase().removeAttachment(attachment); } @Override public void recalculatePermissions() { - perm.recalculatePermissions(); + getPermissibleBase().recalculatePermissions(); } @Override public Set<PermissionAttachmentInfo> getEffectivePermissions() { - return perm.getEffectivePermissions(); + return getPermissibleBase().getEffectivePermissions(); } @Override public boolean isOp() { - return perm.isOp(); + return getPermissibleBase().isOp(); } @Override public void setOp(boolean value) { - perm.setOp(value); + getPermissibleBase().setOp(value); } @Override @@ -563,4 +552,22 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { public boolean isGlowing() { 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; + } } |