mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 02:04:44 +02:00
Added an option to turn off fishing exploit detection as a band-aid fix until the config update is done
This commit is contained in:
@ -144,6 +144,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
/* EXPLOIT TOGGLES */
|
||||
public boolean isEndermanEndermiteFarmingPrevented() { return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true); }
|
||||
|
||||
public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
|
||||
/* Curve settings */
|
||||
public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
|
||||
public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }
|
||||
|
@ -324,23 +324,26 @@ public class PlayerListener implements Listener {
|
||||
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
|
||||
|
||||
//Track the hook
|
||||
if(event.getHook().getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() == 0)
|
||||
if(ExperienceConfig.getInstance().isFishingExploitingPrevented())
|
||||
{
|
||||
fishingManager.setFishHookReference(event.getHook());
|
||||
}
|
||||
|
||||
//Spam Fishing
|
||||
if(event.getState() == PlayerFishEvent.State.CAUGHT_FISH && fishingManager.isFishingTooOften())
|
||||
{
|
||||
event.setExpToDrop(0);
|
||||
|
||||
if(caught instanceof Item)
|
||||
if(event.getHook().getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() == 0)
|
||||
{
|
||||
Item caughtItem = (Item) caught;
|
||||
caughtItem.remove();
|
||||
fishingManager.setFishHookReference(event.getHook());
|
||||
}
|
||||
|
||||
return;
|
||||
//Spam Fishing
|
||||
if(event.getState() == PlayerFishEvent.State.CAUGHT_FISH && fishingManager.isFishingTooOften())
|
||||
{
|
||||
event.setExpToDrop(0);
|
||||
|
||||
if(caught instanceof Item)
|
||||
{
|
||||
Item caughtItem = (Item) caught;
|
||||
caughtItem.remove();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (event.getState()) {
|
||||
@ -351,12 +354,16 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
return;
|
||||
case CAUGHT_FISH:
|
||||
if(fishingManager.isExploitingFishing(event.getHook().getLocation().toVector()))
|
||||
if(ExperienceConfig.getInstance().isFishingExploitingPrevented())
|
||||
{
|
||||
event.setExpToDrop(0);
|
||||
Item caughtItem = (Item) caught;
|
||||
caughtItem.remove();
|
||||
return;
|
||||
if(fishingManager.isExploitingFishing(event.getHook().getLocation().toVector()))
|
||||
{
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Scarcity"));
|
||||
event.setExpToDrop(0);
|
||||
Item caughtItem = (Item) caught;
|
||||
caughtItem.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fishingManager.handleFishing((Item) caught);
|
||||
|
@ -45,6 +45,7 @@ import java.util.*;
|
||||
|
||||
public class FishingManager extends SkillManager {
|
||||
public static final int FISHING_ROD_CAST_CD_MILLISECONDS = 200;
|
||||
public static final int OVERFISH_LIMIT = 4;
|
||||
private final long FISHING_COOLDOWN_SECONDS = 1000L;
|
||||
|
||||
private long fishingRodCastTimestamp = 0L;
|
||||
@ -55,6 +56,7 @@ public class FishingManager extends SkillManager {
|
||||
private BoundingBox lastFishingBoundingBox;
|
||||
private Item fishingCatch;
|
||||
private Location hookLocation;
|
||||
private int fishCaughtCounter = 1;
|
||||
|
||||
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, PrimarySkillType.FISHING);
|
||||
@ -131,15 +133,21 @@ public class FishingManager extends SkillManager {
|
||||
|
||||
boolean sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox);
|
||||
|
||||
if(sameTarget)
|
||||
fishCaughtCounter++;
|
||||
else
|
||||
fishCaughtCounter = 1;
|
||||
|
||||
if(fishCaughtCounter + 1 == OVERFISH_LIMIT)
|
||||
{
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResources"));
|
||||
}
|
||||
|
||||
//If the new bounding box does not intersect with the old one, then update our bounding box reference
|
||||
if(!sameTarget)
|
||||
lastFishingBoundingBox = newCastBoundingBox;
|
||||
else
|
||||
{
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Fishing.Scarcity"));
|
||||
}
|
||||
|
||||
return sameTarget;
|
||||
return sameTarget && fishCaughtCounter >= OVERFISH_LIMIT;
|
||||
}
|
||||
|
||||
public static BoundingBox makeBoundingBox(Vector centerOfCastVector) {
|
||||
|
Reference in New Issue
Block a user