Java Code Examples for org.bukkit.event.inventory.InventoryType#DISPENSER

The following examples show how to use org.bukkit.event.inventory.InventoryType#DISPENSER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StoreListener.java    From skRayFall with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Remove the store/unstore event possibility when an inventory is closed.
 *
 * @param evt The InventoryCloseEvent used to remove the possibility of a store/unstore
 *            event
 */
@EventHandler
public void onClose(InventoryCloseEvent evt) {
    if (evt.getView().getBottomInventory().getType() == InventoryType.PLAYER
            && (evt.getView().getTopInventory().getType() == InventoryType.CHEST
            || evt.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST
            || evt.getView().getTopInventory().getType() == InventoryType.HOPPER
            || evt.getView().getTopInventory().getType() == InventoryType.DISPENSER
            || evt.getView().getTopInventory().getType() == InventoryType.DROPPER)) {
        if (storePossible.contains(evt.getPlayer())) {
            storePossible.remove(evt.getPlayer());
        } else if (unstorePossible.contains(evt.getPlayer())) {
            unstorePossible.remove(evt.getPlayer());
        }
    }
}
 
Example 2
Source File: CraftInventory.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public InventoryType getType() {
    // Thanks to Droppers extending Dispensers, order is important.
    if (inventory instanceof InventoryCrafting) {
        return inventory.getSizeInventory() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING;
    } else if (inventory instanceof InventoryPlayer) {
        return InventoryType.PLAYER;
    } else if (inventory instanceof TileEntityDropper) {
        return InventoryType.DROPPER;
    } else if (inventory instanceof TileEntityDispenser) {
        return InventoryType.DISPENSER;
    } else if (inventory instanceof TileEntityFurnace) {
        return InventoryType.FURNACE;
    } else if (this instanceof CraftInventoryEnchanting) {
        return InventoryType.ENCHANTING;
    } else if (inventory instanceof TileEntityBrewingStand) {
        return InventoryType.BREWING;
    } else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) {
        return ((CraftInventoryCustom.MinecraftInventory) inventory).getType();
    } else if (inventory instanceof InventoryEnderChest) {
        return InventoryType.ENDER_CHEST;
    } else if (inventory instanceof InventoryMerchant) {
        return InventoryType.MERCHANT;
    } else if (inventory instanceof TileEntityBeacon) {
        return InventoryType.BEACON;
    } else if (this instanceof CraftInventoryAnvil) {
        return InventoryType.ANVIL;
    } else if (inventory instanceof IHopper) {
        return InventoryType.HOPPER;
    } else if (inventory instanceof TileEntityShulkerBox) {
        return InventoryType.SHULKER_BOX;
    } else {
        return InventoryType.CHEST;
    }
}
 
Example 3
Source File: QAListener.java    From QualityArmory with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onHopper(InventoryMoveItemEvent e) {
	if (e.isCancelled())
		return;
	if (e.getSource().getType() == InventoryType.HOPPER || e.getSource().getType() == InventoryType.DISPENSER
			|| e.getSource().getType() == InventoryType.DROPPER)
		if (QualityArmory.isGun(e.getItem()))
			e.setCancelled(true);
}
 
Example 4
Source File: CraftInventory.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public InventoryType getType() {
    // Thanks to Droppers extending Dispensers, order is important.
    if (inventory instanceof net.minecraft.inventory.InventoryCrafting) {
        return inventory.getSizeInventory() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING;
    } else if (inventory instanceof net.minecraft.entity.player.InventoryPlayer) {
        return InventoryType.PLAYER;
    } else if (inventory instanceof net.minecraft.tileentity.TileEntityDropper) {
        return InventoryType.DROPPER;
    } else if (inventory instanceof net.minecraft.tileentity.TileEntityDispenser) {
        return InventoryType.DISPENSER;
    } else if (inventory instanceof net.minecraft.tileentity.TileEntityFurnace) {
        return InventoryType.FURNACE;
    } else if (inventory instanceof net.minecraft.inventory.ContainerEnchantTableInventory) {
        return InventoryType.ENCHANTING;
    } else if (inventory instanceof net.minecraft.tileentity.TileEntityBrewingStand) {
        return InventoryType.BREWING;
    } else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) {
        return ((CraftInventoryCustom.MinecraftInventory) inventory).getType();
    } else if (inventory instanceof net.minecraft.inventory.InventoryEnderChest) {
        return InventoryType.ENDER_CHEST;
    } else if (inventory instanceof net.minecraft.inventory.InventoryMerchant) {
        return InventoryType.MERCHANT;
    } else if (inventory instanceof net.minecraft.tileentity.TileEntityBeacon) {
        return InventoryType.BEACON;
    } else if (inventory instanceof net.minecraft.inventory.ContainerRepairInventory) {
        return InventoryType.ANVIL;
    } else if (inventory instanceof net.minecraft.tileentity.IHopper) {
        return InventoryType.HOPPER;
    } else {
        return InventoryType.CHEST;
    }
}
 
Example 5
Source File: TrMenuNmsModern.java    From TrMenu with MIT License 4 votes vote down vote up
private Containers<?> getByInventory(Inventory inventory) {
    InventoryType type = inventory.getType();
    int size = inventory.getSize();
    if (type == InventoryType.CHEST) {
        if (size == 9) {
            return Containers.GENERIC_9X1;
        } else if (size == 18) {
            return Containers.GENERIC_9X2;
        } else if (size == 27) {
            return Containers.GENERIC_9X3;
        } else if (size == 36) {
            return Containers.GENERIC_9X4;
        } else if (size == 45) {
            return Containers.GENERIC_9X5;
        } else {
            return Containers.GENERIC_9X6;
        }
    } else if (type == InventoryType.DROPPER || type == InventoryType.DISPENSER) {
        return Containers.GENERIC_3X3;
    } else if (type == InventoryType.BARREL || type == InventoryType.ENDER_CHEST) {
        return Containers.GENERIC_9X3;
    } else if (type == InventoryType.CRAFTING || type == InventoryType.WORKBENCH) {
        return Containers.CRAFTING;
    } else if (type == InventoryType.HOPPER) {
        return Containers.HOPPER;
    } else if (type == InventoryType.LOOM) {
        return Containers.LOOM;
    } else if (type == InventoryType.ANVIL) {
        return Containers.ANVIL;
    } else if (type == InventoryType.BEACON) {
        return Containers.BEACON;
    } else if (type == InventoryType.SMOKER) {
        return Containers.SMOKER;
    } else if (type == InventoryType.BREWING) {
        return Containers.BREWING_STAND;
    } else if (type == InventoryType.FURNACE) {
        return Containers.FURNACE;
    } else if (type == InventoryType.LECTERN) {
        return Containers.LECTERN;
    } else if (type == InventoryType.MERCHANT) {
        return Containers.MERCHANT;
    } else if (type == InventoryType.ENCHANTING) {
        return Containers.ENCHANTMENT;
    } else if (type == InventoryType.GRINDSTONE) {
        return Containers.GRINDSTONE;
    } else if (type == InventoryType.CARTOGRAPHY) {
        return Containers.CARTOGRAPHY_TABLE;
    } else if (type == InventoryType.SHULKER_BOX) {
        return Containers.SHULKER_BOX;
    } else if (type == InventoryType.STONECUTTER) {
        return Containers.STONECUTTER;
    } else if (type == InventoryType.BLAST_FURNACE) {
        return Containers.BLAST_FURNACE;
    } else {
        return Containers.GENERIC_3X3;
    }
}
 
Example 6
Source File: StoreListener.java    From skRayFall with GNU General Public License v3.0 4 votes vote down vote up
/**
 * See if a store/unstore event is possible through items being moved into an inventory. Then
 * Storing the value in a array list while the inventory is open.
 *
 * @param evt The InventoryClickEvent used to check item movement
 */
@EventHandler
public void onStoringFilter(InventoryClickEvent evt) {
    if (evt.getAction() == InventoryAction.SWAP_WITH_CURSOR
            || evt.getAction() == InventoryAction.COLLECT_TO_CURSOR
            || evt.getAction() == InventoryAction.PICKUP_SOME
            || evt.getAction() == InventoryAction.PICKUP_HALF
            || evt.getAction() == InventoryAction.PICKUP_ALL
            || evt.getAction() == InventoryAction.PICKUP_ONE) {
        if (evt.getClickedInventory().getType() != null
                && evt.getView().getBottomInventory().getType() == InventoryType.PLAYER
                && (evt.getView().getTopInventory().getType() == InventoryType.CHEST
                || evt.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST
                || evt.getView().getTopInventory().getType() == InventoryType.HOPPER
                || evt.getView().getTopInventory().getType() == InventoryType.DISPENSER
                || evt.getView().getTopInventory().getType() == InventoryType.DROPPER)
                && evt.getClickedInventory().getType() == InventoryType.PLAYER
                && (!(storePossible.contains(evt.getWhoClicked())))) {
            storePossible.add((Player) evt.getWhoClicked());
            if (unstorePossible.contains(evt.getWhoClicked())) {
                unstorePossible.remove(evt.getWhoClicked());
            }
        }
        if (evt.getClickedInventory().getType() != null
                && evt.getView().getBottomInventory().getType() == InventoryType.PLAYER
                && (evt.getView().getTopInventory().getType() == InventoryType.CHEST
                || evt.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST
                || evt.getView().getTopInventory().getType() == InventoryType.HOPPER
                || evt.getView().getTopInventory().getType() == InventoryType.DISPENSER
                || evt.getView().getTopInventory().getType() == InventoryType.DROPPER)
                && (evt.getClickedInventory().getType() == InventoryType.CHEST
                || evt.getClickedInventory().getType() == InventoryType.ENDER_CHEST
                || evt.getClickedInventory().getType() == InventoryType.HOPPER
                || evt.getClickedInventory().getType() == InventoryType.DISPENSER
                || evt.getClickedInventory().getType() == InventoryType.DROPPER)
                && (!(unstorePossible.contains(evt.getWhoClicked())))) {
            unstorePossible.add((Player) evt.getWhoClicked());
            if (storePossible.contains(evt.getWhoClicked())) {
                storePossible.remove(evt.getWhoClicked());
            }
        }
    }
}