From 8025f3a082382e344dfae0c961b0b3a87db23537 Mon Sep 17 00:00:00 2001 From: Luck Date: Sun, 22 Jan 2017 22:19:29 +0000 Subject: [PATCH] Fix all users sharing the same meta state --- .../common/caching/stacking/GenericMetaStack.java | 12 ++++++++++++ .../luckperms/common/caching/stacking/MetaStack.java | 1 + .../common/caching/stacking/MetaStackElement.java | 2 ++ .../common/caching/stacking/NoopMetaStack.java | 5 +++++ .../stacking/elements/HighestPriorityElement.java | 5 +++++ .../stacking/elements/HighestPriorityOwnElement.java | 5 +++++ .../elements/HighestPriorityTrackElement.java | 5 +++++ .../stacking/elements/LowestPriorityElement.java | 5 +++++ .../stacking/elements/LowestPriorityOwnElement.java | 5 +++++ .../elements/LowestPriorityTrackElement.java | 5 +++++ .../common/core/model/PermissionHolder.java | 4 ++-- 11 files changed, 52 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/GenericMetaStack.java b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/GenericMetaStack.java index 4b8c00ab..fc91b383 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/GenericMetaStack.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/GenericMetaStack.java @@ -25,6 +25,8 @@ package me.lucko.luckperms.common.caching.stacking; import lombok.Getter; import lombok.RequiredArgsConstructor; +import me.lucko.luckperms.common.utils.ImmutableCollectors; + import java.util.ArrayList; import java.util.List; @@ -60,4 +62,14 @@ public class GenericMetaStack implements MetaStack { return sb.toString(); } + + @Override + public MetaStack copy() { + return new GenericMetaStack( + elements.stream().map(MetaStackElement::copy).collect(ImmutableCollectors.toImmutableList()), + startSpacer, + middleSpacer, + endSpacer + ); + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/MetaStack.java b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/MetaStack.java index 864a62c8..b08df0c6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/MetaStack.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/MetaStack.java @@ -30,6 +30,7 @@ public interface MetaStack { List getElements(); String toFormattedString(); + MetaStack copy(); default void accumulateToAll(LocalizedNode node) { getElements().forEach(m -> m.accumulateNode(node)); diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/MetaStackElement.java b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/MetaStackElement.java index 99860a20..64f1cdfa 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/MetaStackElement.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/MetaStackElement.java @@ -36,6 +36,8 @@ public interface MetaStackElement { boolean accumulateNode(LocalizedNode node); + MetaStackElement copy(); + /** * Returns true if the types do not match * @param expectingPrefix if the method is expecting a prefix diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/NoopMetaStack.java b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/NoopMetaStack.java index f93b4eab..22b8e46e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/NoopMetaStack.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/NoopMetaStack.java @@ -37,4 +37,9 @@ public class NoopMetaStack implements MetaStack { public String toFormattedString() { return null; } + + @Override + public MetaStack copy() { + return this; + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityElement.java b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityElement.java index e01a743c..0d015e32 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityElement.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityElement.java @@ -65,4 +65,9 @@ public class HighestPriorityElement implements MetaStackElement { this.entry = entry; return true; } + + @Override + public MetaStackElement copy() { + return new HighestPriorityElement(prefix); + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityOwnElement.java b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityOwnElement.java index cb2a39b0..30c7a53d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityOwnElement.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityOwnElement.java @@ -59,4 +59,9 @@ public class HighestPriorityOwnElement implements MetaStackElement { return true; } + @Override + public MetaStackElement copy() { + return new HighestPriorityOwnElement(prefix); + } + } diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityTrackElement.java b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityTrackElement.java index 05a090e0..799b75b7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityTrackElement.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/HighestPriorityTrackElement.java @@ -62,4 +62,9 @@ public class HighestPriorityTrackElement implements MetaStackElement { this.entry = entry; return true; } + + @Override + public MetaStackElement copy() { + return new HighestPriorityTrackElement(prefix, plugin, trackName); + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityElement.java b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityElement.java index 9ef82b1a..e865b14b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityElement.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityElement.java @@ -65,4 +65,9 @@ public class LowestPriorityElement implements MetaStackElement { this.entry = entry; return true; } + + @Override + public MetaStackElement copy() { + return new LowestPriorityElement(prefix); + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityOwnElement.java b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityOwnElement.java index 5eb085c5..c318da4b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityOwnElement.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityOwnElement.java @@ -58,4 +58,9 @@ public class LowestPriorityOwnElement implements MetaStackElement { this.entry = entry; return true; } + + @Override + public MetaStackElement copy() { + return new LowestPriorityOwnElement(prefix); + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityTrackElement.java b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityTrackElement.java index d29194e2..8ff7d367 100644 --- a/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityTrackElement.java +++ b/common/src/main/java/me/lucko/luckperms/common/caching/stacking/elements/LowestPriorityTrackElement.java @@ -62,4 +62,9 @@ public class LowestPriorityTrackElement implements MetaStackElement { this.entry = entry; return true; } + + @Override + public MetaStackElement copy() { + return new LowestPriorityTrackElement(prefix, plugin, trackName); + } } 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 597316be..42b8e772 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 @@ -468,8 +468,8 @@ public abstract class PermissionHolder { public MetaHolder accumulateMeta(MetaHolder holder, List excludedGroups, ExtractedContexts contexts) { if (holder == null) { holder = new MetaHolder( - plugin.getConfiguration().get(ConfigKeys.PREFIX_FORMATTING_OPTIONS), - plugin.getConfiguration().get(ConfigKeys.SUFFIX_FORMATTING_OPTIONS) + plugin.getConfiguration().get(ConfigKeys.PREFIX_FORMATTING_OPTIONS).copy(), + plugin.getConfiguration().get(ConfigKeys.SUFFIX_FORMATTING_OPTIONS).copy() ); }