Browse Source

Propose: Add an option for Exploiting Fishing. (#4619)

* feat: Add exploiting option for fishing

* Update experience.yml

Let's change how this was named

* Update ExperienceConfig.java

Let's change how this was named

Co-authored-by: Robert Alan Chapton <nossr50@gmail.com>
tunagohan 3 năm trước cách đây
mục cha
commit
7fc6577196

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

@@ -155,6 +155,9 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
     public boolean isNPCInteractionPrevented() { return config.getBoolean("ExploitFix.PreventPluginNPCInteraction", true); }
 
     public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
+    public int getFishingExploitingOptionMoveRange() { return config.getInt("Fishing_ExploitFix_Options.MoveRange", 3); }
+    public int getFishingExploitingOptionOverFishLimit() { return config.getInt("Fishing_ExploitFix_Options.OverFishLimit", 10); }
+
     public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); }
     public boolean isTreeFellerXPReduced() { return config.getBoolean("ExploitFix.TreeFellerReducedXP", true); }
 

+ 3 - 3
src/main/java/com/gmail/nossr50/listeners/PlayerListener.java

@@ -449,7 +449,7 @@ public class PlayerListener implements Listener {
                 if(caught instanceof Item) {
                     if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) {
                         if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) {
-                            player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", 3));
+                            player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
                             event.setExpToDrop(0);
                             Item caughtItem = (Item) caught;
                             caughtItem.remove();
@@ -886,7 +886,7 @@ public class PlayerListener implements Listener {
                 if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {
                     break;
                 }
-                
+
                 /* ACTIVATION CHECKS */
                 if (mcMMO.p.getGeneralConfig().getAbilitiesEnabled()) {
                     mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES);
@@ -1005,7 +1005,7 @@ public class PlayerListener implements Listener {
      * When a {@link Player} attempts to place an {@link ItemStack}
      * into an {@link ItemFrame}, we want to make sure to remove any
      * Ability buffs from that item.
-     * 
+     *
      * @param event The {@link PlayerInteractEntityEvent} to handle
      */
     @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)

+ 5 - 5
src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java

@@ -43,7 +43,6 @@ import java.util.*;
 
 public class FishingManager extends SkillManager {
     public static final int FISHING_ROD_CAST_CD_MILLISECONDS = 100;
-    public static final int OVERFISH_LIMIT = 10;
     private final long FISHING_COOLDOWN_SECONDS = 1000L;
 
     private long fishingRodCastTimestamp = 0L;
@@ -143,20 +142,21 @@ public class FishingManager extends SkillManager {
         else
             fishCaughtCounter = 1;
 
-        if(fishCaughtCounter + 1 == OVERFISH_LIMIT)
+        if(fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit())
         {
-            getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", 3));
+            getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
         }
 
         //If the new bounding box does not intersect with the old one, then update our bounding box reference
         if(!sameTarget)
             lastFishingBoundingBox = newCastBoundingBox;
 
-        return sameTarget && fishCaughtCounter >= OVERFISH_LIMIT;
+        return sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit();
     }
 
     public static BoundingBox makeBoundingBox(Vector centerOfCastVector) {
-        return BoundingBox.of(centerOfCastVector, 1, 1, 1);
+        int exploitingRange = ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange();
+        return BoundingBox.of(centerOfCastVector, exploitingRange / 2, 1, exploitingRange / 2);
     }
 
     public void setFishingTarget() {

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

@@ -39,6 +39,9 @@ ExploitFix:
     # mcMMO normally doesn't process attacks against an Entity if it is an NPC from another plugin
     # Of course, mcMMO doesn't know for sure whether or not something is an NPC, it checks a few known things, see our source code to see how
     PreventPluginNPCInteraction: true
+Fishing_ExploitFix_Options:
+    MoveRange: 3
+    OverFishLimit: 10
 Experience_Bars:
     # Turn this to false if you wanna disable XP bars
     Enable: true