From 8c7fd7b1a6498c201304c90d1bdad7e0bb9a48d7 Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 1 Feb 2013 08:03:03 -0500 Subject: [PATCH] Fix issue where the vanilla XP boost for smelting would be called regardless of who took the item out of the furnace. Not only does this fix the exploit, it also fixes an NPE that could occur if the player who lit the furnance was offline when someone else extracted the items from it. --- .../com/gmail/nossr50/listeners/InventoryListener.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 11bdbcf88..f1e1f6ee7 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -17,6 +17,7 @@ import org.bukkit.inventory.FurnaceInventory; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Users; @@ -118,8 +119,12 @@ public class InventoryListener implements Listener{ ItemStack result = inventory.getResult(); if (plugin.furnaceIsTracked(furnaceBlock) && result != null && ItemChecks.isSmelted(result)) { - SmeltingManager smeltingManager = new SmeltingManager(Users.getPlayer(plugin.getFurnacePlayer(furnaceBlock))); - smeltingManager.vanillaXPBoost(event); + McMMOPlayer mcMMOPlayer = Users.getPlayer(plugin.getFurnacePlayer(furnaceBlock)); + + if (event.getPlayer().equals(mcMMOPlayer.getPlayer())) { + SmeltingManager smeltingManager = new SmeltingManager(mcMMOPlayer); + smeltingManager.vanillaXPBoost(event); + } } } }