mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Improve Fishing AFK detection
This commit is contained in:
parent
2f0a58b968
commit
e3d2526939
@ -7,6 +7,10 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- 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
|
Version 2.1.18
|
||||||
You will need to add Kelp to your experience.yml file for this fix to be fully functional
|
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
|
Breaking Kelp will now properly count its XP
|
||||||
|
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>2.1.18</version>
|
<version>2.1.19-SNAPSHOT</version>
|
||||||
<name>mcMMO</name>
|
<name>mcMMO</name>
|
||||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||||
<scm>
|
<scm>
|
||||||
|
@ -29,6 +29,7 @@ import com.gmail.nossr50.util.sounds.SoundManager;
|
|||||||
import com.gmail.nossr50.util.sounds.SoundType;
|
import com.gmail.nossr50.util.sounds.SoundType;
|
||||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -331,21 +332,18 @@ public class PlayerListener implements Listener {
|
|||||||
fishingManager.setFishingTarget();
|
fishingManager.setFishingTarget();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case CAUGHT_FISH:
|
case CAUGHT_FISH:
|
||||||
if(fishingManager.exploitPrevention(event.getHook().getBoundingBox()))
|
if(fishingManager.exploitPrevention(event.getHook().getLocation().toVector()))
|
||||||
return;
|
return;
|
||||||
fishingManager.handleFishing((Item) caught);
|
fishingManager.handleFishing((Item) caught);
|
||||||
fishingManager.setFishingTarget();
|
fishingManager.setFishingTarget();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case CAUGHT_ENTITY:
|
case CAUGHT_ENTITY:
|
||||||
if (fishingManager.canShake(caught)) {
|
if (fishingManager.canShake(caught)) {
|
||||||
fishingManager.shakeCheck((LivingEntity) caught);
|
fishingManager.shakeCheck((LivingEntity) caught);
|
||||||
fishingManager.setFishingTarget();
|
fishingManager.setFishingTarget();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import com.gmail.nossr50.util.random.RandomChanceUtil;
|
|||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -34,6 +35,7 @@ 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 org.bukkit.util.BoundingBox;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.*;
|
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);
|
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()) {
|
if (!targetBlock.isLiquid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
if(lastFishingBoundingBox == null)
|
||||||
|
lastFishingBoundingBox = makeBoundingBox(centerOfCastVector);
|
||||||
|
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
boolean hasFished = (currentTime < fishingTimestamp + (FISHING_COOLDOWN_SECONDS * 10));
|
boolean hasFished = (currentTime < fishingTimestamp + (FISHING_COOLDOWN_SECONDS * 10));
|
||||||
@ -71,13 +76,21 @@ public class FishingManager extends SkillManager {
|
|||||||
if(hasFished)
|
if(hasFished)
|
||||||
fishingTimestamp = currentTime;
|
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;
|
return hasFished || sameTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BoundingBox makeBoundingBox(Vector centerOfCastVector) {
|
||||||
|
return BoundingBox.of(centerOfCastVector, 2, 2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
public void setFishingTarget() {
|
public void setFishingTarget() {
|
||||||
getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
|
getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user