From 93fefa031b22fa2fe8432959a1cd1e2ae9c0ba40 Mon Sep 17 00:00:00 2001 From: LogGits Date: Tue, 12 Feb 2019 13:26:03 +1000 Subject: [PATCH 1/2] Herbalism compatibility with PlayerAnimationEvent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../java/com/gmail/nossr50/listeners/PlayerListener.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 263b2598e..4084d4d77 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -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); From 3ed4228b7228f40dc8e7f6e25128dbce5ab94deb Mon Sep 17 00:00:00 2001 From: LogGits Date: Sat, 16 Feb 2019 05:40:49 +1000 Subject: [PATCH 2/2] Added imports --- src/main/java/com/gmail/nossr50/listeners/PlayerListener.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 4084d4d77..06f03efd7 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -29,6 +29,8 @@ import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; +import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.block.Block;