From a711d3a3e33b85675aa985e3959d128fea4d16c7 Mon Sep 17 00:00:00 2001 From: Dor Date: Fri, 18 Mar 2016 02:18:40 +0200 Subject: [PATCH] Stop duplicate messages from abilities. --- .../com/gmail/nossr50/listeners/PlayerListener.java | 5 +++-- .../nossr50/skills/herbalism/HerbalismManager.java | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 57dfdcaa9..c61b3419e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -65,6 +65,7 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.adapter.SoundAdapter; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; +import org.bukkit.inventory.EquipmentSlot; public class PlayerListener implements Listener { private final mcMMO plugin; @@ -427,7 +428,7 @@ public class PlayerListener implements Listener { public void onPlayerInteractLowest(PlayerInteractEvent event) { Player player = event.getPlayer(); - if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { + if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { return; } @@ -519,7 +520,7 @@ public class PlayerListener implements Listener { public void onPlayerInteractMonitor(PlayerInteractEvent event) { Player player = event.getPlayer(); - if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { + if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 4ab0bff76..77a945a5d 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -303,23 +303,23 @@ public class HerbalismManager extends SkillManager { private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) { Player player = getPlayer(); PlayerInventory playerInventory = player.getInventory(); - ItemStack seed = null; + Material seed = null; switch (blockState.getType()) { case CARROT: - seed = new ItemStack(Material.CARROT_ITEM); + seed = Material.CARROT_ITEM; break; case CROPS: - seed = new ItemStack(Material.SEEDS); + seed = Material.SEEDS; break; case NETHER_WARTS: - seed = new ItemStack(Material.NETHER_STALK); + seed = Material.NETHER_STALK; break; case POTATO: - seed = new ItemStack(Material.POTATO_ITEM); + seed = Material.POTATO_ITEM; break; default: @@ -338,7 +338,7 @@ public class HerbalismManager extends SkillManager { return; } - playerInventory.removeItem(seed); + playerInventory.removeItem(new ItemStack(seed)); player.updateInventory(); // Needed until replacement available new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0); }