本文整理了Java中org.bukkit.inventory.Inventory.setContents()
方法的一些代码示例,展示了Inventory.setContents()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Inventory.setContents()
方法的具体详情如下:
包路径:org.bukkit.inventory.Inventory
类名称:Inventory
方法名:setContents
[英]Completely replaces the inventory's contents. Removes all existing contents and replaces it with the ItemStacks given in the array.
[中]完全替换库存的内容。删除所有现有内容并将其替换为数组中给定的ItemStacks。
代码示例来源:origin: GlowstoneMC/Glowstone
@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
}
代码示例来源:origin: GlowstoneMC/Glowstone
@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()));
});
}
代码示例来源:origin: bergerkiller/BKCommonLib
@Override
public void setContents(ItemStack[] items) {
base.setContents(items);
}
代码示例来源:origin: bergerkiller/BKCommonLib
@Override
public void setContents(ItemStack[] items) {
base.setContents(items);
}
代码示例来源:origin: drtshock/PlayerVaults
public static String toBase64(ItemStack[] is, int size) {
Inventory inventory = Bukkit.createInventory(null, size);
inventory.setContents(is);
return toBase64(inventory, size);
}
代码示例来源:origin: ProSavage/SavageFactions
public static String toBase64(ItemStack[] is, int size) {
Inventory inventory = Bukkit.createInventory(null, size);
inventory.setContents(is);
return toBase64(inventory);
}
代码示例来源:origin: eccentricdevotion/TARDIS
public static void sortInventory(Inventory inventory) {
inventory.setContents(sortInventory(inventory.getContents()));
}
}
代码示例来源:origin: drtshock/PlayerVaults
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());
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
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);
}
代码示例来源:origin: ProSavage/SavageFactions
@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);
}
代码示例来源:origin: eccentricdevotion/TARDIS
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);
}
}
代码示例来源:origin: AddstarMC/Minigames
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);
}
代码示例来源:origin: FunnyGuilds/FunnyGuilds
public void open(HumanEntity entity) {
Inventory inv = Bukkit.createInventory(entity, this.wrap().getSize(), this.wrap().getTitle());
inv.setContents(this.wrap().getContents());
entity.openInventory(inv);
}
代码示例来源:origin: garbagemule/MobArena
/**
* 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);
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
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;
}
代码示例来源:origin: eccentricdevotion/TARDIS
@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));
}
}
}
代码示例来源:origin: eccentricdevotion/TARDIS
/**
* 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);
}
代码示例来源:origin: eccentricdevotion/TARDIS
/**
* 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);
}
代码示例来源:origin: eccentricdevotion/TARDIS
/**
* 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);
}
代码示例来源:origin: jiongjionger/NeverLag
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());
}
内容来源于网络,如有侵权,请联系作者删除!