Merge pull request #4162 from broccolai/master

Check to make sure correct item is being damaged in Fishing exploit prevention
This commit is contained in:
Robert Alan Chapton 2020-04-16 12:03:48 -07:00 committed by GitHub
commit f82ad99c82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)