@Override public void load(GlowMinecart entity, CompoundTag tag) { super.load(entity, tag); if (entity instanceof InventoryHolder) { Inventory inventory = ((InventoryHolder) entity).getInventory(); if (inventory != null) { tag.readCompoundList("Items", items -> inventory.setContents(NbtSerialization.readInventory( items, 0, inventory.getSize()))); } } // todo }
@Override public void load(T entity, CompoundTag tag) { super.load(entity, tag); tag.readInt("XpSeed", entity::setXpSeed); tag.readInt("playerGameType", gameType -> { GlowServer server = (GlowServer) ServerProvider.getServer(); if (!server.getConfig().getBoolean(ServerConfig.Key.FORCE_GAMEMODE)) { GameMode mode = GameMode.getByValue(gameType); if (mode != null) { entity.setGameMode(mode); } } else { entity.setGameMode(server.getDefaultGameMode()); } }); tag.readInt("SelectedItemSlot", entity.getInventory()::setHeldItemSlot); // Sleeping and SleepTimer are ignored on load. tag.readCompoundList("Inventory", items -> { PlayerInventory inventory = entity.getInventory(); inventory.setStorageContents( NbtSerialization.readInventory(items, 0, inventory.getSize() - 5)); inventory.setArmorContents(NbtSerialization.readInventory(items, 100, 4)); inventory.setExtraContents(NbtSerialization.readInventory(items, -106, 1)); }); tag.readCompoundList("EnderItems", items -> { Inventory inventory = entity.getEnderChest(); inventory.setContents(NbtSerialization.readInventory(items, 0, inventory.getSize())); }); }
@Override public void setContents(ItemStack[] items) { base.setContents(items); }
@Override public void setContents(ItemStack[] items) { base.setContents(items); }
public static String toBase64(ItemStack[] is, int size) { Inventory inventory = Bukkit.createInventory(null, size); inventory.setContents(is); return toBase64(inventory, size); }
public static String toBase64(ItemStack[] is, int size) { Inventory inventory = Bukkit.createInventory(null, size); inventory.setContents(is); return toBase64(inventory); }
public static void sortInventory(Inventory inventory) { inventory.setContents(sortInventory(inventory.getContents())); } }
public void saveVault(Player player, Inventory inventory) { if (plugin.getInVault().containsKey(player.getUniqueId().toString())) { Inventory inv = Bukkit.createInventory(null, 6 * 9); inv.setContents(inventory.getContents().clone()); if (inventory.getViewers().size() == 1) { VaultViewInfo info = plugin.getInVault().get(player.getUniqueId().toString()); vaultManager.saveVault(inv, info.getVaultName(), info.getNumber()); plugin.getOpenInventories().remove(info.toString()); } plugin.getInVault().remove(player.getUniqueId().toString()); } }
private void openActivate(Player p) { ItemStack[] items = new TARDISSonicActivatorInventory(plugin).getActivator(); Inventory sgc = plugin.getServer().createInventory(p, 9, ChatColor.DARK_RED + "Sonic Activator"); sgc.setContents(items); p.openInventory(sgc); }
@Override public void setChestSize(int chestSize) { ItemStack[] contents = this.getChestInventory().getContents(); chest = Bukkit.createInventory(null, chestSize, SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fchest.Inventory-Title"))); chest.setContents(contents); }
private void list(Player player) { ResultSetTardisCompanions rs = new ResultSetTardisCompanions(plugin); if (rs.fromUUID(player.getUniqueId().toString())) { String comps = rs.getCompanions(); close(player); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { ItemStack[] items = new TARDISCompanionInventory(plugin, comps.split(":")).getSkulls(); Inventory cominv = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "Companions"); cominv.setContents(items); player.openInventory(cominv); }, 2L); } }
public void displayMenu(MinigamePlayer ply){ updateAll(); populateMenu(); Player player = ply.getPlayer(); inv = Bukkit.createInventory(player, rows*9, name); inv.setContents(pageView); ply.getPlayer().openInventory(inv); ply.setMenu(this); }
public void open(HumanEntity entity) { Inventory inv = Bukkit.createInventory(entity, this.wrap().getSize(), this.wrap().getTitle()); inv.setContents(this.wrap().getContents()); entity.openInventory(inv); }
/** * Repairs the container block by adding all the contents back in. */ public void repair() { super.repair(); // Grab the inventory InventoryHolder cb = (InventoryHolder) getWorld().getBlockAt(getX(),getY(),getZ()).getState(); Inventory chestInv = cb.getInventory(); chestInv.setContents(contents); } }
boolean doAddGUI(Player player) { if (player.hasPermission("tardis.add")) { ItemStack[] items = new TARDISCompanionAddInventory(plugin, player.getUniqueId()).getPlayers(); Inventory presetinv = plugin.getServer().createInventory(player, 54, ChatColor.DARK_RED + "Add Companion"); presetinv.setContents(items); player.openInventory(presetinv); } else { TARDISMessage.send(player, "NO_PERMS"); } return true; }
@Override public void run() { TARDISRegulatorInventory reg = new TARDISRegulatorInventory(); ItemStack[] items = reg.getRegulator(); Inventory inv = plugin.getServer().createInventory(player, 54, "Helmic Regulator"); inv.setContents(items); player.openInventory(inv); // play inflight sound if (!plugin.getTrackerKeeper().getDestinationVortex().containsKey(id)) { plugin.getServer().getScheduler().runTask(plugin, new TARDISLoopingFlightSound(plugin, player.getLocation(), id)); } } }
/** * Closes the inventory and opens the archive consoles menu. * * @param p the player using the GUI */ private void archive(Player p) { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { p.closeInventory(); ItemStack[] archive = new TARDISArchiveInventory(plugin, p).getArchives(); Inventory menu = plugin.getServer().createInventory(p, 27, ChatColor.DARK_RED + "TARDIS Archive"); menu.setContents(archive); p.openInventory(menu); }, 1L); }
/** * Goes back to the seeds menu. * * @param p the player using the GUI */ private void back(Player p) { close(p); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { ItemStack[] seeds = new TARDISSeedsInventory(p).getMenu(); Inventory gui = plugin.getServer().createInventory(p, 27, ChatColor.DARK_RED + "TARDIS Seeds Menu"); gui.setContents(seeds); p.openInventory(gui); }, 2L); }
/** * Closes the inventory and opens the Wall block selector menu. * * @param p the player using the GUI */ private void floor(Player p) { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> { p.closeInventory(); ItemStack[] wall_blocks = new TARDISWallsInventory(plugin).getMenu(); Inventory wall = plugin.getServer().createInventory(p, 54, ChatColor.DARK_RED + "TARDIS Floor Menu"); wall.setContents(wall_blocks); p.openInventory(wall); }, 1L); }
public GUIMaker(Inventory inv) { if (inv.getType() == InventoryType.CHEST) { // 自定义大小的 Inventory this.inv = Bukkit.createInventory(inv.getHolder(), inv.getSize(), inv.getTitle()); } else { // 自定义类型的 Inventory this.inv = Bukkit.createInventory(inv.getHolder(), inv.getType(), inv.getTitle()); } this.inv.setContents(inv.getContents()); }