Add not_on_track meta stack criteria
This commit is contained in:
parent
a27436b086
commit
3314e94a9a
@ -116,6 +116,8 @@ group-weight:
|
|||||||
# - lowest_own
|
# - lowest_own
|
||||||
# - highest_on_track_<track>
|
# - highest_on_track_<track>
|
||||||
# - lowest_on_track_<track>
|
# - lowest_on_track_<track>
|
||||||
|
# - highest_not_on_track_<track>
|
||||||
|
# - lowest_not_on_track_<track>
|
||||||
#
|
#
|
||||||
# Each element is added in the order listed.
|
# Each element is added in the order listed.
|
||||||
meta-formatting:
|
meta-formatting:
|
||||||
|
@ -116,6 +116,8 @@ group-weight:
|
|||||||
# - lowest_own
|
# - lowest_own
|
||||||
# - highest_on_track_<track>
|
# - highest_on_track_<track>
|
||||||
# - lowest_on_track_<track>
|
# - lowest_on_track_<track>
|
||||||
|
# - highest_not_on_track_<track>
|
||||||
|
# - lowest_not_on_track_<track>
|
||||||
#
|
#
|
||||||
# Each element is added in the order listed.
|
# Each element is added in the order listed.
|
||||||
meta-formatting:
|
meta-formatting:
|
||||||
|
@ -94,4 +94,20 @@ public interface MetaStackElement {
|
|||||||
return t == null || !t.containsGroup(node.getLocation());
|
return t == null || !t.containsGroup(node.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the node is held by a group on the track
|
||||||
|
* @param node the node to check
|
||||||
|
* @param track the track
|
||||||
|
* @return true if the accumulation should return
|
||||||
|
*/
|
||||||
|
static boolean checkNotTrackElement(LuckPermsPlugin plugin, LocalizedNode node, String track) {
|
||||||
|
// it's not come from a group on this track (from the user directly)
|
||||||
|
if (node.getLocation() == null || node.getLocation().equals("")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Track t = plugin.getTrackManager().getIfLoaded(track);
|
||||||
|
return t == null || t.containsGroup(node.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,11 @@ package me.lucko.luckperms.common.caching.stacking;
|
|||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.caching.stacking.elements.HighestPriorityElement;
|
import me.lucko.luckperms.common.caching.stacking.elements.HighestPriorityElement;
|
||||||
|
import me.lucko.luckperms.common.caching.stacking.elements.HighestPriorityNotOnTrackElement;
|
||||||
import me.lucko.luckperms.common.caching.stacking.elements.HighestPriorityOwnElement;
|
import me.lucko.luckperms.common.caching.stacking.elements.HighestPriorityOwnElement;
|
||||||
import me.lucko.luckperms.common.caching.stacking.elements.HighestPriorityTrackElement;
|
import me.lucko.luckperms.common.caching.stacking.elements.HighestPriorityTrackElement;
|
||||||
import me.lucko.luckperms.common.caching.stacking.elements.LowestPriorityElement;
|
import me.lucko.luckperms.common.caching.stacking.elements.LowestPriorityElement;
|
||||||
|
import me.lucko.luckperms.common.caching.stacking.elements.LowestPriorityNotOnTrackElement;
|
||||||
import me.lucko.luckperms.common.caching.stacking.elements.LowestPriorityOwnElement;
|
import me.lucko.luckperms.common.caching.stacking.elements.LowestPriorityOwnElement;
|
||||||
import me.lucko.luckperms.common.caching.stacking.elements.LowestPriorityTrackElement;
|
import me.lucko.luckperms.common.caching.stacking.elements.LowestPriorityTrackElement;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
@ -71,6 +73,16 @@ public class StackElementFactory {
|
|||||||
return Optional.of(new LowestPriorityTrackElement(prefix, plugin, track));
|
return Optional.of(new LowestPriorityTrackElement(prefix, plugin, track));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s.startsWith("highest_not_on_track_") && s.length() > "highest_not_on_track_".length()) {
|
||||||
|
String track = s.substring("highest_not_on_track_".length());
|
||||||
|
return Optional.of(new HighestPriorityNotOnTrackElement(prefix, plugin, track));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.startsWith("lowest_not_on_track_") && s.length() > "lowest_not_on_track_".length()) {
|
||||||
|
String track = s.substring("lowest_not_on_track_".length());
|
||||||
|
return Optional.of(new LowestPriorityNotOnTrackElement(prefix, plugin, track));
|
||||||
|
}
|
||||||
|
|
||||||
new IllegalArgumentException("Cannot parse MetaStackElement: " + s).printStackTrace();
|
new IllegalArgumentException("Cannot parse MetaStackElement: " + s).printStackTrace();
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.caching.stacking.elements;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.LocalizedNode;
|
||||||
|
import me.lucko.luckperms.common.caching.stacking.MetaStackElement;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class HighestPriorityNotOnTrackElement implements MetaStackElement {
|
||||||
|
private final boolean prefix;
|
||||||
|
private final LuckPermsPlugin plugin;
|
||||||
|
private final String trackName;
|
||||||
|
|
||||||
|
private Map.Entry<Integer, String> entry = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Map.Entry<Integer, String>> getEntry() {
|
||||||
|
return Optional.ofNullable(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accumulateNode(LocalizedNode node) {
|
||||||
|
if (MetaStackElement.checkMetaType(prefix, node)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map.Entry<Integer, String> entry = prefix ? node.getPrefix() : node.getSuffix();
|
||||||
|
if (HighestPriorityElement.compareEntries(this.entry, entry)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MetaStackElement.checkNotTrackElement(plugin, node, trackName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entry = entry;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetaStackElement copy() {
|
||||||
|
return new HighestPriorityNotOnTrackElement(prefix, plugin, trackName);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.caching.stacking.elements;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.LocalizedNode;
|
||||||
|
import me.lucko.luckperms.common.caching.stacking.MetaStackElement;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class LowestPriorityNotOnTrackElement implements MetaStackElement {
|
||||||
|
private final boolean prefix;
|
||||||
|
private final LuckPermsPlugin plugin;
|
||||||
|
private final String trackName;
|
||||||
|
|
||||||
|
private Map.Entry<Integer, String> entry = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Map.Entry<Integer, String>> getEntry() {
|
||||||
|
return Optional.ofNullable(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accumulateNode(LocalizedNode node) {
|
||||||
|
if (MetaStackElement.checkMetaType(prefix, node)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map.Entry<Integer, String> entry = prefix ? node.getPrefix() : node.getSuffix();
|
||||||
|
if (LowestPriorityElement.compareEntries(this.entry, entry)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MetaStackElement.checkNotTrackElement(plugin, node, trackName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entry = entry;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetaStackElement copy() {
|
||||||
|
return new LowestPriorityNotOnTrackElement(prefix, plugin, trackName);
|
||||||
|
}
|
||||||
|
}
|
@ -57,7 +57,6 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* An immutable permission node
|
* An immutable permission node
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
|
||||||
@ToString(of = {"permission", "value", "override", "server", "world", "expireAt", "contexts"})
|
@ToString(of = {"permission", "value", "override", "server", "world", "expireAt", "contexts"})
|
||||||
@EqualsAndHashCode(of = {"permission", "value", "override", "server", "world", "expireAt", "contexts"})
|
@EqualsAndHashCode(of = {"permission", "value", "override", "server", "world", "expireAt", "contexts"})
|
||||||
public final class ImmutableNode implements Node {
|
public final class ImmutableNode implements Node {
|
||||||
@ -193,6 +192,7 @@ public final class ImmutableNode implements Node {
|
|||||||
* @param world the world this node applies on
|
* @param world the world this node applies on
|
||||||
* @param contexts any additional contexts applying to this node
|
* @param contexts any additional contexts applying to this node
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public ImmutableNode(String permission, boolean value, boolean override, long expireAt, String server, String world, ContextSet contexts) {
|
public ImmutableNode(String permission, boolean value, boolean override, long expireAt, String server, String world, ContextSet contexts) {
|
||||||
if (permission == null || permission.equals("")) {
|
if (permission == null || permission.equals("")) {
|
||||||
throw new IllegalArgumentException("Empty permission");
|
throw new IllegalArgumentException("Empty permission");
|
||||||
|
@ -118,6 +118,8 @@ group-weight {
|
|||||||
# - lowest_own
|
# - lowest_own
|
||||||
# - highest_on_track_<track>
|
# - highest_on_track_<track>
|
||||||
# - lowest_on_track_<track>
|
# - lowest_on_track_<track>
|
||||||
|
# - highest_not_on_track_<track>
|
||||||
|
# - lowest_not_on_track_<track>
|
||||||
#
|
#
|
||||||
# Each element is added in the order listed.
|
# Each element is added in the order listed.
|
||||||
meta-formatting {
|
meta-formatting {
|
||||||
|
Loading…
Reference in New Issue
Block a user