Java Code Examples for org.bukkit.event.inventory.InventoryType#CHEST
The following examples show how to use
org.bukkit.event.inventory.InventoryType#CHEST .
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: SilentOpenChest.java From SuperVanish with Mozilla Public License 2.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onChestClose(InventoryCloseEvent e) { if (!(e.getPlayer() instanceof Player)) return; final Player p = (Player) e.getPlayer(); if (!playerStateInfoMap.containsKey(p)) return; if (!(p.getInventory().getType() == InventoryType.CHEST || plugin.getVersionUtil().isOneDotXOrHigher(11) && isShulkerBox(p.getInventory()))) { return; } new BukkitRunnable() { @Override public void run() { StateInfo stateInfo = playerStateInfoMap.get(p); if (stateInfo == null) return; restoreState(stateInfo, p); playerStateInfoMap.remove(p); } }.runTaskLater(plugin, 1); }
Example 2
Source File: StoreListener.java From skRayFall with GNU General Public License v3.0 | 6 votes |
/** * 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 3
Source File: CraftInventoryCustom.java From Kettle with GNU General Public License v3.0 | 5 votes |
public MinecraftInventory(InventoryHolder owner, int size, String title) { Validate.notNull(title, "Title cannot be null"); this.items = NonNullList.withSize(size, ItemStack.EMPTY); this.title = title; this.viewers = new ArrayList<HumanEntity>(); this.owner = owner; this.type = InventoryType.CHEST; }
Example 4
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 5
Source File: ClassesTest.java From Skript with GNU General Public License v3.0 | 5 votes |
@Test public void test() { final Object[] random = { // Java (byte) 127, (short) 2000, -1600000, 1L << 40, -1.5f, 13.37, "String", // Skript SkriptColor.BLACK, StructureType.RED_MUSHROOM, WeatherType.THUNDER, new Date(System.currentTimeMillis()), new Timespan(1337), new Time(12000), new Timeperiod(1000, 23000), new Experience(15), new Direction(0, Math.PI, 10), new Direction(new double[] {0, 1, 0}), new EntityType(new SimpleEntityData(HumanEntity.class), 300), new CreeperData(), new SimpleEntityData(Snowball.class), new HorseData(Variant.SKELETON_HORSE), new WolfData(), new XpOrbData(50), // Bukkit - simple classes only GameMode.ADVENTURE, InventoryType.CHEST, DamageCause.FALL, // there is also at least one variable for each class on my test server which are tested whenever the server shuts down. }; for (final Object o : random) { Classes.serialize(o); // includes a deserialisation test } }
Example 6
Source File: GuiInject.java From AACAdditionPro with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onJoin(InventoryOpenEvent event) { if (event.getView().getTitle().startsWith(AAC_GUI_TITLE) && event.getView().getType() == InventoryType.CHEST && InternalPermission.hasPermission(event.getPlayer(), InternalPermission.AAC_MANAGE)) { event.getInventory().setItem(16, AACADDITIONPRO_ITEMSTACK); } }
Example 7
Source File: CraftInventoryCustom.java From Thermos with GNU General Public License v3.0 | 5 votes |
public MinecraftInventory(InventoryHolder owner, int size, String title) { Validate.notNull(title, "Title cannot be null"); Validate.isTrue(title.length() <= 32, "Title cannot be longer than 32 characters"); this.items = new net.minecraft.item.ItemStack[size]; this.title = title; this.viewers = new ArrayList<HumanEntity>(); this.owner = owner; this.type = InventoryType.CHEST; }
Example 8
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 9
Source File: SilentOpenChest.java From SuperVanish with Mozilla Public License 2.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onMove(PlayerMoveEvent e) { Player p = e.getPlayer(); if (playerStateInfoMap.containsKey(p)) { if (!(p.getOpenInventory().getType() == InventoryType.CHEST || plugin.getVersionUtil().isOneDotXOrHigher(11) && isShulkerBox(p.getOpenInventory()))) { restoreState(playerStateInfoMap.get(p), p); playerStateInfoMap.remove(p); } } }
Example 10
Source File: BasicGUIOpener.java From CratesPlus with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onInventoryClick(InventoryClickEvent event) { String title = event.getView().getTitle(); if (title.contains(" Win") && !title.contains("Edit ")) { if (event.getInventory().getType() == InventoryType.CHEST && event.getSlot() != 22 || event.getCurrentItem() != null) { event.setCancelled(true); event.getWhoClicked().closeInventory(); } } }
Example 11
Source File: SignEvents.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onChestClosed(InventoryCloseEvent e) { if (e.getPlayer() == null || e.getPlayer().getLocation() == null || !plugin.getWorldManager().isSkyAssociatedWorld(e.getPlayer().getLocation().getWorld()) || e.getInventory().getType() != InventoryType.CHEST ) { return; } Location loc = e.getInventory().getLocation(); if (loc != null) { logic.updateSignsOnContainer(loc); } }
Example 12
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 13
Source File: StoreListener.java From skRayFall with GNU General Public License v3.0 | 4 votes |
/** * 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()); } } } }