Java Code Examples for org.bukkit.event.inventory.InventoryType#BREWING
The following examples show how to use
org.bukkit.event.inventory.InventoryType#BREWING .
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: PlayerListener.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onInventoryOpen(InventoryOpenEvent event) { if (event.isCancelled() || !(event.getPlayer() instanceof Player)) { return; } Player player = (Player) event.getPlayer(); if (Main.isPlayerInGame(player)) { GamePlayer gProfile = Main.getPlayerGameProfile(player); if (gProfile.getGame().getStatus() == GameStatus.RUNNING) { if (gProfile.isSpectator) { // TODO spectator compass exclude event.setCancelled(true); return; } if (event.getInventory().getType() == InventoryType.ENCHANTING || event.getInventory().getType() == InventoryType.CRAFTING || event.getInventory().getType() == InventoryType.ANVIL || event.getInventory().getType() == InventoryType.BREWING || event.getInventory().getType() == InventoryType.FURNACE || event.getInventory().getType() == InventoryType.WORKBENCH) { if (!gProfile.getGame().getOriginalOrInheritedCrafting()) { event.setCancelled(true); } } } } }
Example 2
Source File: PlayerListener.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onInventoryOpen(InventoryOpenEvent event) { if (event.isCancelled() || !(event.getPlayer() instanceof Player)) { return; } Player player = (Player) event.getPlayer(); if (Main.isPlayerInGame(player)) { GamePlayer gProfile = Main.getPlayerGameProfile(player); if (gProfile.getGame().getStatus() == GameStatus.RUNNING) { if (gProfile.isSpectator) { // TODO spectator compass exclude event.setCancelled(true); return; } if (event.getInventory().getType() == InventoryType.ENCHANTING || event.getInventory().getType() == InventoryType.CRAFTING || event.getInventory().getType() == InventoryType.ANVIL || event.getInventory().getType() == InventoryType.BREWING || event.getInventory().getType() == InventoryType.FURNACE || event.getInventory().getType() == InventoryType.WORKBENCH) { if (!gProfile.getGame().getOriginalOrInheritedCrafting()) { event.setCancelled(true); } } } } }
Example 3
Source File: CraftInventory.java From Kettle with GNU General Public License v3.0 | 5 votes |
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 4
Source File: CraftInventory.java From Thermos with GNU General Public License v3.0 | 5 votes |
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: PotionFuelsListener.java From UHC with MIT License | 5 votes |
@EventHandler(ignoreCancelled = true) public void on(InventoryMoveItemEvent event) { if (event.getDestination().getType() != InventoryType.BREWING) return; if (disabled.contains(event.getItem().getType())) { event.setCancelled(true); } }
Example 6
Source File: PotionFuelsListener.java From UHC with MIT License | 5 votes |
@EventHandler(ignoreCancelled = true) public void on(InventoryDragEvent event) { if (event.getInventory().getType() != InventoryType.BREWING) return; // if it's not a disabled type do nothing if (!disabled.contains(event.getOldCursor().getType())) return; // check if they dragged over the ingredient if (event.getRawSlots().contains(INGREDIENT_SLOT_ID)) { event.getWhoClicked().sendMessage(messages.get(event.getOldCursor().getType())); event.setCancelled(true); } }
Example 7
Source File: BrewObjective.java From BetonQuest with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onIngredientPut(InventoryClickEvent event) { if (event.getInventory().getType() != InventoryType.BREWING) return; if (event.getRawSlot() == 3 || event.getClick().equals(ClickType.SHIFT_LEFT)) { String playerID = PlayerConverter.getID((Player) event.getWhoClicked()); if (!containsPlayer(playerID)) return; locations.put(((BrewingStand) event.getInventory().getHolder()).getLocation(), playerID); } }
Example 8
Source File: VanillaMachinesListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onPreBrew(InventoryClickEvent e) { Inventory inventory = e.getInventory(); if (inventory.getType() == InventoryType.BREWING && e.getRawSlot() < inventory.getSize() && inventory.getHolder() instanceof BrewingStand) { e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCursor()))); } }
Example 9
Source File: TrMenuNmsModern.java From TrMenu with MIT License | 4 votes |
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 10
Source File: PlayerListener.java From BedwarsRel with GNU General Public License v3.0 | 4 votes |
@EventHandler public void openInventory(InventoryOpenEvent ioe) { if (!(ioe.getPlayer() instanceof Player)) { return; } Player player = (Player) ioe.getPlayer(); Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player); if (game == null) { return; } if (game.getState() != GameState.RUNNING) { return; } if (ioe.getInventory().getType() == InventoryType.ENCHANTING || ioe.getInventory().getType() == InventoryType.BREWING || (ioe.getInventory().getType() == InventoryType.CRAFTING && !BedwarsRel.getInstance().getBooleanConfig("allow-crafting", false))) { ioe.setCancelled(true); return; } else if (ioe.getInventory().getType() == InventoryType.CRAFTING && BedwarsRel.getInstance().getBooleanConfig("allow-crafting", false)) { return; } if (game.isSpectator(player)) { if (ioe.getInventory().getName().equals(BedwarsRel._l(player, "ingame.spectator"))) { return; } ioe.setCancelled(true); } if (ioe.getInventory().getHolder() == null) { return; } if (game.getRegion().getInventories().contains(ioe.getInventory())) { return; } game.getRegion().addInventory(ioe.getInventory()); }
Example 11
Source File: PotionFuelsListener.java From UHC with MIT License | 4 votes |
@EventHandler(ignoreCancelled = true) public void on(InventoryClickEvent event) { if (event.getInventory().getType() != InventoryType.BREWING) return; // quick exit if (disabled.size() == 0) return; // clicked outside of the window if (event.getClickedInventory() == null) return; final InventoryType clicked = event.getClickedInventory().getType(); // get any relevant stack to check the type of based on the action took Optional<ItemStack> relevant = Optional.absent(); switch (event.getAction()) { case MOVE_TO_OTHER_INVENTORY: // only worry about player -> stand if (clicked == InventoryType.PLAYER) { relevant = Optional.fromNullable(event.getCurrentItem()); } break; case PLACE_ALL: case PLACE_SOME: case PLACE_ONE: case SWAP_WITH_CURSOR: // only worry about within a stand if (clicked == InventoryType.BREWING) { relevant = Optional.fromNullable(event.getCursor()); } break; case HOTBAR_SWAP: // only worry about within a stand if (clicked == InventoryType.BREWING) { relevant = Optional.fromNullable( event.getWhoClicked().getInventory().getItem(event.getHotbarButton()) ); } break; default: } if (relevant.isPresent() && disabled.contains(relevant.get().getType())) { event.getWhoClicked().sendMessage(messages.get(relevant.get().getType())); event.setCancelled(true); } }