Fix fishing exploit toggle

This commit is contained in:
nossr50 2019-03-18 09:19:38 -07:00
parent 7d2e76e464
commit 7c0469dce1

View File

@ -326,13 +326,20 @@ public class PlayerListener implements Listener {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
//Track the hook //Track the hook
if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) if(mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits())
{ {
if(event.getHook().getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() == 0) if(event.getHook().getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() == 0)
{ {
fishingManager.setFishHookReference(event.getHook()); fishingManager.setFishHookReference(event.getHook());
} }
//Spam Fishing
if(event.getState() == PlayerFishEvent.State.CAUGHT_FISH && fishingManager.isFishingTooOften())
{
event.setExpToDrop(0);
fishingManager.setFishHookReference(event.getHook());
}
//Spam Fishing //Spam Fishing
if(event.getState() == PlayerFishEvent.State.CAUGHT_FISH && fishingManager.isFishingTooOften()) if(event.getState() == PlayerFishEvent.State.CAUGHT_FISH && fishingManager.isFishingTooOften())
{ {
@ -348,6 +355,7 @@ public class PlayerListener implements Listener {
} }
} }
switch (event.getState()) { switch (event.getState()) {
case FISHING: case FISHING:
if (fishingManager.canMasterAngler()) { if (fishingManager.canMasterAngler()) {
@ -356,7 +364,7 @@ public class PlayerListener implements Listener {
} }
return; return;
case CAUGHT_FISH: case CAUGHT_FISH:
if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) if(mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits())
{ {
if(fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) if(fishingManager.isExploitingFishing(event.getHook().getLocation().toVector()))
{ {
@ -655,9 +663,9 @@ public class PlayerListener implements Listener {
ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack heldItem = player.getInventory().getItemInMainHand();
//Spam Fishing Detection //Spam Fishing Detection
if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) if(mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits())
{ {
if(heldItem.getType() == Material.FISHING_ROD || player.getInventory().getItemInOffHand().getType() == Material.FISHING_ROD) if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)
{ {
if(player.isInsideVehicle() && (player.getVehicle() instanceof Minecart || player.getVehicle() instanceof PoweredMinecart)) if(player.isInsideVehicle() && (player.getVehicle() instanceof Minecart || player.getVehicle() instanceof PoweredMinecart))
{ {
@ -669,6 +677,7 @@ public class PlayerListener implements Listener {
} }
} }
switch (event.getAction()) { switch (event.getAction()) {
case RIGHT_CLICK_BLOCK: case RIGHT_CLICK_BLOCK:
if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) { if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {