public GlowInventory(InventoryHolder holder, InventoryType type) { this(holder, type, type.getDefaultSize(), type.getDefaultTitle()); }
if (top.getType().equals(InventoryType.FURNACE)) { CraftingManager cm = ((GlowServer) ServerProvider.getServer()).getCraftingManager(); if (cm.getFurnaceRecipe(clickedItem) != null) {
@Override public MCInventoryType getType() { return MCInventoryType.valueOf(this.i.getType().name()); }
/** * Creates a minecart with a chest. * * @param location the location. */ public Storage(Location location) { super(location, MinecartType.CHEST); inventory = new GlowInventory(this, InventoryType.CHEST, InventoryType.CHEST.getDefaultSize(), "Minecart with Chest"); }
@Override public void getParameterOptions(Spell spell, String parameterKey, Collection<String> examples) { if (parameterKey.equals("type")) { for (InventoryType invType : InventoryType.values()) { examples.add(invType.name().toLowerCase()); } } else { super.getParameterOptions(spell, parameterKey, examples); } } }
@Override public void prepare(CastContext context, ConfigurationSection parameters) { super.prepare(context, parameters); String inventoryTypeString = parameters.getString("type", "ender_chest").toUpperCase(); if (inventoryTypeString.equals("ENDER")) { inventoryTypeString = "ENDER_CHEST"; } else if (inventoryTypeString.equals("INVENTORY")) { inventoryTypeString = "CRAFTING"; } else if (inventoryTypeString.equals("DISPOSAL")) { disposal = true; inventoryTypeString = "CHEST"; } // For backwards-compatibility with disposal spell if (inventoryTypeString.equals("CHEST") && parameters.getString("target", "").equals("self")) { disposal = true; } title = parameters.getString("title"); try { inventoryType = InventoryType.valueOf(inventoryTypeString); } catch (Exception ex) { context.getLogger().warning("Invalid inventory type in " + context.getSpell().getKey() + ": " + inventoryTypeString); } }
/** * Set the custom title of this inventory or reset it to the default. * * @param title The new title, or null to reset. */ public void setTitle(String title) { if (title == null) { this.title = type.getDefaultTitle(); } else { this.title = title; } }
@EventHandler public void onInventoryClose(InventoryCloseEvent event) { Player p = (Player) event.getPlayer(); UUID uuid = p.getUniqueId(); Inventory inv = event.getInventory(); if (crafters.contains(uuid) && inv.getType().equals(InventoryType.WORKBENCH)) { // remove dropped items around workbench plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> p.getNearbyEntities(6, 6, 6).forEach((e) -> { if (e instanceof Item) { e.remove(); } }), 1L); crafters.remove(uuid); } }
@Override public MCInventoryType getType() { return MCInventoryType.valueOf(this.iv.getType().name()); }
/** * Creates a minecart with a hopper. * * @param location the location */ public Hopper(Location location) { super(location, MinecartType.HOPPER); inventory = new GlowInventory(this, InventoryType.HOPPER, InventoryType.HOPPER.getDefaultSize(), "Minecart with Hopper"); }
@Override public MCInventory createInventory(MCInventoryHolder holder, MCInventoryType type, String title) { InventoryHolder ih; if(holder == null) { ih = null; } else { ih = (InventoryHolder) holder.getHandle(); } if(title == null) { return new BukkitMCInventory(Bukkit.createInventory(ih, InventoryType.valueOf(type.name()))); } return new BukkitMCInventory(Bukkit.createInventory(ih, InventoryType.valueOf(type.name()), title)); }
public GlowInventory(InventoryHolder holder, InventoryType type, int size) { this(holder, type, size, type.getDefaultTitle()); }
@EventHandler public void onInteract(final InventoryInteractEvent e) { if (GuiWindow.getWindow(e.getInventory().getTitle()) != null) { if (e.getInventory().getType().equals(InventoryType.CHEST)) { e.setResult(Event.Result.DENY); e.setCancelled(true); } } } }
public Inventory open(Player player, int page) { Optional<SmartInventory> oldInv = this.manager.getInventory(player); oldInv.ifPresent(inv -> { inv.getListeners().stream() .filter(listener -> listener.getType() == InventoryCloseEvent.class) .forEach(listener -> ((InventoryListener<InventoryCloseEvent>) listener) .accept(new InventoryCloseEvent(player.getOpenInventory()))); this.manager.setInventory(player, null); }); InventoryContents contents = new InventoryContents.Impl(this, player); contents.pagination().page(page); this.manager.setContents(player, contents); this.provider.init(player, contents); InventoryOpener opener = this.manager.findOpener(type) .orElseThrow(() -> new IllegalStateException("No opener found for the inventory type " + type.name())); Inventory handle = opener.open(this, player); this.manager.setInventory(player, this); return handle; }
@Override public Inventory createInventory(InventoryHolder owner, InventoryType type, String title) { return new GlowInventory(owner, type, type.getDefaultSize(), title); }
protected void initialize(List<GlowInventory> parents, InventoryHolder owner, InventoryType type) { initialize(parents, owner, type, type.getDefaultTitle()); }
@EventHandler(priority = EventPriority.HIGH) public void onPaperBagInteract(InventoryClickEvent event) { Inventory inv = event.getView().getBottomInventory(); if (inv.getType().equals(InventoryType.PLAYER)) { Player player = (Player) event.getWhoClicked(); if (!player.hasPermission("tardis.paper_bag")) {
if (!isChest) isChest = inventoryType.name().equals("SHULKER_BOX"); boolean clickedWand = Wand.isWand(clickedItem); boolean isContainerSlot = event.getSlot() == event.getRawSlot();
items = new ItemStack[InventoryType.DISPENSER.getDefaultSize()]; items = new ItemStack[InventoryType.HOPPER.getDefaultSize()]; items = new ItemStack[InventoryType.FURNACE.getDefaultSize()]; items = new ItemStack[InventoryType.BREWING.getDefaultSize()]; items = new ItemStack[InventoryType.CHEST.getDefaultSize()];
@Override public void saveNbt(CompoundTag tag) { super.saveNbt(tag); tag.putCompoundList("Items", NbtSerialization.writeInventory(inventory.getContents(), 0)); if (!inventory.getTitle().equals(inventory.getType().getDefaultTitle())) { tag.putString("CustomName", inventory.getTitle()); } } }