本文整理汇总了Java中org.bukkit.inventory.Inventory.setItem方法的典型用法代码示例。如果您正苦于以下问题:Java Inventory.setItem方法的具体用法?Java Inventory.setItem怎么用?Java Inventory.setItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.setItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setLayout
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
private void setLayout(Inventory inv) {
String title = getData().title();
int size = getData().size();
int lastLineFirstIndex = size - 9;
ItemStack wall = new ItemBuilder(Material.STAINED_GLASS)
.display("")
.build();
for (int i = 0; i < 9; i++) {
inv.setItem(i, wall);
}
for (int i = lastLineFirstIndex; i < size; i++) {
inv.setItem(i, wall);
}
inv.setItem(4, new ItemBuilder(Material.NETHER_STAR).display(title).build());
inv.setItem(prevPageBtnIndex, new ItemBuilder(Material.WOOD_BUTTON).build());
inv.setItem(nextPageBtnIndex, new ItemBuilder(Material.WOOD_BUTTON).build());
}
示例2: setupMobSpawnInventory
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static void setupMobSpawnInventory(Player player) {
Inventory inv = Bukkit.createInventory(player, 18, ChatColor.BOLD + "Select Mob Type");
inv.setItem(0, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 50, ChatColor.DARK_GREEN + "Creeper", null));
inv.setItem(1, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 51, ChatColor.GRAY + "Skeleton", null));
inv.setItem(2, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 52, ChatColor.DARK_GRAY + "Spider", null));
inv.setItem(3, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 54, ChatColor.DARK_AQUA + "Zombie", null));
inv.setItem(4, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 55, ChatColor.GREEN + "Slime", null));
inv.setItem(5, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 56, ChatColor.RED + "Ghast", null));
inv.setItem(6, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 57, ChatColor.RED + "Pigman", null));
inv.setItem(7, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 58, ChatColor.DARK_GRAY + "Enderman", null));
inv.setItem(8, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 59, ChatColor.DARK_RED + "Cave Spider", null));
inv.setItem(9, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 60, ChatColor.DARK_GRAY + "Silverfish", null));
inv.setItem(10, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 61, ChatColor.YELLOW + "Blaze", null));
inv.setItem(11, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 62, ChatColor.GRAY + "Magma Cube", null));
inv.setItem(12, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 65, ChatColor.DARK_GRAY + "Bat", null));
inv.setItem(13, ItemStackGenerator.createItem(Material.MONSTER_EGG, 0, 66, ChatColor.DARK_PURPLE + "Witch", null));
player.openInventory(inv);
}
示例3: pending
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static Inventory pending(Player player) {
Inventory i = Bukkit.createInventory(null, 54, Messager.color("&cPending Ban Requests"));
ItemStack back = new ItemStack(Material.ARROW);
ItemMeta im = back.getItemMeta();
im.setDisplayName(Messager.color("&cBack"));
back.setItemMeta(im);
i.setItem(45, back);
int tillFull = 0;
for (int x = 0; x <= Main.getInstance().getConfig().getInt("current_id"); x++) {
if (tillFull >= 53) {
Messager.msgPlayer("&cAll of the requests could not fit in the GUI. Please accept or deny some requests.", player);
break;
}
BanRequest br = new BanRequest(x);
if (!br.closed) {
i.addItem(br.getItem());
tillFull++;
}
}
return i;
}
示例4: onCompassClick
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@EventHandler
public void onCompassClick(PlayerInteractEvent event) {
if (event.getItem() == null || event.getItem().getType() != Material.COMPASS)
return;
Player p = event.getPlayer();
ItemStack stack = event.getItem();
if (stack.getItemMeta().hasDisplayName()) {
String display = Chat.stripColor(stack.getItemMeta().getDisplayName());
if (display.equalsIgnoreCase("game picker")) {
Inventory inv = Bukkit.getServer().createInventory(p, 9, Chat.colors("&oMC Zone Games"));
for (int i = 1; i < 12; i++) {
int number = i - 1;
if (i > GameIcon.getList().size())
break;
inv.setItem(i, GameIcon.getList().get(number).getItemStack());
}
p.openInventory(inv);
}
}
}
示例5: run
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@Override
public void run() {
AgarMC plugin = AgarMC.get();
if (plugin.getGame().getPlayers().isEmpty())
return ;
if(plugin.getGame().getVirus().size() < plugin.getGame().getMaxVirus()) {
VirusCell virus = new VirusCell(Utils.randomLocation(plugin.getGame().getOrigin().getX(), plugin.getGame().getDimensions()), Utils.randomLocation(plugin.getGame().getOrigin().getZ(), plugin.getGame().getDimensions()));
plugin.getGame().addVirus(virus);
}
for (CPlayer player : plugin.getGame().getPlayers())
{
player.getPlayer().getInventory().setItem(1, updateColorBlock(player.getPlayer().getInventory().getItem(1)));
InventoryView iv = player.getPlayer().getOpenInventory();
if (iv == null)
continue ;
Inventory i = iv.getTopInventory();
if (i == null || !i.getName().equals(MenuGui.INV_NAME))
continue ;
i.setItem(0, updateColorBlock(i.getItem(0)));
}
}
示例6: lockEmptySlots
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static void lockEmptySlots(Inventory inventory) {
for (int i = 0; i < inventory.getSize(); i++) {
Slot slot = SlotManager.instance().getSlot(i, InventoryType.SlotType.CONTAINER);
if (slot == null) {
inventory.setItem(i, fillSlot);
} else if (ItemUtils.isEmpty(inventory.getItem(i))) {
inventory.setItem(i, slot.getCup());
}
}
}
示例7: run
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@Override
public void run(PlayerInteractEvent evt) {
Player player = evt.getPlayer();
if (CooldownTicker.can(this, player) || evt.getItem().getItemMeta().getLore().contains("§6高速射击")) {
Inventory inv = player.getInventory();
if (!inv.contains(Material.SULPHUR)) {
AzureAPI.log(player, "你没有弹药! 需要 " + ChatColor.RED + "火药" + ChatColor.GOLD + " 作为弹药");
AzureAPI.playSound(player, Sound.ENTITY_ITEM_BREAK);
return;
}
int slot = inv.first(Material.SULPHUR);
ItemStack ammo = inv.getItem(slot);
int amount = ammo.getAmount();
if (amount > 1) {
ammo.setAmount(amount - 1);
inv.setItem(slot, ammo);
} else {
inv.setItem(slot, null);
}
Location eye = player.getEyeLocation();
Vector direction = eye.getDirection().multiply(2);
Projectile projectile = player.getWorld().spawn(eye.add(direction), Fireball.class);
projectile.setShooter(player);
projectile.setVelocity(direction);
AzureAPI.playSound(player, Sound.ITEM_FIRECHARGE_USE, true);
CooldownTicker.cooldown(this, player, TimeUnit.SECONDS, 3);
} else {
AzureAPI.playSound(player, Sound.UI_BUTTON_CLICK);
AzureAPI.log(player, "冷却时间还没有结束呢!");
}
}
示例8: updateQuickSlot
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static void updateQuickSlot(@NotNull Player player, @NotNull Inventory inventory, @NotNull Slot slot, int slotId,
InventoryType.SlotType slotType, InventoryAction action,
ItemStack currentItem, ItemStack cursor) {
ActionType actionType = ActionType.getTypeOfAction(action);
if (actionType == ActionType.GET) {
if (slot.isCup(currentItem)) {
return;
}
if (player.getInventory().getHeldItemSlot() == slot.getQuickSlot()) {
InventoryUtils.heldFreeSlot(player, slot.getQuickSlot(), InventoryUtils.SearchType.NEXT);
}
if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
inventory.setItem(slot.getSlotId(), slot.getCup());
} else {
player.getInventory().setItem(slot.getQuickSlot(), slot.getCup());
}
action = InventoryAction.SWAP_WITH_CURSOR;
cursor = slot.getCup();
} else if (actionType == ActionType.SET) {
if (slot.isCup(currentItem)) {
currentItem = null;
action = InventoryAction.PLACE_ALL;
}
if (slotType == InventoryType.SlotType.QUICKBAR && InventoryAPI.isRPGInventory(inventory)) {
inventory.setItem(slot.getSlotId(), cursor);
} else {
player.getInventory().setItem(slot.getQuickSlot(), cursor);
}
}
InventoryManager.updateInventory(player, inventory, slotId, slotType, action, currentItem, cursor);
}
示例9: getInventory
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public Inventory getInventory() {
Inventory inv = Bukkit.createInventory(null, 54, "Inventory of " + this.name);
for (int i = 9; i <= 35; ++i) {
inv.setItem(i - 9, this.inventory.getContents()[i]);
}
for (int i = 0; i <= 8; ++i) {
inv.setItem(i + 27, this.inventory.getContents()[i]);
}
inv.setItem(36, this.inventory.getHelmet());
inv.setItem(37, this.inventory.getChestPiece());
inv.setItem(38, this.inventory.getLeggings());
inv.setItem(39, this.inventory.getBoots());
if (this.health == 0.0) {
inv.setItem(48, new ItemBuilder(Material.SKULL_ITEM, ChatColor.RED + "Player Died", new String[] { "" }).getItem());
}
else {
inv.setItem(48, new ItemBuilder(Material.SPECKLED_MELON, ChatColor.GREEN + "Player Health", new String[] { this.health / 2.0 + " Hearts" }).getItem());
}
inv.setItem(49, new ItemBuilder(Material.COOKED_BEEF, ChatColor.GREEN + "Player Hunger", new String[] { this.food / 2.0 + " Hunger" }).getItem());
ItemStack potions = new ItemBuilder(Material.POTION, ChatColor.BLUE + "Potion Effects", new String[0]).getItem();
ItemMeta imm = potions.getItemMeta();
imm.setLore(this.effects);
potions.setItemMeta(imm);
inv.setItem(50, potions);
return inv;
}
示例10: onCommand
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender cs, String[] args) {
if (!cs.hasPermission("transportpipes.creative")) {
return false;
}
if (cs instanceof Player) {
Inventory inv = Bukkit.createInventory(null, 9 * 3, LocConf.load(LocConf.CREATIVE_TITLE));
int i = 0;
List<ItemStack> ductItems = DuctItemUtils.getAllDuctItems();
for (ItemStack is : ductItems) {
ItemStack clonedIs = is.clone();
clonedIs.setAmount(16);
inv.setItem(i, clonedIs);
i++;
}
inv.setItem(i++, DuctItemUtils.getClonedWrenchItem());
((Player) cs).openInventory(inv);
} else {
cs.sendMessage("§cYou're not a player!");
}
return true;
}
示例11: createDefaultGUI
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
private static Inventory createDefaultGUI(String title){
Inventory inv=Bukkit.createInventory(null, 54,title);
for(int i=0;i<54;i++)
if(!(materials.contains(i)||products.contains(i)))
inv.setItem(i, Items.createPItem((short)15, "��7��l������~��Ҫ���ǿ����˼���~"));
return inv;
}
示例12: onItemUse
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
@EventHandler
public void onItemUse(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (!event.hasItem() || !InventoryManager.playerIsLoaded(player)) {
return;
}
Inventory inventory = InventoryManager.get(player).getInventory();
ItemStack petItem = event.getItem();
if (player.getGameMode() == GameMode.CREATIVE && PetManager.isPetItem(petItem)) {
petItem = PetManager.toPetItem(petItem);
player.getEquipment().setItemInMainHand(petItem);
}
if (PetType.isPetItem(petItem)
&& (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)) {
Slot petSlot = SlotManager.instance().getPetSlot();
if (petSlot != null && petSlot.isCup(inventory.getItem(PetManager.getPetSlotId()))
&& ItemManager.allowedForPlayer(player, petItem, false)) {
inventory.setItem(PetManager.getPetSlotId(), event.getItem());
PetManager.spawnPet(player, petItem);
player.getEquipment().setItemInMainHand(null);
}
event.setCancelled(true);
}
}
示例13: openPD
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static Inventory openPD(){
Inventory inv=Bukkit.createInventory(null, 18,"��2��l����װ��");
for(int i=0;i<18;i++)
inv.setItem(i, Items.createPItem((short)15, "��7��l������~��Ҫ���ǿ����˼���~"));
inv.setItem(1,null);
inv.setItem(4, null);
inv.setItem(7, null);
inv.setItem(13, Items.createPItem((short)5, "��2��l��ʼ����"));
return inv;
}
示例14: setItem
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
public static void setItem(String display, int id, int data, int amount, List<String> lore, int loc, Inventory inventory) {
ItemStack icon = new MaterialData(id, (byte) data).toItemStack(amount);
ItemMeta iconmeta = icon.getItemMeta();
iconmeta.setDisplayName(display);
iconmeta.setLore(lore);
icon.setItemMeta(iconmeta);
inventory.setItem(loc, icon);
}
示例15: populateInventoryLine
import org.bukkit.inventory.Inventory; //导入方法依赖的package包/类
private static void populateInventoryLine(Inventory inv, int row, ItemStack... items) {
for (int i = 0; i < 9; i++) {
if (items.length > i && items[i] != null) {
ItemStack is = items[i];
inv.setItem(row * 9 + i, is);
}
}
}