diff --git a/eco-core/core-plugin/src/main/java/com/willfp/talismans/talismans/util/TalismanChecks.java b/eco-core/core-plugin/src/main/java/com/willfp/talismans/talismans/util/TalismanChecks.java index 03a9b20..2501a9e 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/talismans/talismans/util/TalismanChecks.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/talismans/talismans/util/TalismanChecks.java @@ -199,6 +199,26 @@ public class TalismanChecks { found.add(talisman); } + if (PLUGIN.getConfigYml().getBool("highest-level-only")) { + Map highestFound = new HashMap<>(); + Set 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); diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index cd253a0..002ea30 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -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.