From 43600ef80024b27572764593c92edd524ce9e40f Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 13 Jun 2019 18:12:10 -0700 Subject: [PATCH] Add and wire up Herbalism AFK exploit toggle --- .../antiexploit/ConfigExploitPrevention.java | 16 ++++++++++++++++ .../ConfigSectionExploitHerbalism.java | 18 ++++++++++++++++++ .../ConfigSectionExploitSkills.java | 11 +++++++++++ .../nossr50/core/SkillPropertiesManager.java | 2 -- .../skills/herbalism/HerbalismManager.java | 3 +-- 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigSectionExploitHerbalism.java diff --git a/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigExploitPrevention.java b/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigExploitPrevention.java index 7db1fad08..212e06784 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigExploitPrevention.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigExploitPrevention.java @@ -87,4 +87,20 @@ public class ConfigExploitPrevention { public boolean isPreventAcrobaticsAbuse() { return getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse(); } + + public ConfigSectionExploitHerbalism getConfigSectionExploitHerbalism() { + return configSectionExploitSkills.getConfigSectionExploitHerbalism(); + } + + public ConfigSectionExploitMining getConfigSectionExploitMining() { + return configSectionExploitSkills.getConfigSectionExploitMining(); + } + + public boolean isPreventCobblestoneStoneGeneratorXP() { + return configSectionExploitSkills.isPreventCobblestoneStoneGeneratorXP(); + } + + public boolean isPreventVehicleAutoFarming() { + return configSectionExploitSkills.isPreventVehicleAutoFarming(); + } } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigSectionExploitHerbalism.java b/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigSectionExploitHerbalism.java new file mode 100644 index 000000000..3351ad13d --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigSectionExploitHerbalism.java @@ -0,0 +1,18 @@ +package com.gmail.nossr50.config.hocon.antiexploit; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigSectionExploitHerbalism { + + private static final boolean VEHICLE_XP_PREVENT_DEFAULT = true; + + @Setting(value = "Prevent-Vehicle-Autofarming", comment = "This setting will prevent players from automating Herbalism XP via vehicles such as minecarts." + + "\nDefault value: "+VEHICLE_XP_PREVENT_DEFAULT) + private boolean preventVehicleAutoFarming = VEHICLE_XP_PREVENT_DEFAULT; + + public boolean isPreventVehicleAutoFarming() { + return preventVehicleAutoFarming; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigSectionExploitSkills.java b/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigSectionExploitSkills.java index 0e4069f3b..806c070bb 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigSectionExploitSkills.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/ConfigSectionExploitSkills.java @@ -14,6 +14,9 @@ public class ConfigSectionExploitSkills { @Setting(value = "Mining", comment = "Exploit settings related to Mining") private ConfigSectionExploitMining configSectionExploitMining = new ConfigSectionExploitMining(); + @Setting(value = "Herbalism", comment = "Exploit settings related to Herbalism.") + private ConfigSectionExploitHerbalism configSectionExploitHerbalism = new ConfigSectionExploitHerbalism(); + public ConfigSectionExploitAcrobatics getConfigSectionExploitAcrobatics() { return configSectionExploitAcrobatics; } @@ -22,6 +25,10 @@ public class ConfigSectionExploitSkills { return configSectionExploitFishing; } + public ConfigSectionExploitHerbalism getConfigSectionExploitHerbalism() { + return configSectionExploitHerbalism; + } + public ConfigSectionExploitMining getConfigSectionExploitMining() { return configSectionExploitMining; } @@ -30,6 +37,10 @@ public class ConfigSectionExploitSkills { return configSectionExploitMining.isPreventCobblestoneStoneGeneratorXP(); } + public boolean isPreventVehicleAutoFarming() { + return configSectionExploitHerbalism.isPreventVehicleAutoFarming(); + } + public long getFishingRodSpamMilliseconds() { return configSectionExploitFishing.getFishingRodSpamMilliseconds(); } diff --git a/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java b/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java index 53ebc6c8c..9c3f2a7ec 100644 --- a/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java +++ b/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java @@ -7,12 +7,10 @@ import com.gmail.nossr50.datatypes.skills.properties.MaxBonusLevel; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.random.InvalidStaticChance; import com.google.common.reflect.TypeToken; -import ninja.leaping.configurate.ValueType; import ninja.leaping.configurate.commented.CommentedConfigurationNode; import ninja.leaping.configurate.objectmapping.ObjectMappingException; import java.util.HashMap; -import java.util.Iterator; /** * Hacky way to do this until I rewrite the skill system fully diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 7767ebdf1..3a97c7314 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.herbalism; -import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig; import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.experience.XPGainReason; @@ -37,7 +36,7 @@ public class HerbalismManager extends SkillManager { } public boolean canBlockCheck() { - return !(MainConfig.getInstance().getHerbalismPreventAFK() && getPlayer().isInsideVehicle()); + return !(mcMMO.getConfigManager().getConfigExploitPrevention().isPreventVehicleAutoFarming() && getPlayer().isInsideVehicle()); } public boolean canGreenThumbBlock(BlockState blockState) {