mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Fixing the fishing AFK detection
This commit is contained in:
parent
85a04c71f4
commit
4f832edada
@ -251,9 +251,6 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
|
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
|
||||||
|
|
||||||
if(fishingManager.exploitPrevention())
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (event.getState()) {
|
switch (event.getState()) {
|
||||||
case CAUGHT_FISH:
|
case CAUGHT_FISH:
|
||||||
//TODO Update to new API once available! Waiting for case CAUGHT_TREASURE:
|
//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();
|
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
|
||||||
|
|
||||||
if(fishingManager.exploitPrevention())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Entity caught = event.getCaught();
|
Entity caught = event.getCaught();
|
||||||
|
|
||||||
switch (event.getState()) {
|
switch (event.getState()) {
|
||||||
@ -329,6 +323,8 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case CAUGHT_FISH:
|
case CAUGHT_FISH:
|
||||||
|
if(fishingManager.exploitPrevention(event.getHook().getBoundingBox()))
|
||||||
|
return;
|
||||||
fishingManager.handleFishing((Item) caught);
|
fishingManager.handleFishing((Item) caught);
|
||||||
fishingManager.setFishingTarget();
|
fishingManager.setFishingTarget();
|
||||||
return;
|
return;
|
||||||
|
@ -32,6 +32,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
import org.bukkit.util.BoundingBox;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ public class FishingManager extends SkillManager {
|
|||||||
private final long FISHING_COOLDOWN_SECONDS = 1000L;
|
private final long FISHING_COOLDOWN_SECONDS = 1000L;
|
||||||
|
|
||||||
private long fishingTimestamp = 0L;
|
private long fishingTimestamp = 0L;
|
||||||
private Location fishingTarget;
|
private BoundingBox lastFishingBoundingBox;
|
||||||
private Item fishingCatch;
|
private Item fishingCatch;
|
||||||
private Location hookLocation;
|
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);
|
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);
|
Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
|
||||||
|
|
||||||
@ -69,10 +70,9 @@ public class FishingManager extends SkillManager {
|
|||||||
if(hasFished)
|
if(hasFished)
|
||||||
fishingTimestamp = currentTime;
|
fishingTimestamp = currentTime;
|
||||||
|
|
||||||
Location targetLocation = targetBlock.getLocation();
|
boolean sameTarget = (lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(boundingBox));
|
||||||
boolean sameTarget = (fishingTarget != null && fishingTarget.equals(targetLocation));
|
|
||||||
|
|
||||||
fishingTarget = targetLocation;
|
lastFishingBoundingBox = boundingBox;
|
||||||
|
|
||||||
return hasFished || sameTarget;
|
return hasFished || sameTarget;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user