From eba6820ec6ab3de2314c3881760eab9f56758bd6 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 18 Apr 2013 07:49:55 -0400 Subject: [PATCH] Clean this up a bit. --- .../nossr50/listeners/InventoryListener.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 9e1f1555b..c9929d4bb 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -163,26 +163,18 @@ public class InventoryListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCraftItem(CraftItemEvent event) { - if (event.getRecipe().getResult() == null) { - return; - } - else if (!ItemUtils.isMcMMOItem(event.getRecipe().getResult())) { - return; - } - else if (event.getWhoClicked() == null) { - return; - } - else if (!(event.getWhoClicked() instanceof Player)) { + ItemStack result = event.getRecipe().getResult(); + final HumanEntity whoClicked = event.getWhoClicked(); + + if (!ItemUtils.isMcMMOItem(result) || Misc.isNPCEntity(whoClicked) || !(whoClicked instanceof Player)) { return; } - final Player player = (Player) event.getWhoClicked(); - - mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() { + mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() { @Override public void run() { - player.updateInventory(); + ((Player) whoClicked).updateInventory(); } - }); + }, 0); } }