diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 65103db8b..9a936c05a 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -251,9 +251,6 @@ public class PlayerListener implements Listener { FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); - if(fishingManager.exploitPrevention()) - return; - switch (event.getState()) { case CAUGHT_FISH: //TODO Update to new API once available! Waiting for case CAUGHT_TREASURE: @@ -315,9 +312,6 @@ public class PlayerListener implements Listener { FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); - if(fishingManager.exploitPrevention()) - return; - Entity caught = event.getCaught(); switch (event.getState()) { @@ -329,6 +323,8 @@ public class PlayerListener implements Listener { return; case CAUGHT_FISH: + if(fishingManager.exploitPrevention(event.getHook().getBoundingBox())) + return; fishingManager.handleFishing((Item) caught); fishingManager.setFishingTarget(); return; 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 d702f360d..a293566d9 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -32,6 +32,7 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.util.BoundingBox; import java.util.*; @@ -39,7 +40,7 @@ public class FishingManager extends SkillManager { private final long FISHING_COOLDOWN_SECONDS = 1000L; private long fishingTimestamp = 0L; - private Location fishingTarget; + private BoundingBox lastFishingBoundingBox; private Item fishingCatch; private Location hookLocation; @@ -55,7 +56,7 @@ public class FishingManager extends SkillManager { return getSkillLevel() >= RankUtils.getUnlockLevel(SubSkillType.FISHING_MASTER_ANGLER) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_MASTER_ANGLER); } - public boolean exploitPrevention() { + public boolean exploitPrevention(BoundingBox boundingBox) { Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100); @@ -69,10 +70,9 @@ public class FishingManager extends SkillManager { if(hasFished) fishingTimestamp = currentTime; - Location targetLocation = targetBlock.getLocation(); - boolean sameTarget = (fishingTarget != null && fishingTarget.equals(targetLocation)); + boolean sameTarget = (lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(boundingBox)); - fishingTarget = targetLocation; + lastFishingBoundingBox = boundingBox; return hasFished || sameTarget; }