Add highest_inherited and lowest_inherited meta stack elements
This commit is contained in:
parent
2fd74f3b7e
commit
0f4c057395
@ -176,6 +176,8 @@ group-weight:
|
|||||||
# - lowest
|
# - lowest
|
||||||
# - highest_own
|
# - highest_own
|
||||||
# - lowest_own
|
# - lowest_own
|
||||||
|
# - highest_inherited
|
||||||
|
# - lowest_inherited
|
||||||
# - highest_on_track_<track>
|
# - highest_on_track_<track>
|
||||||
# - lowest_on_track_<track>
|
# - lowest_on_track_<track>
|
||||||
# - highest_not_on_track_<track>
|
# - highest_not_on_track_<track>
|
||||||
|
@ -165,6 +165,8 @@ group-weight:
|
|||||||
# - lowest
|
# - lowest
|
||||||
# - highest_own
|
# - highest_own
|
||||||
# - lowest_own
|
# - lowest_own
|
||||||
|
# - highest_inherited
|
||||||
|
# - lowest_inherited
|
||||||
# - highest_on_track_<track>
|
# - highest_on_track_<track>
|
||||||
# - lowest_on_track_<track>
|
# - lowest_on_track_<track>
|
||||||
# - highest_not_on_track_<track>
|
# - highest_not_on_track_<track>
|
||||||
|
@ -51,6 +51,8 @@ public class StandardStackElements {
|
|||||||
private static final LowestPriority LOWEST_PRIORITY = new LowestPriority();
|
private static final LowestPriority LOWEST_PRIORITY = new LowestPriority();
|
||||||
private static final HighestPriorityOwn HIGHEST_PRIORITY_OWN = new HighestPriorityOwn();
|
private static final HighestPriorityOwn HIGHEST_PRIORITY_OWN = new HighestPriorityOwn();
|
||||||
private static final LowestPriorityOwn LOWEST_PRIORITY_OWN = new LowestPriorityOwn();
|
private static final LowestPriorityOwn LOWEST_PRIORITY_OWN = new LowestPriorityOwn();
|
||||||
|
private static final HighestPriorityInherited HIGHEST_PRIORITY_INHERITED = new HighestPriorityInherited();
|
||||||
|
private static final LowestPriorityInherited LOWEST_PRIORITY_INHERITED = new LowestPriorityInherited();
|
||||||
|
|
||||||
public static Optional<MetaStackElement> parseFromString(LuckPermsPlugin plugin, String s) {
|
public static Optional<MetaStackElement> parseFromString(LuckPermsPlugin plugin, String s) {
|
||||||
s = s.toLowerCase();
|
s = s.toLowerCase();
|
||||||
@ -71,6 +73,14 @@ public class StandardStackElements {
|
|||||||
return Optional.of(LOWEST_PRIORITY_OWN);
|
return Optional.of(LOWEST_PRIORITY_OWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s.equals("highest_inherited")) {
|
||||||
|
return Optional.of(HIGHEST_PRIORITY_INHERITED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.equals("lowest_inherited")) {
|
||||||
|
return Optional.of(LOWEST_PRIORITY_INHERITED);
|
||||||
|
}
|
||||||
|
|
||||||
if (s.startsWith("highest_on_track_") && s.length() > "highest_on_track_".length()) {
|
if (s.startsWith("highest_on_track_") && s.length() > "highest_on_track_".length()) {
|
||||||
String track = s.substring("highest_on_track_".length());
|
String track = s.substring("highest_on_track_".length());
|
||||||
return Optional.of(new HighestPriorityTrack(plugin, track));
|
return Optional.of(new HighestPriorityTrack(plugin, track));
|
||||||
@ -129,10 +139,6 @@ public class StandardStackElements {
|
|||||||
* @return true if the accumulation should return
|
* @return true if the accumulation should return
|
||||||
*/
|
*/
|
||||||
private static boolean checkOwnElement(LocalizedNode node) {
|
private static boolean checkOwnElement(LocalizedNode node) {
|
||||||
if (node.getLocation() == null || node.getLocation().equals("")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
UUID.fromString(node.getLocation());
|
UUID.fromString(node.getLocation());
|
||||||
return false;
|
return false;
|
||||||
@ -202,6 +208,23 @@ public class StandardStackElements {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
private static final class HighestPriorityInherited implements MetaStackElement {
|
||||||
|
@Override
|
||||||
|
public boolean shouldAccumulate(LocalizedNode node, ChatMetaType type, Map.Entry<Integer, String> current) {
|
||||||
|
if (type.shouldIgnore(node)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkOwnElement(node)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map.Entry<Integer, String> newEntry = type.getEntry(node);
|
||||||
|
return !compareEntriesHighest(current, newEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ToString(of = "trackName")
|
@ToString(of = "trackName")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@EqualsAndHashCode(of = "trackName")
|
@EqualsAndHashCode(of = "trackName")
|
||||||
@ -268,6 +291,23 @@ public class StandardStackElements {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
private static final class LowestPriorityInherited implements MetaStackElement {
|
||||||
|
@Override
|
||||||
|
public boolean shouldAccumulate(LocalizedNode node, ChatMetaType type, Map.Entry<Integer, String> current) {
|
||||||
|
if (type.shouldIgnore(node)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkOwnElement(node)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map.Entry<Integer, String> newEntry = type.getEntry(node);
|
||||||
|
return !compareEntriesLowest(current, newEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ToString(of = "trackName")
|
@ToString(of = "trackName")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@EqualsAndHashCode(of = "trackName")
|
@EqualsAndHashCode(of = "trackName")
|
||||||
|
@ -175,6 +175,8 @@ group-weight {
|
|||||||
# - lowest
|
# - lowest
|
||||||
# - highest_own
|
# - highest_own
|
||||||
# - lowest_own
|
# - lowest_own
|
||||||
|
# - highest_inherited
|
||||||
|
# - lowest_inherited
|
||||||
# - highest_on_track_<track>
|
# - highest_on_track_<track>
|
||||||
# - lowest_on_track_<track>
|
# - lowest_on_track_<track>
|
||||||
# - highest_not_on_track_<track>
|
# - highest_not_on_track_<track>
|
||||||
|
Loading…
Reference in New Issue
Block a user