Herbalism compatibility with PlayerAnimationEvent

This change in theory should make McMMO herbalism compatible with plugins that utilise PlayerAnimationEvent. The main reason that I want to add this is to fix `no swing` false positives in `AAC` (though didn't get to test this). 

I would appreciate if someone could test this PR and verify that its working without any issues. (I am busy for the next few days so I haven't been able to test it. In theory it looks like it should work. I could have checked if the event `isCancelled()` however, this doesn't seem necessary quite yet. Though, if it is needed I can add it 👍 

Please don't merge this unless it's confirmed completely working. I will find some time to test it out within the next few days.
This commit is contained in:
LogGits 2019-02-12 13:26:03 +10:00 committed by GitHub
parent c0a3d63213
commit 93fefa031b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -656,16 +656,17 @@ public class PlayerListener implements Listener {
}
}
FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer()); //PlayerAnimationEvent compat
if (herbalismManager.canGreenThumbBlock(blockState)) {
Bukkit.getPluginManager().callEvent(fakeSwing);
player.getInventory().setItemInMainHand(new ItemStack(Material.WHEAT_SEEDS, heldItem.getAmount() - 1));
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);
}
}
/* SHROOM THUMB CHECK */
else if (herbalismManager.canUseShroomThumb(blockState)) {
Bukkit.getPluginManager().callEvent(fakeSwing);
event.setCancelled(true);
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);