Fix NPE when a furnace belonging to a player that has logged out keeps

burning.
This commit is contained in:
GJ 2013-01-24 15:35:01 -05:00
parent 76a987e1e0
commit 8736aae2ef

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.listeners;
import org.bukkit.block.Block;
import org.bukkit.block.Furnace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -72,10 +73,14 @@ public class InventoryListener implements Listener{
ItemStack smelting = inventory.getSmelting();
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
SmeltingManager smeltingManager = new SmeltingManager(plugin.getFurnacePlayer(furnaceBlock));
Player player = plugin.getFurnacePlayer(furnaceBlock);
if (player != null) {
SmeltingManager smeltingManager = new SmeltingManager(player);
smeltingManager.fuelEfficiency(event);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
@ -84,10 +89,14 @@ public class InventoryListener implements Listener{
ItemStack smelting = inventory.getSmelting();
if (plugin.furnaceIsTracked(furnaceBlock) && smelting != null && ItemChecks.isSmeltable(smelting)) {
SmeltingManager smeltingManager = new SmeltingManager(plugin.getFurnacePlayer(furnaceBlock));
Player player = plugin.getFurnacePlayer(furnaceBlock);
if (player != null) {
SmeltingManager smeltingManager = new SmeltingManager(player);
smeltingManager.smeltProcessing(event);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {