Sweet berry bush exploit fix

This commit is contained in:
nossr50
2021-03-29 16:09:47 -07:00
parent 50eadb2e8d
commit ae538d8c72
2 changed files with 23 additions and 20 deletions

View File

@ -824,30 +824,32 @@ public class PlayerListener implements Listener {
}
}
FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer()); //PlayerAnimationEvent compat
if (herbalismManager.canGreenThumbBlock(blockState)) {
//call event for Green Thumb Block
if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, block).isCancelled()) {
Bukkit.getPluginManager().callEvent(fakeSwing);
player.getInventory().getItemInMainHand().setAmount(heldItem.getAmount() - 1);
player.updateInventory();
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);
FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer()); //PlayerAnimationEvent compat
if(!event.isCancelled() || event.useInteractedBlock() != Event.Result.DENY) {
if (herbalismManager.canGreenThumbBlock(blockState)) {
//call event for Green Thumb Block
if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, block).isCancelled()) {
Bukkit.getPluginManager().callEvent(fakeSwing);
player.getInventory().getItemInMainHand().setAmount(heldItem.getAmount() - 1);
player.updateInventory();
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);
}
}
}
}
/* SHROOM THUMB CHECK */
else if (herbalismManager.canUseShroomThumb(blockState)) {
if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_SHROOM_THUMB, block).isCancelled()) {
Bukkit.getPluginManager().callEvent(fakeSwing);
event.setCancelled(true);
if (herbalismManager.processShroomThumb(blockState)
&& EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);
/* SHROOM THUMB CHECK */
else if (herbalismManager.canUseShroomThumb(blockState)) {
if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_SHROOM_THUMB, block).isCancelled()) {
Bukkit.getPluginManager().callEvent(fakeSwing);
event.setCancelled(true);
if (herbalismManager.processShroomThumb(blockState)
&& EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);
}
}
} else {
herbalismManager.processBerryBushHarvesting(blockState);
}
} else {
herbalismManager.processBerryBushHarvesting(blockState);
}
break;