diff --git a/Changelog.txt b/Changelog.txt
index 6ea5050be..ecebaff20 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -7,6 +7,10 @@ Key:
! Change
- Removal
+Version 2.1.19
+ Improved Fishing AFK detection
+ Fixed a bug where Fishing AFK detection did not work on a new exploit
+
Version 2.1.18
You will need to add Kelp to your experience.yml file for this fix to be fully functional
Breaking Kelp will now properly count its XP
diff --git a/pom.xml b/pom.xml
index edb8ea5d2..57bf86f19 100755
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.gmail.nossr50.mcMMO
mcMMO
- 2.1.18
+ 2.1.19-SNAPSHOT
mcMMO
https://github.com/mcMMO-Dev/mcMMO
diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java
index 263b2598e..fbd841aab 100644
--- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java
@@ -29,6 +29,7 @@ import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
+import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -331,21 +332,18 @@ public class PlayerListener implements Listener {
fishingManager.setFishingTarget();
}
return;
-
case CAUGHT_FISH:
- if(fishingManager.exploitPrevention(event.getHook().getBoundingBox()))
+ if(fishingManager.exploitPrevention(event.getHook().getLocation().toVector()))
return;
fishingManager.handleFishing((Item) caught);
fishingManager.setFishingTarget();
return;
-
case CAUGHT_ENTITY:
if (fishingManager.canShake(caught)) {
fishingManager.shakeCheck((LivingEntity) caught);
fishingManager.setFishingTarget();
}
return;
-
default:
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 5c2e27348..62696dca1 100644
--- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java
@@ -23,6 +23,7 @@ import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
+import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -34,6 +35,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.util.BoundingBox;
+import org.bukkit.util.Vector;
import java.util.*;
@@ -57,13 +59,16 @@ public class FishingManager extends SkillManager {
return getSkillLevel() >= RankUtils.getUnlockLevel(SubSkillType.FISHING_MASTER_ANGLER) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.FISHING_MASTER_ANGLER);
}
- public boolean exploitPrevention(BoundingBox boundingBox) {
+ public boolean exploitPrevention(Vector centerOfCastVector) {
- Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
+ /*Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
if (!targetBlock.isLiquid()) {
return false;
- }
+ }*/
+
+ if(lastFishingBoundingBox == null)
+ lastFishingBoundingBox = makeBoundingBox(centerOfCastVector);
long currentTime = System.currentTimeMillis();
boolean hasFished = (currentTime < fishingTimestamp + (FISHING_COOLDOWN_SECONDS * 10));
@@ -71,13 +76,21 @@ public class FishingManager extends SkillManager {
if(hasFished)
fishingTimestamp = currentTime;
- boolean sameTarget = (lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(boundingBox));
+ BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector);
- lastFishingBoundingBox = boundingBox;
+ boolean sameTarget = lastFishingBoundingBox.overlaps(newCastBoundingBox);
+
+ //If the new bounding box does not intersect with the old one, then update our bounding box reference
+ if(!sameTarget)
+ lastFishingBoundingBox = newCastBoundingBox;
return hasFished || sameTarget;
}
+ public static BoundingBox makeBoundingBox(Vector centerOfCastVector) {
+ return BoundingBox.of(centerOfCastVector, 2, 2, 2);
+ }
+
public void setFishingTarget() {
getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
}