Fix all users sharing the same meta state

This commit is contained in:
Luck 2017-01-22 22:19:29 +00:00
parent 247871f678
commit 8025f3a082
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
11 changed files with 52 additions and 2 deletions

View File

@ -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
);
}
}

View File

@ -30,6 +30,7 @@ public interface MetaStack {
List<MetaStackElement> getElements();
String toFormattedString();
MetaStack copy();
default void accumulateToAll(LocalizedNode node) {
getElements().forEach(m -> m.accumulateNode(node));

View File

@ -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

View File

@ -37,4 +37,9 @@ public class NoopMetaStack implements MetaStack {
public String toFormattedString() {
return null;
}
@Override
public MetaStack copy() {
return this;
}
}

View File

@ -65,4 +65,9 @@ public class HighestPriorityElement implements MetaStackElement {
this.entry = entry;
return true;
}
@Override
public MetaStackElement copy() {
return new HighestPriorityElement(prefix);
}
}

View File

@ -59,4 +59,9 @@ public class HighestPriorityOwnElement implements MetaStackElement {
return true;
}
@Override
public MetaStackElement copy() {
return new HighestPriorityOwnElement(prefix);
}
}

View File

@ -62,4 +62,9 @@ public class HighestPriorityTrackElement implements MetaStackElement {
this.entry = entry;
return true;
}
@Override
public MetaStackElement copy() {
return new HighestPriorityTrackElement(prefix, plugin, trackName);
}
}

View File

@ -65,4 +65,9 @@ public class LowestPriorityElement implements MetaStackElement {
this.entry = entry;
return true;
}
@Override
public MetaStackElement copy() {
return new LowestPriorityElement(prefix);
}
}

View File

@ -58,4 +58,9 @@ public class LowestPriorityOwnElement implements MetaStackElement {
this.entry = entry;
return true;
}
@Override
public MetaStackElement copy() {
return new LowestPriorityOwnElement(prefix);
}
}

View File

@ -62,4 +62,9 @@ public class LowestPriorityTrackElement implements MetaStackElement {
this.entry = entry;
return true;
}
@Override
public MetaStackElement copy() {
return new LowestPriorityTrackElement(prefix, plugin, trackName);
}
}

View File

@ -468,8 +468,8 @@ public abstract class PermissionHolder {
public MetaHolder accumulateMeta(MetaHolder holder, List<String> 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()
);
}