mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-03 18:43:43 +01:00 
			
		
		
		
	Clean up our inventory event handling.
This commit is contained in:
		@@ -9,19 +9,12 @@ import org.bukkit.Chunk;
 | 
			
		||||
import org.bukkit.Location;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.OfflinePlayer;
 | 
			
		||||
import org.bukkit.block.Block;
 | 
			
		||||
import org.bukkit.block.BlockState;
 | 
			
		||||
import org.bukkit.block.Furnace;
 | 
			
		||||
import org.bukkit.entity.Entity;
 | 
			
		||||
import org.bukkit.entity.HumanEntity;
 | 
			
		||||
import org.bukkit.entity.Item;
 | 
			
		||||
import org.bukkit.entity.NPC;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.event.inventory.InventoryEvent;
 | 
			
		||||
import org.bukkit.inventory.FurnaceInventory;
 | 
			
		||||
import org.bukkit.inventory.Inventory;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
import org.bukkit.metadata.MetadataValue;
 | 
			
		||||
 | 
			
		||||
import com.gmail.nossr50.mcMMO;
 | 
			
		||||
import com.gmail.nossr50.config.Config;
 | 
			
		||||
@@ -219,52 +212,6 @@ public final class Misc {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Block processInventoryOpenorCloseEvent(InventoryEvent event) {
 | 
			
		||||
        Inventory inventory = event.getInventory();
 | 
			
		||||
 | 
			
		||||
        if (!(inventory instanceof FurnaceInventory)) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Furnace furnace = (Furnace) inventory.getHolder();
 | 
			
		||||
 | 
			
		||||
        if (furnace == null || furnace.getBurnTime() != 0) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return furnace.getBlock();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Player getPlayerFromFurnace(Block furnaceBlock) {
 | 
			
		||||
        List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
 | 
			
		||||
 | 
			
		||||
        if (metadata.isEmpty()) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return mcMMO.p.getServer().getPlayerExact(metadata.get(0).asString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static ItemStack getSmeltingFromFurnace(Block furnaceBlock) {
 | 
			
		||||
        BlockState furnaceState = furnaceBlock.getState();
 | 
			
		||||
 | 
			
		||||
        if (!(furnaceState instanceof Furnace)) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return ((Furnace) furnaceState).getInventory().getSmelting();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static ItemStack getResultFromFurnace(Block furnaceBlock) {
 | 
			
		||||
        BlockState furnaceState = furnaceBlock.getState();
 | 
			
		||||
 | 
			
		||||
        if (!(furnaceState instanceof Furnace)) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return ((Furnace) furnaceState).getInventory().getResult();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Attempts to match any player names with the given name, and returns a list of all possibly matches.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user