Added option to only activate highest level talisman
This commit is contained in:
@@ -199,6 +199,26 @@ public class TalismanChecks {
|
||||
found.add(talisman);
|
||||
}
|
||||
|
||||
if (PLUGIN.getConfigYml().getBool("highest-level-only")) {
|
||||
Map<Talisman, Integer> highestFound = new HashMap<>();
|
||||
Set<TalismanLevel> foundClone = new HashSet<>(found);
|
||||
found.clear();
|
||||
|
||||
for (TalismanLevel talismanLevel : foundClone) {
|
||||
Integer highestLevel = highestFound.get(talismanLevel.getTalisman());
|
||||
if (highestLevel != null) {
|
||||
if (highestLevel < talismanLevel.getLevel()) {
|
||||
found.remove(talismanLevel.getTalisman().getLevel(highestLevel));
|
||||
highestFound.put(talismanLevel.getTalisman(), talismanLevel.getLevel());
|
||||
found.add(talismanLevel);
|
||||
}
|
||||
} else {
|
||||
found.add(talismanLevel);
|
||||
highestFound.put(talismanLevel.getTalisman(), talismanLevel.getLevel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useCache) {
|
||||
CACHED_TALISMANS.put(player.getUniqueId(), found);
|
||||
PLUGIN.getScheduler().runLater(() -> CACHED_TALISMANS.remove(player.getUniqueId()), 40);
|
||||
|
||||
@@ -14,3 +14,5 @@ read-enderchest: true # If a player's ender chest should be checked for talisman
|
||||
read-shulkerboxes: true # If a player's shulker boxes should be checked for talismans
|
||||
|
||||
offhand-only: false # If talismans or shulkers of talismans need to be in the offhand to work
|
||||
|
||||
highest-level-only: false # If only the highest level talisman is activated rather than different levels stacking.
|
||||
|
||||
Reference in New Issue
Block a user