mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
Fixed fishing exploiting compatibility
This commit is contained in:
parent
965540dfaf
commit
c4f890d00e
@ -450,6 +450,9 @@ public class PlayerListener implements Listener {
|
|||||||
case CAUGHT_FISH:
|
case CAUGHT_FISH:
|
||||||
if(caught instanceof Item) {
|
if(caught instanceof Item) {
|
||||||
if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) {
|
if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) {
|
||||||
|
|
||||||
|
fishingManager.processExploiting(event.getHook().getLocation().toVector());
|
||||||
|
|
||||||
if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) {
|
if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) {
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
|
player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
|
||||||
event.setExpToDrop(0);
|
event.setExpToDrop(0);
|
||||||
|
@ -125,6 +125,20 @@ public class FishingManager extends SkillManager {
|
|||||||
return hasFished;
|
return hasFished;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void processExploiting(Vector centerOfCastVector) {
|
||||||
|
BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector);
|
||||||
|
boolean sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox);
|
||||||
|
|
||||||
|
if (sameTarget)
|
||||||
|
fishCaughtCounter++;
|
||||||
|
else
|
||||||
|
fishCaughtCounter = 1;
|
||||||
|
|
||||||
|
if (fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit()) {
|
||||||
|
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isExploitingFishing(Vector centerOfCastVector) {
|
public boolean isExploitingFishing(Vector centerOfCastVector) {
|
||||||
|
|
||||||
/*Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
|
/*Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
|
||||||
@ -134,22 +148,10 @@ public class FishingManager extends SkillManager {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector);
|
BoundingBox newCastBoundingBox = makeBoundingBox(centerOfCastVector);
|
||||||
|
|
||||||
boolean sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox);
|
boolean sameTarget = lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(newCastBoundingBox);
|
||||||
|
|
||||||
if(sameTarget)
|
|
||||||
fishCaughtCounter++;
|
|
||||||
else
|
|
||||||
fishCaughtCounter = 1;
|
|
||||||
|
|
||||||
if(fishCaughtCounter + 1 == ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit())
|
|
||||||
{
|
|
||||||
getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", ExperienceConfig.getInstance().getFishingExploitingOptionMoveRange()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//If the new bounding box does not intersect with the old one, then update our bounding box reference
|
//If the new bounding box does not intersect with the old one, then update our bounding box reference
|
||||||
if(!sameTarget)
|
if (!sameTarget) lastFishingBoundingBox = newCastBoundingBox;
|
||||||
lastFishingBoundingBox = newCastBoundingBox;
|
|
||||||
|
|
||||||
return sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit();
|
return sameTarget && fishCaughtCounter >= ExperienceConfig.getInstance().getFishingExploitingOptionOverFishLimit();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user