From 25f31d0bb8396f9eb2a54548123e9aefafd5e994 Mon Sep 17 00:00:00 2001 From: Luck Date: Mon, 3 Apr 2017 10:27:31 +0100 Subject: [PATCH] Cleanup sponge delegate classes --- .../common/core/model/PermissionHolder.java | 62 ++++--- .../luckperms/common/core/model/User.java | 9 +- .../migration/SpongeMigrationUtils.java | 39 ++--- .../sponge/service/LuckPermsSubjectData.java | 158 ++++++++++++------ .../calculated/CalculatedSubjectData.java | 70 ++++---- .../SubjectCollectionReference.java | 7 +- .../service/references/SubjectReference.java | 12 +- 7 files changed, 212 insertions(+), 145 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/core/model/PermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/core/model/PermissionHolder.java index f0ce26ed2..aed698b97 100644 --- a/common/src/main/java/me/lucko/luckperms/common/core/model/PermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/core/model/PermissionHolder.java @@ -992,33 +992,44 @@ public abstract class PermissionHolder { /** * Clear all of the holders permission nodes */ - public void clearNodes() { + public boolean clearNodes() { ImmutableSet before = ImmutableSet.copyOf(getNodes().values()); synchronized (nodes) { nodes.clear(); } invalidateCache(); ImmutableSet after = ImmutableSet.copyOf(getNodes().values()); + + if (before.size() == after.size()) { + return false; + } + plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after); + return true; } - public void clearNodes(ContextSet contextSet) { + public boolean clearNodes(ContextSet contextSet) { ImmutableSet before = ImmutableSet.copyOf(getNodes().values()); synchronized (nodes) { nodes.removeAll(contextSet.makeImmutable()); } invalidateCache(); ImmutableSet after = ImmutableSet.copyOf(getNodes().values()); + + if (before.size() == after.size()) { + return false; + } + plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after); + return true; } - public void clearParents(boolean giveDefault) { + public boolean clearParents(boolean giveDefault) { ImmutableSet before = ImmutableSet.copyOf(getNodes().values()); - synchronized (nodes) { boolean b = nodes.values().removeIf(Node::isGroupNode); if (!b) { - return; + return false; } } if (this instanceof User && giveDefault) { @@ -1027,19 +1038,20 @@ public abstract class PermissionHolder { invalidateCache(); ImmutableSet after = ImmutableSet.copyOf(getNodes().values()); plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after); + return true; } - public void clearParents(ContextSet contextSet, boolean giveDefault) { + public boolean clearParents(ContextSet contextSet, boolean giveDefault) { ImmutableSet before = ImmutableSet.copyOf(getNodes().values()); synchronized (nodes) { SortedSet nodes = this.nodes.get(contextSet.makeImmutable()); if (nodes == null) { - return; + return false; } boolean b = nodes.removeIf(Node::isGroupNode); if (!b) { - return; + return false; } } if (this instanceof User && giveDefault) { @@ -1048,80 +1060,90 @@ public abstract class PermissionHolder { invalidateCache(); ImmutableSet after = ImmutableSet.copyOf(getNodes().values()); plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after); + return true; } - public void clearMeta() { + public boolean clearMeta() { ImmutableSet before = ImmutableSet.copyOf(getNodes().values()); synchronized (nodes) { if (!nodes.values().removeIf(n -> n.isMeta() || n.isPrefix() || n.isSuffix())) { - return; + return false; } } invalidateCache(); ImmutableSet after = ImmutableSet.copyOf(getNodes().values()); plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after); + return true; } - public void clearMeta(ContextSet contextSet) { + public boolean clearMeta(ContextSet contextSet) { ImmutableSet before = ImmutableSet.copyOf(getNodes().values()); synchronized (nodes) { SortedSet nodes = this.nodes.get(contextSet.makeImmutable()); if (nodes == null) { - return; + return false; } boolean b = nodes.removeIf(n -> n.isMeta() || n.isPrefix() || n.isSuffix()); if (!b) { - return; + return false; } } invalidateCache(); ImmutableSet after = ImmutableSet.copyOf(getNodes().values()); plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after); + return true; } - public void clearMetaKeys(String key, boolean temp) { + public boolean clearMetaKeys(String key, boolean temp) { ImmutableSet before = ImmutableSet.copyOf(getNodes().values()); synchronized (nodes) { boolean b = this.nodes.values().removeIf(n -> n.isMeta() && (n.isTemporary() == temp) && n.getMeta().getKey().equalsIgnoreCase(key)); if (!b) { - return; + return false; } } invalidateCache(); ImmutableSet after = ImmutableSet.copyOf(getNodes().values()); plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after); + return true; } - public void clearMetaKeys(String key, ContextSet contextSet, boolean temp) { + public boolean clearMetaKeys(String key, ContextSet contextSet, boolean temp) { ImmutableSet before = ImmutableSet.copyOf(getNodes().values()); synchronized (nodes) { SortedSet nodes = this.nodes.get(contextSet.makeImmutable()); if (nodes == null) { - return; + return false; } boolean b = nodes.removeIf(n -> n.isMeta() && (n.isTemporary() == temp) && n.getMeta().getKey().equalsIgnoreCase(key)); if (!b) { - return; + return false; } } invalidateCache(); ImmutableSet after = ImmutableSet.copyOf(getNodes().values()); plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after); + return true; } - public void clearTransientNodes() { + public boolean clearTransientNodes() { ImmutableSet before = ImmutableSet.copyOf(getTransientNodes().values()); - synchronized (transientNodes) { transientNodes.clear(); } invalidateCache(); ImmutableSet after = ImmutableSet.copyOf(getTransientNodes().values()); + + if (before.size() == after.size()) { + return false; + } + plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after); + return true; } /** diff --git a/common/src/main/java/me/lucko/luckperms/common/core/model/User.java b/common/src/main/java/me/lucko/luckperms/common/core/model/User.java index d61d53c48..19edd047d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/core/model/User.java +++ b/common/src/main/java/me/lucko/luckperms/common/core/model/User.java @@ -154,9 +154,14 @@ public class User extends PermissionHolder implements Identifiable, Map> e : perms.entrySet()) { ContextSet context = Util.convertContexts(e.getKey()); - ExtractedContexts extractedContexts = ExtractedContexts.generate(context); - ContextSet contexts = extractedContexts.getContextSet(); - String server = extractedContexts.getServer(); - String world = extractedContexts.getWorld(); - for (Map.Entry perm : e.getValue().entrySet()) { - holder.setPermission(NodeFactory.newBuilder(perm.getKey()).setServer(server).setWorld(world).withExtraContext(contexts).setValue(perm.getValue()).build()); + holder.setPermission(NodeFactory.newBuilder(perm.getKey()).withExtraContext(context).setValue(perm.getValue()).build()); } } @@ -71,18 +64,13 @@ public class SpongeMigrationUtils { for (Map.Entry, Map> e : opts.entrySet()) { ContextSet context = Util.convertContexts(e.getKey()); - ExtractedContexts extractedContexts = ExtractedContexts.generate(context); - ContextSet contexts = extractedContexts.getContextSet(); - String server = extractedContexts.getServer(); - String world = extractedContexts.getWorld(); - for (Map.Entry opt : e.getValue().entrySet()) { if (opt.getKey().equalsIgnoreCase("prefix")) { - holder.setPermission(NodeFactory.makePrefixNode(priority, opt.getValue()).setServer(server).setWorld(world).withExtraContext(contexts).setValue(true).build()); + holder.setPermission(NodeFactory.makePrefixNode(priority, opt.getValue()).withExtraContext(context).setValue(true).build()); } else if (opt.getKey().equalsIgnoreCase("suffix")) { - holder.setPermission(NodeFactory.makeSuffixNode(priority, opt.getValue()).setServer(server).setWorld(world).withExtraContext(contexts).setValue(true).build()); + holder.setPermission(NodeFactory.makeSuffixNode(priority, opt.getValue()).withExtraContext(context).setValue(true).build()); } else { - holder.setPermission(NodeFactory.makeMetaNode(opt.getKey(), opt.getValue()).setServer(server).setWorld(world).withExtraContext(contexts).setValue(true).build()); + holder.setPermission(NodeFactory.makeMetaNode(opt.getKey(), opt.getValue()).withExtraContext(context).setValue(true).build()); } } } @@ -92,34 +80,29 @@ public class SpongeMigrationUtils { for (Map.Entry, List> e : parents.entrySet()) { ContextSet context = Util.convertContexts(e.getKey()); - ExtractedContexts extractedContexts = ExtractedContexts.generate(context); - ContextSet contexts = extractedContexts.getContextSet(); - String server = extractedContexts.getServer(); - String world = extractedContexts.getWorld(); - for (Subject s : e.getValue()) { if (!s.getContainingCollection().getIdentifier().equalsIgnoreCase(PermissionService.SUBJECTS_GROUP)) { continue; // LuckPerms does not support persisting other subject types. } - holder.setPermission(NodeFactory.newBuilder("group." + MigrationUtils.standardizeName(s.getIdentifier())).setServer(server).setWorld(world).withExtraContext(contexts).setValue(true).build()); + holder.setPermission(NodeFactory.newBuilder("group." + MigrationUtils.standardizeName(s.getIdentifier())).withExtraContext(context).setValue(true).build()); } } } public static void migrateSubjectData(SubjectData from, SubjectData to) { - for (Map.Entry, Map> e : from.getAllOptions().entrySet()) { - for (Map.Entry e1 : e.getValue().entrySet()) { - to.setOption(e.getKey(), e1.getKey(), e1.getValue()); - } - } - for (Map.Entry, Map> e : from.getAllPermissions().entrySet()) { for (Map.Entry e1 : e.getValue().entrySet()) { to.setPermission(e.getKey(), e1.getKey(), Tristate.fromBoolean(e1.getValue())); } } + for (Map.Entry, Map> e : from.getAllOptions().entrySet()) { + for (Map.Entry e1 : e.getValue().entrySet()) { + to.setOption(e.getKey(), e1.getKey(), e1.getValue()); + } + } + for (Map.Entry, List> e : from.getAllParents().entrySet()) { for (Subject s : e.getValue()) { to.addParent(e.getKey(), s); diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsSubjectData.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsSubjectData.java index 2962884bf..a8ae19cff 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsSubjectData.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsSubjectData.java @@ -34,6 +34,7 @@ import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.common.caching.MetaAccumulator; +import me.lucko.luckperms.common.core.DataMutateResult; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.core.model.Group; import me.lucko.luckperms.common.core.model.PermissionHolder; @@ -48,8 +49,8 @@ import org.spongepowered.api.service.permission.PermissionService; import co.aikar.timings.Timing; +import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -72,16 +73,19 @@ public class LuckPermsSubjectData implements LPSubjectData { @Override public Map> getPermissions() { try (Timing ignored = service.getPlugin().getTimings().time(LPTiming.LP_SUBJECT_GET_PERMISSIONS)) { - Map> perms = new HashMap<>(); + Map> perms = new HashMap<>(); - for (Node n : enduring ? holder.getNodes().values() : holder.getTransientNodes().values()) { - ContextSet contexts = n.getFullContexts(); - perms.computeIfAbsent(contexts.makeImmutable(), cs -> new HashMap<>()).put(n.getPermission(), n.getValue()); + for (Map.Entry> e : (enduring ? holder.getNodes() : holder.getTransientNodes()).asMap().entrySet()) { + ImmutableMap.Builder results = ImmutableMap.builder(); + for (Node n : e.getValue()) { + results.put(n.getPermission(), n.getValue()); + } + perms.put(e.getKey(), results); } ImmutableMap.Builder> map = ImmutableMap.builder(); - for (Map.Entry> e : perms.entrySet()) { - map.put(e.getKey(), ImmutableMap.copyOf(e.getValue())); + for (Map.Entry> e : perms.entrySet()) { + map.put(e.getKey(), e.getValue().build()); } return map.build(); } @@ -127,10 +131,15 @@ public class LuckPermsSubjectData implements LPSubjectData { @Override public boolean clearPermissions() { try (Timing ignored = service.getPlugin().getTimings().time(LPTiming.LP_SUBJECT_CLEAR_PERMISSIONS)) { + boolean ret; if (enduring) { - holder.clearNodes(); + ret = holder.clearNodes(); } else { - holder.clearTransientNodes(); + ret = holder.clearTransientNodes(); + } + + if (!ret) { + return false; } if (holder instanceof User) { @@ -145,36 +154,50 @@ public class LuckPermsSubjectData implements LPSubjectData { @Override public boolean clearPermissions(@NonNull ContextSet set) { try (Timing i = service.getPlugin().getTimings().time(LPTiming.LP_SUBJECT_CLEAR_PERMISSIONS)) { - List toRemove = streamNodes(enduring) - .filter(n -> n.getFullContexts().equals(set)) - .collect(Collectors.toList()); + boolean ret; - toRemove.forEach(makeUnsetConsumer(enduring)); + if (enduring) { + ret = holder.clearNodes(set); + } else { + List toRemove = streamNodes(false) + .filter(n -> n.getFullContexts().equals(set)) + .collect(Collectors.toList()); + + toRemove.forEach(makeUnsetConsumer(false)); + ret = !toRemove.isEmpty(); + } + + if (!ret) { + return false; + } if (holder instanceof User) { service.getPlugin().getUserManager().giveDefaultIfNeeded(((User) holder), false); } objectSave(holder); - return !toRemove.isEmpty(); + return true; } } @Override public Map> getParents() { try (Timing ignored = service.getPlugin().getTimings().time(LPTiming.LP_SUBJECT_GET_PARENTS)) { - Map> parents = new HashMap<>(); + Map> parents = new HashMap<>(); - for (Node n : enduring ? holder.getNodes().values() : holder.getTransientNodes().values()) { - if (!n.isGroupNode()) continue; - - ContextSet contexts = n.getFullContexts(); - parents.computeIfAbsent(contexts.makeImmutable(), cs -> new HashSet<>()).add(service.getGroupSubjects().get(n.getGroupName()).toReference()); + for (Map.Entry> e : (enduring ? holder.getNodes() : holder.getTransientNodes()).asMap().entrySet()) { + ImmutableSet.Builder results = ImmutableSet.builder(); + for (Node n : e.getValue()) { + if (n.isGroupNode()) { + results.add(service.getGroupSubjects().get(n.getGroupName()).toReference()); + } + } + parents.put(e.getKey(), results); } ImmutableMap.Builder> map = ImmutableMap.builder(); - for (Map.Entry> e : parents.entrySet()) { - map.put(e.getKey(), ImmutableSet.copyOf(e.getValue())); + for (Map.Entry> e : parents.entrySet()) { + map.put(e.getKey(), e.getValue().build()); } return map.build(); } @@ -185,17 +208,22 @@ public class LuckPermsSubjectData implements LPSubjectData { try (Timing i = service.getPlugin().getTimings().time(LPTiming.LP_SUBJECT_ADD_PARENT)) { if (subject.getCollection().equals(PermissionService.SUBJECTS_GROUP)) { LPSubject permsSubject = subject.resolve(service); + DataMutateResult result; if (enduring) { - holder.setPermission(NodeFactory.newBuilder("group." + permsSubject.getIdentifier()) + result = holder.setPermission(NodeFactory.newBuilder("group." + permsSubject.getIdentifier()) .withExtraContext(contexts) .build()); } else { - holder.setTransientPermission(NodeFactory.newBuilder("group." + permsSubject.getIdentifier()) + result = holder.setTransientPermission(NodeFactory.newBuilder("group." + permsSubject.getIdentifier()) .withExtraContext(contexts) .build()); } + if (!result.asBoolean()) { + return false; + } + objectSave(holder); return true; } @@ -208,17 +236,22 @@ public class LuckPermsSubjectData implements LPSubjectData { try (Timing i = service.getPlugin().getTimings().time(LPTiming.LP_SUBJECT_REMOVE_PARENT)) { if (subject.getCollection().equals(PermissionService.SUBJECTS_GROUP)) { LPSubject permsSubject = subject.resolve(service); + DataMutateResult result; if (enduring) { - holder.unsetPermission(NodeFactory.newBuilder("group." + permsSubject.getIdentifier()) + result = holder.unsetPermission(NodeFactory.newBuilder("group." + permsSubject.getIdentifier()) .withExtraContext(contexts) .build()); } else { - holder.unsetTransientPermission(NodeFactory.newBuilder("group." + permsSubject.getIdentifier()) + result = holder.unsetTransientPermission(NodeFactory.newBuilder("group." + permsSubject.getIdentifier()) .withExtraContext(contexts) .build()); } + if (!result.asBoolean()) { + return false; + } + objectSave(holder); return true; } @@ -229,37 +262,58 @@ public class LuckPermsSubjectData implements LPSubjectData { @Override public boolean clearParents() { try (Timing i = service.getPlugin().getTimings().time(LPTiming.LP_SUBJECT_CLEAR_PARENTS)) { - List toRemove = streamNodes(enduring) - .filter(Node::isGroupNode) - .collect(Collectors.toList()); + boolean ret; - toRemove.forEach(makeUnsetConsumer(enduring)); + if (enduring) { + ret = holder.clearParents(true); + } else { + List toRemove = streamNodes(false) + .filter(Node::isGroupNode) + .collect(Collectors.toList()); - if (holder instanceof User) { - service.getPlugin().getUserManager().giveDefaultIfNeeded(((User) holder), false); + toRemove.forEach(makeUnsetConsumer(false)); + ret = !toRemove.isEmpty(); + + if (ret && holder instanceof User) { + service.getPlugin().getUserManager().giveDefaultIfNeeded(((User) holder), false); + } + } + + if (!ret) { + return false; } objectSave(holder); - return !toRemove.isEmpty(); + return true; } } @Override public boolean clearParents(@NonNull ContextSet set) { try (Timing i = service.getPlugin().getTimings().time(LPTiming.LP_SUBJECT_CLEAR_PARENTS)) { - List toRemove = streamNodes(enduring) - .filter(Node::isGroupNode) - .filter(n -> n.getFullContexts().equals(set)) - .collect(Collectors.toList()); + boolean ret; + if (enduring) { + ret = holder.clearParents(set, true); + } else { + List toRemove = streamNodes(false) + .filter(Node::isGroupNode) + .filter(n -> n.getFullContexts().equals(set)) + .collect(Collectors.toList()); - toRemove.forEach(makeUnsetConsumer(enduring)); + toRemove.forEach(makeUnsetConsumer(false)); + ret = !toRemove.isEmpty(); - if (holder instanceof User) { - service.getPlugin().getUserManager().giveDefaultIfNeeded(((User) holder), false); + if (ret && holder instanceof User) { + service.getPlugin().getUserManager().giveDefaultIfNeeded(((User) holder), false); + } + } + + if (!ret) { + return false; } objectSave(holder); - return !toRemove.isEmpty(); + return true; } } @@ -429,13 +483,21 @@ public class LuckPermsSubjectData implements LPSubjectData { } private void objectSave(PermissionHolder t) { - if (t instanceof User) { - service.getPlugin().getStorage().saveUser(((User) t)) - .thenRunAsync(() -> ((User) t).getRefreshBuffer().request(), service.getPlugin().getScheduler().getAsyncExecutor()); - } - if (t instanceof Group) { - service.getPlugin().getStorage().saveGroup((Group) t) - .thenRunAsync(() -> service.getPlugin().getUpdateTaskBuffer().request(), service.getPlugin().getScheduler().getAsyncExecutor()); + if (!enduring) { + // don't bother saving to primary storage. just refresh + if (t instanceof User) { + ((User) t).getRefreshBuffer().request(); + } else { + service.getPlugin().getUpdateTaskBuffer().request(); + } + } else { + if (t instanceof User) { + service.getPlugin().getStorage().saveUser(((User) t)) + .thenRunAsync(() -> ((User) t).getRefreshBuffer().request(), service.getPlugin().getScheduler().getAsyncExecutor()); + } else { + service.getPlugin().getStorage().saveGroup((Group) t) + .thenRunAsync(() -> service.getPlugin().getUpdateTaskBuffer().request(), service.getPlugin().getScheduler().getAsyncExecutor()); + } } } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/calculated/CalculatedSubjectData.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/calculated/CalculatedSubjectData.java index ef4f320a6..5a7e60fcb 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/calculated/CalculatedSubjectData.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/calculated/CalculatedSubjectData.java @@ -59,43 +59,6 @@ import java.util.concurrent.TimeUnit; public class CalculatedSubjectData implements LPSubjectData { private static final ContextComparator CONTEXT_COMPARATOR = new ContextComparator(); - private static Map flattenMap(ContextSet contexts, Map> source) { - Map map = new HashMap<>(); - - SortedMap> ret = getRelevantEntries(contexts, source); - for (Map m : ret.values()) { - for (Map.Entry e : m.entrySet()) { - if (!map.containsKey(e.getKey())) { - map.put(e.getKey(), e.getValue()); - } - } - } - - return ImmutableMap.copyOf(map); - } - - private static SortedMap> getRelevantEntries(ContextSet set, Map> map) { - ImmutableSortedMap.Builder> perms = ImmutableSortedMap.orderedBy(CONTEXT_COMPARATOR); - - loop: - for (Map.Entry> e : map.entrySet()) { - - for (Map.Entry c : e.getKey().toSet()) { - if (!set.has(c.getKey(), c.getValue())) { - continue loop; - } - } - - perms.put(e.getKey().makeImmutable(), ImmutableMap.copyOf(e.getValue())); - } - - return perms.build(); - } - - private static boolean stringEquals(String a, String b) { - return a == null && b == null || a != null && b != null && a.equalsIgnoreCase(b); - } - @Getter private final LPSubject parentSubject; @@ -342,6 +305,39 @@ public class CalculatedSubjectData implements LPSubjectData { return !map.isEmpty(); } + private static Map flattenMap(ContextSet contexts, Map> source) { + Map map = new HashMap<>(); + + SortedMap> ret = getRelevantEntries(contexts, source); + for (Map m : ret.values()) { + for (Map.Entry e : m.entrySet()) { + if (!map.containsKey(e.getKey())) { + map.put(e.getKey(), e.getValue()); + } + } + } + + return ImmutableMap.copyOf(map); + } + + private static SortedMap> getRelevantEntries(ContextSet set, Map> map) { + ImmutableSortedMap.Builder> perms = ImmutableSortedMap.orderedBy(CONTEXT_COMPARATOR); + + for (Map.Entry> e : map.entrySet()) { + if (!e.getKey().isSatisfiedBy(set)) { + continue; + } + + perms.put(e.getKey().makeImmutable(), ImmutableMap.copyOf(e.getValue())); + } + + return perms.build(); + } + + private static boolean stringEquals(String a, String b) { + return a == null && b == null || a != null && b != null && a.equalsIgnoreCase(b); + } + private static class ContextComparator implements Comparator { @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/references/SubjectCollectionReference.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/references/SubjectCollectionReference.java index 6f2ecc799..84854c471 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/references/SubjectCollectionReference.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/references/SubjectCollectionReference.java @@ -32,13 +32,14 @@ import me.lucko.luckperms.sponge.service.proxy.LPSubjectCollection; import java.lang.ref.WeakReference; -@Getter -@ToString -@EqualsAndHashCode +@ToString(of = "collection") +@EqualsAndHashCode(of = "collection") @RequiredArgsConstructor(staticName = "of") public class SubjectCollectionReference { + @Getter private final String collection; + private WeakReference ref = null; public synchronized LPSubjectCollection resolve(LuckPermsService service) { diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/references/SubjectReference.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/references/SubjectReference.java index 8e6c71732..f6a970ecc 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/references/SubjectReference.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/references/SubjectReference.java @@ -37,9 +37,8 @@ import org.spongepowered.api.service.permission.Subject; import java.lang.ref.WeakReference; import java.util.List; -@Getter -@ToString -@EqualsAndHashCode +@ToString(of = {"collection", "identifier"}) +@EqualsAndHashCode(of = {"collection", "identifier"}) @RequiredArgsConstructor(staticName = "of") public class SubjectReference { public static SubjectReference deserialize(String s) { @@ -51,7 +50,10 @@ public class SubjectReference { return of(subject.getContainingCollection().getIdentifier(), subject.getIdentifier()); } + @Getter private final String collection; + + @Getter private final String identifier; private WeakReference ref = null; @@ -69,8 +71,4 @@ public class SubjectReference { return s; } - public String serialize() { - return collection + "/" + identifier; - } - }