From 56fe8ecd6be21f8a291ee1bfec6524cf754e29af Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 8 Mar 2021 20:53:36 +0000 Subject: [PATCH] Added offhand read only --- .../talismans/talismans/util/TalismanChecks.java | 11 +++++++++++ eco-core/core-plugin/src/main/resources/config.yml | 2 ++ 2 files changed, 13 insertions(+) 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 71c59d3..621ed7e 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 @@ -46,6 +46,11 @@ public class TalismanChecks { */ private static boolean readShulkerBoxes = true; + /** + * If only offhand should be read. + */ + private static boolean offhandOnly = false; + /** * The associated plugin instance. */ @@ -149,6 +154,11 @@ public class TalismanChecks { rawContents.addAll(Arrays.asList(player.getEnderChest().getContents())); } + if (offhandOnly) { + rawContents.clear(); + rawContents.add(player.getInventory().getItemInOffHand()); + } + rawContents.addAll(Arrays.asList(extra)); for (ItemStack rawContent : rawContents) { @@ -207,5 +217,6 @@ public class TalismanChecks { public static void reload() { readEnderChest = PLUGIN.getConfigYml().getBool("read-enderchest"); readShulkerBoxes = PLUGIN.getConfigYml().getBool("read-shulkerboxes"); + offhandOnly = PLUGIN.getConfigYml().getBool("offhand-only"); } } diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index f7635ff..a374e81 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -20,3 +20,5 @@ crafting: read-enderchest: true # If a player's ender chest should be checked for talismans 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