From 27854720f0e88a49c8e75f3a1d6d6627e99840b7 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 15 May 2022 15:24:25 -0700 Subject: [PATCH] Add some exploit prevention to fishing --- pom.xml | 2 +- .../gmail/nossr50/listeners/PlayerListener.java | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index f0cc4b158..ccd012f05 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.212 + 2.1.213-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index d5f7a9ffc..2eb17c405 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -428,7 +428,9 @@ public class PlayerListener implements Listener { ItemStack inHand = player.getInventory().getItemInMainHand(); //Grab lure level - if(inHand != null && inHand.getType().getKey().getKey().equalsIgnoreCase("fishing_rod")) { + if(inHand != null + && inHand.getItemMeta() != null + && inHand.getType().getKey().getKey().equalsIgnoreCase("fishing_rod")) { if(inHand.getItemMeta().hasEnchants()) { for(Enchantment enchantment : inHand.getItemMeta().getEnchants().keySet()) { if(enchantment.toString().toLowerCase().contains("lure")) { @@ -436,10 +438,14 @@ public class PlayerListener implements Listener { } } } - } - fishingManager.masterAngler(event.getHook(), lureLevel); - fishingManager.setFishingTarget(); + // Prevent any potential odd behavior by only processing if no offhand fishing rod is present + if(!player.getInventory().getItemInOffHand().getType().getKey().getKey().equalsIgnoreCase("fishing_rod")) { + // In case of offhand fishing rod, don't process anything + fishingManager.masterAngler(event.getHook(), lureLevel); + fishingManager.setFishingTarget(); + } + } } return; case CAUGHT_FISH: