More workarounds to support MassiveCore's modification of attachment permissions via reflection
This commit is contained in:
parent
644c53a074
commit
f4e4f727dd
@ -53,12 +53,12 @@ public class DummyPermissibleBase extends PermissibleBase {
|
|||||||
|
|
||||||
public static void nullFields(PermissibleBase permissibleBase) {
|
public static void nullFields(PermissibleBase permissibleBase) {
|
||||||
try {
|
try {
|
||||||
ATTACHMENTS_FIELD.set(permissibleBase, null);
|
ATTACHMENTS_FIELD.set(permissibleBase, Collections.emptyList());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PERMISSIONS_FIELD.set(permissibleBase, null);
|
PERMISSIONS_FIELD.set(permissibleBase, Collections.emptyMap());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
|||||||
public LPPermissionAttachment(LPPermissible permissible, PermissionAttachment source) {
|
public LPPermissionAttachment(LPPermissible permissible, PermissionAttachment source) {
|
||||||
super(DummyPlugin.INSTANCE, null);
|
super(DummyPlugin.INSTANCE, null);
|
||||||
this.permissible = permissible;
|
this.permissible = permissible;
|
||||||
this.owner = null;
|
this.owner = source.getPlugin();
|
||||||
|
|
||||||
// copy
|
// copy
|
||||||
this.perms.putAll(source.getPermissions());
|
this.perms.putAll(source.getPermissions());
|
||||||
@ -389,19 +389,29 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
|||||||
@Override
|
@Override
|
||||||
public Set<String> keySet() {
|
public Set<String> keySet() {
|
||||||
// just proxy
|
// just proxy
|
||||||
return LPPermissionAttachment.this.perms.keySet();
|
return Collections.unmodifiableSet(LPPermissionAttachment.this.perms.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Boolean> values() {
|
public Collection<Boolean> values() {
|
||||||
// just proxy
|
// just proxy
|
||||||
return LPPermissionAttachment.this.perms.values();
|
return Collections.unmodifiableCollection(LPPermissionAttachment.this.perms.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Entry<String, Boolean>> entrySet() {
|
public Set<Entry<String, Boolean>> entrySet() {
|
||||||
// just proxy
|
// 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,12 +53,12 @@ public class DummyPermissibleBase extends PermissibleBase {
|
|||||||
|
|
||||||
public static void nullFields(PermissibleBase permissibleBase) {
|
public static void nullFields(PermissibleBase permissibleBase) {
|
||||||
try {
|
try {
|
||||||
ATTACHMENTS_FIELD.set(permissibleBase, null);
|
ATTACHMENTS_FIELD.set(permissibleBase, Collections.emptyList());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PERMISSIONS_FIELD.set(permissibleBase, null);
|
PERMISSIONS_FIELD.set(permissibleBase, Collections.emptyMap());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
@ -109,13 +109,13 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
|||||||
injectFakeMap();
|
injectFakeMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LPPermissionAttachment(LPPermissible permissible, PermissionAttachment nukkit) {
|
public LPPermissionAttachment(LPPermissible permissible, PermissionAttachment source) {
|
||||||
super(DummyPlugin.INSTANCE, null);
|
super(DummyPlugin.INSTANCE, null);
|
||||||
this.permissible = permissible;
|
this.permissible = permissible;
|
||||||
this.owner = null;
|
this.owner = source.getPlugin();
|
||||||
|
|
||||||
// copy
|
// copy
|
||||||
this.perms.putAll(nukkit.getPermissions());
|
this.perms.putAll(source.getPermissions());
|
||||||
this.source = source;
|
this.source = source;
|
||||||
|
|
||||||
injectFakeMap();
|
injectFakeMap();
|
||||||
@ -419,19 +419,29 @@ public class LPPermissionAttachment extends PermissionAttachment {
|
|||||||
@Override
|
@Override
|
||||||
public Set<String> keySet() {
|
public Set<String> keySet() {
|
||||||
// just proxy
|
// just proxy
|
||||||
return LPPermissionAttachment.this.perms.keySet();
|
return Collections.unmodifiableSet(LPPermissionAttachment.this.perms.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Boolean> values() {
|
public Collection<Boolean> values() {
|
||||||
// just proxy
|
// just proxy
|
||||||
return LPPermissionAttachment.this.perms.values();
|
return Collections.unmodifiableCollection(LPPermissionAttachment.this.perms.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Entry<String, Boolean>> entrySet() {
|
public Set<Entry<String, Boolean>> entrySet() {
|
||||||
// just proxy
|
// 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user