From 4a5bcaa92d8b26dae7f82df401575351530554bc Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 16 Apr 2020 05:44:26 +0100 Subject: [PATCH] Fix fishing exploit prevention --- .../com/gmail/nossr50/skills/fishing/FishingManager.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index de591a60c..add636f12 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -78,8 +78,15 @@ public class FishingManager extends SkillManager { if(currentTime < fishingRodCastTimestamp + FISHING_ROD_CAST_CD_MILLISECONDS) { + ItemStack fishingRod = getPlayer().getInventory().getItemInMainHand(); + + //Ensure correct hand item is damaged + if(fishingRod.getType() != Material.FISHING_ROD) { + fishingRod = getPlayer().getInventory().getItemInOffHand(); + } + getPlayer().setFoodLevel(Math.max(getPlayer().getFoodLevel() - 1, 0)); - getPlayer().getInventory().getItemInMainHand().setDurability((short) (getPlayer().getInventory().getItemInMainHand().getDurability() + 5)); + fishingRod.setDurability((short) (fishingRod.getDurability() + 5)); getPlayer().updateInventory(); if(lastWarnedExhaust + (1000 * 1) < currentTime)