Browse Source

Correcting a bug with the new Enderman Endermite farm exploit fix and making it toggleable for servers that wish to allow it!

nossr50 6 years ago
parent
commit
d609b45e68

+ 2 - 1
Changelog.txt

@@ -8,13 +8,14 @@ Key:
   - Removal
 
 Version 2.1.4
-    Removed XP from entities that target endermite to prevent easy exploitation (Credits to BentoBox for the tip!)
+    Removed XP from entities that target endermite to prevent easy exploitation (Credits to TheBentoBox for the tip!) [Can be turned off in experience.yml]
     Fixed a bug where static chance skills like Arcane Salvage were using incorrect calculations for success
     Advanced Salvage now uses a rank system
     Arcane Salvage now goes by your rank to determine the maximum amount of materials salvaged and is no longer percentage based
     Fixed a bug where Iron Arm was checking for Iron Grip to be unlocked instead of itself
     (Plugin Compatibility) mcMMO now ignores cancelled events relating to the player left or right clicking
     (Locale) Changed the string for "Salvage.Ability.Bonus.1" to fit the new material recovery mechanics of Salvage
+    (Config) Added a toggle for the new endermite enderman xp farm fix in experience.yml "ExploitFix.EndermanEndermiteFarms"
     (Config) Cleaned up some leftover 'unlocklevel' settings, this stuff is now handled in skillranks.yml
     (Config) Removed Salvage.MaxPercentage
     (Config) Removed Salvage.MaxPercentageChance

+ 3 - 0
src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java

@@ -141,6 +141,9 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
      * FORMULA SETTINGS
      */
 
+    /* EXPLOIT TOGGLES */
+    public boolean isEndermanEndermiteFarmingPrevented() { return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true); }
+
     /* Curve settings */
     public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
     public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }

+ 6 - 2
src/main/java/com/gmail/nossr50/listeners/EntityListener.java

@@ -3,6 +3,7 @@ package com.gmail.nossr50.listeners;
 import com.gmail.nossr50.config.AdvancedConfig;
 import com.gmail.nossr50.config.Config;
 import com.gmail.nossr50.config.WorldBlacklist;
+import com.gmail.nossr50.config.experience.ExperienceConfig;
 import com.gmail.nossr50.datatypes.meta.OldName;
 import com.gmail.nossr50.datatypes.player.McMMOPlayer;
 import com.gmail.nossr50.datatypes.skills.SubSkillType;
@@ -56,11 +57,14 @@ public class EntityListener implements Listener {
     @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
     public void onEntityTargetEntity(EntityTargetLivingEntityEvent event)
     {
+        if(!ExperienceConfig.getInstance().isEndermanEndermiteFarmingPrevented())
+            return;
+
         //Prevent entities from giving XP if they target endermite
         if(event.getTarget() instanceof Endermite)
         {
-            if(event.getTarget().getMetadata(mcMMO.entityMetadataKey) == null || event.getTarget().getMetadata(mcMMO.entityMetadataKey).size() <= 0)
-                event.getTarget().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
+            if(event.getEntity().getMetadata(mcMMO.entityMetadataKey) == null || event.getEntity().getMetadata(mcMMO.entityMetadataKey).size() <= 0)
+                event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
         }
     }
 

+ 2 - 0
src/main/resources/experience.yml

@@ -22,6 +22,8 @@
 #   Splits the boss bar into 6 segments
 #SOLID
 #   The bar is one solid piece
+ExploitFix:
+    EndermanEndermiteFarms: true
 Experience_Bars:
     # Turn this to false if you wanna disable XP bars
     Enable: true