diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/dummy/DummyPermissibleBase.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/dummy/DummyPermissibleBase.java index 8f8524de..88cd1082 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/dummy/DummyPermissibleBase.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/dummy/DummyPermissibleBase.java @@ -53,12 +53,12 @@ public class DummyPermissibleBase extends PermissibleBase { public static void nullFields(PermissibleBase permissibleBase) { try { - ATTACHMENTS_FIELD.set(permissibleBase, null); + ATTACHMENTS_FIELD.set(permissibleBase, Collections.emptyList()); } catch (Exception e) { // ignore } try { - PERMISSIONS_FIELD.set(permissibleBase, null); + PERMISSIONS_FIELD.set(permissibleBase, Collections.emptyMap()); } catch (Exception e) { // ignore } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/permissible/LPPermissionAttachment.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/permissible/LPPermissionAttachment.java index 71a7c65c..9ecd7181 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/permissible/LPPermissionAttachment.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/model/permissible/LPPermissionAttachment.java @@ -110,7 +110,7 @@ public class LPPermissionAttachment extends PermissionAttachment { public LPPermissionAttachment(LPPermissible permissible, PermissionAttachment source) { super(DummyPlugin.INSTANCE, null); this.permissible = permissible; - this.owner = null; + this.owner = source.getPlugin(); // copy this.perms.putAll(source.getPermissions()); @@ -389,19 +389,29 @@ public class LPPermissionAttachment extends PermissionAttachment { @Override public Set keySet() { // just proxy - return LPPermissionAttachment.this.perms.keySet(); + return Collections.unmodifiableSet(LPPermissionAttachment.this.perms.keySet()); } @Override public Collection values() { // just proxy - return LPPermissionAttachment.this.perms.values(); + return Collections.unmodifiableCollection(LPPermissionAttachment.this.perms.values()); } @Override public Set> entrySet() { // just proxy - return LPPermissionAttachment.this.perms.entrySet(); + return Collections.unmodifiableSet(LPPermissionAttachment.this.perms.entrySet()); + } + + @Override + public boolean equals(Object obj) { + return obj instanceof Map && LPPermissionAttachment.this.perms.equals(obj); + } + + @Override + public int hashCode() { + return LPPermissionAttachment.this.perms.hashCode(); } } } diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/dummy/DummyPermissibleBase.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/dummy/DummyPermissibleBase.java index 15af8c25..07a9caac 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/dummy/DummyPermissibleBase.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/dummy/DummyPermissibleBase.java @@ -53,12 +53,12 @@ public class DummyPermissibleBase extends PermissibleBase { public static void nullFields(PermissibleBase permissibleBase) { try { - ATTACHMENTS_FIELD.set(permissibleBase, null); + ATTACHMENTS_FIELD.set(permissibleBase, Collections.emptyList()); } catch (Exception e) { // ignore } try { - PERMISSIONS_FIELD.set(permissibleBase, null); + PERMISSIONS_FIELD.set(permissibleBase, Collections.emptyMap()); } catch (Exception e) { // ignore } diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/permissible/LPPermissionAttachment.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/permissible/LPPermissionAttachment.java index 2182542d..09ac5366 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/permissible/LPPermissionAttachment.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/model/permissible/LPPermissionAttachment.java @@ -109,13 +109,13 @@ public class LPPermissionAttachment extends PermissionAttachment { injectFakeMap(); } - public LPPermissionAttachment(LPPermissible permissible, PermissionAttachment nukkit) { + public LPPermissionAttachment(LPPermissible permissible, PermissionAttachment source) { super(DummyPlugin.INSTANCE, null); this.permissible = permissible; - this.owner = null; + this.owner = source.getPlugin(); // copy - this.perms.putAll(nukkit.getPermissions()); + this.perms.putAll(source.getPermissions()); this.source = source; injectFakeMap(); @@ -419,19 +419,29 @@ public class LPPermissionAttachment extends PermissionAttachment { @Override public Set keySet() { // just proxy - return LPPermissionAttachment.this.perms.keySet(); + return Collections.unmodifiableSet(LPPermissionAttachment.this.perms.keySet()); } @Override public Collection values() { // just proxy - return LPPermissionAttachment.this.perms.values(); + return Collections.unmodifiableCollection(LPPermissionAttachment.this.perms.values()); } @Override public Set> entrySet() { // just proxy - return LPPermissionAttachment.this.perms.entrySet(); + return Collections.unmodifiableSet(LPPermissionAttachment.this.perms.entrySet()); + } + + @Override + public boolean equals(Object obj) { + return obj instanceof Map && LPPermissionAttachment.this.perms.equals(obj); + } + + @Override + public int hashCode() { + return LPPermissionAttachment.this.perms.hashCode(); } } }