Fix fishing exploit prevention

This commit is contained in:
Josh Taylor 2020-04-16 05:44:26 +01:00
parent 3a4de97c9b
commit 4a5bcaa92d
No known key found for this signature in database
GPG Key ID: C6B6E57A7A548238

View File

@ -78,8 +78,15 @@ public class FishingManager extends SkillManager {
if(currentTime < fishingRodCastTimestamp + FISHING_ROD_CAST_CD_MILLISECONDS) 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().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(); getPlayer().updateInventory();
if(lastWarnedExhaust + (1000 * 1) < currentTime) if(lastWarnedExhaust + (1000 * 1) < currentTime)