From d1f683b8a52451b75ecd77a9467411e342500bd1 Mon Sep 17 00:00:00 2001 From: Glitchfinder Date: Wed, 7 Nov 2012 18:41:18 -0800 Subject: [PATCH] Adding the option to negate experience earned for Acrobatics or Herbalism while in a minecart to prevent afk leveling. --- src/main/java/com/gmail/nossr50/config/Config.java | 4 ++++ .../gmail/nossr50/skills/acrobatics/AcrobaticsManager.java | 4 ++++ .../java/com/gmail/nossr50/skills/gathering/Herbalism.java | 6 ++++++ src/main/resources/config.yml | 2 ++ 4 files changed, 16 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 8554d5f78..7420f7548 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -300,6 +300,10 @@ public class Config extends ConfigLoader { return disabled; } + /* AFK Leveling */ + public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); } + public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); } + /* Arcane Forging */ public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Arcane_Forging.Downgrades.Enabled", true); } public int getArcaneForgingDowngradeChanceRank1() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_1", 75); } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 5361df9fa..241b042a6 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.acrobatics; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.util.Permissions; @@ -33,6 +34,9 @@ public class AcrobaticsManager { return; } + if(Config.getInstance().getAcrobaticsAFKDisabled() && player.isInsideVehicle()) + return; + RollEventHandler eventHandler = new RollEventHandler(this, event); int randomChance = 1000; diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java index 303cdad1c..956759a77 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java @@ -80,6 +80,9 @@ public class Herbalism { * @param plugin mcMMO plugin instance */ public static void herbalismProcCheck(final Block block, Player player, BlockBreakEvent event, mcMMO plugin) { + if(player == null) + return; + final PlayerProfile profile = Users.getProfile(player); final int MAX_BONUS_LEVEL = 1000; @@ -363,6 +366,9 @@ public class Herbalism { } } + if(Config.getInstance().getHerbalismAFKDisabled() && player.isInsideVehicle()) + return; + Skills.xpProcessing(player, profile, SkillType.HERBALISM, xp); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d731a4e61..5fd0980d9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -133,6 +133,7 @@ Skills: Acrobatics: Enabled_For_PVP: true Enabled_For_PVE: true + Prevent_AFK_Leveling: true Level_Cap: 0 Archery: Enabled_For_PVP: true @@ -149,6 +150,7 @@ Skills: Level_Cap: 0 Herbalism: Level_Cap: 0 + Prevent_AFK_Leveling: true Green_Thumb: Cobble_To_Mossy: true CobbleWall_To_MossyWall: true