Added option to only activate highest level talisman

This commit is contained in:
Auxilor
2021-07-23 00:39:13 +01:00
parent a291872877
commit 861d92c475
2 changed files with 22 additions and 0 deletions

View File

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

View File

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