From c4f890d00e711a0c543b4c9edda342917ea9be68 Mon Sep 17 00:00:00 2001 From: smuddgge <68658429+smuddgge@users.noreply.github.com> Date: Thu, 19 Jan 2023 12:32:46 +0000 Subject: [PATCH] Fixed fishing exploiting compatibility --- .../nossr50/listeners/PlayerListener.java | 3 ++ .../skills/fishing/FishingManager.java | 28 ++++++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index fb906ad1d..9a7b52b73 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -450,6 +450,9 @@ public class PlayerListener implements Listener { case CAUGHT_FISH: if(caught instanceof Item) { if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) { + + fishingManager.processExploiting(event.getHook().getLocation().toVector()); + if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) { player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange())); event.setExpToDrop(0); diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index a0f4f014a..6dde1330d 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -125,6 +125,20 @@ public class FishingManager extends SkillManager { return hasFished; } + public void processExploiting(Vector centerOfCastVector) { + BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector); + boolean sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox); + + if (sameTarget) + fishCaughtCounter++; + else + fishCaughtCounter = 1; + + if (fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit()) { + getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange())); + } + } + public boolean isExploitingFishing(Vector centerOfCastVector) { /*Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100); @@ -134,22 +148,10 @@ public class FishingManager extends SkillManager { }*/ BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector); - boolean sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox); - if(sameTarget) - fishCaughtCounter++; - else - fishCaughtCounter = 1; - - if(fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit()) - { - 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; + if (!sameTarget) lastFishingBoundingBox = newCastBoundingBox; return sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit(); }