From a5cef9c1ff49fc2f32a62f88b2006c4d968c822d Mon Sep 17 00:00:00 2001 From: Auxilor Date: Wed, 24 Mar 2021 18:40:20 +0000 Subject: [PATCH] Updated config and allowed enchantments to work on npcs with a config optoin --- .../com/willfp/ecoenchants/EcoEnchantsPlugin.java | 3 ++- .../ecoenchants/normal/Telekinesis.java | 2 +- .../enchantments/util/WatcherTriggers.java | 15 +++++++++++++++ .../core-plugin/src/main/resources/config.yml | 7 +++---- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java index f0af73e1..f6f714e4 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/EcoEnchantsPlugin.java @@ -204,7 +204,8 @@ public class EcoEnchantsPlugin extends AbstractEcoPlugin { EnchantmentTarget.class, EcoEnchants.class, TabCompleterEnchantinfo.class, - EnchantmentType.class + EnchantmentType.class, + WatcherTriggers.class ); } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java index e9491299..a44bfd90 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Telekinesis.java @@ -41,7 +41,7 @@ public class Telekinesis extends EcoEnchant { @Override protected void postUpdate() { - always = this.getPlugin().getConfigYml().getBool("drops.force-dropqueue"); + always = this.getPlugin().getConfigYml().getBool("advanced.force-dropqueue"); } // For block drops diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java index 9d3204c7..09e00263 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/util/WatcherTriggers.java @@ -2,11 +2,13 @@ package com.willfp.ecoenchants.enchantments.util; import com.google.common.collect.Sets; import com.willfp.eco.util.TridentUtils; +import com.willfp.eco.util.config.updating.annotations.ConfigUpdater; import com.willfp.eco.util.events.armorequip.ArmorEquipEvent; import com.willfp.eco.util.integrations.antigrief.AntigriefManager; import com.willfp.eco.util.integrations.mcmmo.McmmoManager; import com.willfp.eco.util.internal.PluginDependent; import com.willfp.eco.util.plugin.AbstractEcoPlugin; +import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchants; import org.bukkit.Material; import org.bukkit.block.Block; @@ -47,6 +49,11 @@ public class WatcherTriggers extends PluginDependent implements Listener { */ private static final DecimalFormat FORMAT = new DecimalFormat("0.00"); + /** + * If watchers should be triggered against npcs. + */ + private static boolean allowOnNPC = false; + /** * Create new listener for watcher events. * @@ -718,4 +725,12 @@ public class WatcherTriggers extends PluginDependent implements Listener { enchant.onDeflect(blocker, attacker, level, event); }); } + + /** + * Update if allowed on npc. + */ + @ConfigUpdater + public static void update() { + allowOnNPC = EcoEnchantsPlugin.getInstance().getConfig().getBoolean("allow-on-npc"); + } } diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index 39ee5602..1facbc22 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -3,6 +3,8 @@ # by Auxilor # +allow-on-npc: false # If enchantments should activate against NPCs. + commands: enchantinfo: show-target-group: true # Show name of target group rather than individual items @@ -102,14 +104,11 @@ rarity: vanilla-treasure-rarity: legendary # Treasure enchantments do not appear in vanilla enchanting tables (Mending, Soul Speed, Frost Walker) # The above options *do not* affect actual enchantment rarities. They are purely for cosmetic purposes, like in item lores. -drops: - ### ADVANCED OPTIONS +advanced: force-dropqueue: true # When combined with collate, this massively reduces calls to getItemMeta, which can hurt performance when many enchants are on an item. # Without collate, the number of calls may be increased - which will further hurt performance # Enabling this option makes all drops go through telekinesis listeners - -advanced: lore-getter: # This converts enchantments with matching names from other enchantment plugins from lore into real enchantments. # This is experimental not recommended to be used for extended periods of time: enchantments are automatically converted.