本文整理匯總了Java中org.bukkit.event.inventory.InventoryType.ANVIL屬性的典型用法代碼示例。如果您正苦於以下問題:Java InventoryType.ANVIL屬性的具體用法?Java InventoryType.ANVIL怎麽用?Java InventoryType.ANVIL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.bukkit.event.inventory.InventoryType
的用法示例。
在下文中一共展示了InventoryType.ANVIL屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getType
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;
}
}
示例2: onAnvil
@EventHandler
public void onAnvil(InventoryClickEvent e) {
if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.ANVIL) {
if (SlimefunManager.isItemSimiliar(e.getInventory().getContents()[0], SlimefunItems.ELYTRA, true)) return;
if (SlimefunItem.getByItem(e.getInventory().getContents()[0]) != null && !SlimefunItem.isDisabled(e.getInventory().getContents()[0])) {
e.setCancelled(true);
Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true);
}
}
}
示例3: event
@EventHandler
public void event(InventoryClickEvent e) {
if (e.getCurrentItem() == null) return;
if (g.state == GameState.INGAME && e.getInventory().getType() == InventoryType.ANVIL && e.getCurrentItem() != null && e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName() && OMGLoot.loots.stream().anyMatch(l -> l.name.equals(e.getCurrentItem().getItemMeta().getDisplayName()))) {
e.setCancelled(true);
return;
}
if (e.getClickedInventory() != null && e.getClickedInventory().getTitle() != null) {
if (e.getClickedInventory().getTitle().equals(Inventories.options.getTitle()) && e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName()) {
if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Teams"))
Inventories.openFakeInv(Inventories.teams, get((Player) e.getWhoClicked()));
if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Kits"))
Inventories.openFakeInv(Inventories.kits, get((Player) e.getWhoClicked()));
if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Hotbar"))
get((Player) e.getWhoClicked()).hotbarEdit();
if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Vote") && g.voteSystem.vote(get((Player) e.getWhoClicked()), e.getCurrentItem().getItemMeta().getDisplayName().replaceAll(ChatColor.WHITE + "Vote for ", "")))
e.getWhoClicked().sendMessage(ChatColor.DARK_AQUA + "Voted for " + e.getCurrentItem().getItemMeta().getDisplayName().replaceAll(ChatColor.WHITE + "Vote for ", ""));
e.setCancelled(true);
} else if (e.getClickedInventory().getTitle().equals(Inventories.teams.getTitle())) {
OMGTeam.registeredTeams.stream().filter(t -> t.id.equals(NBTParser.getTagCompound(e.getCurrentItem()).getString("teamid"))).findFirst().ifPresent(t -> g.player_request_team(get((Player) e.getWhoClicked()), t));
Inventories.openFakeInv(Inventories.teams, get((Player) e.getWhoClicked()));
e.setCancelled(true);
} else if (e.getClickedInventory().getTitle().equals(Inventories.kits.getTitle())) {
OMGKit.kits.stream().filter(k -> k.name.equals(NBTParser.getTagCompound(e.getCurrentItem()).getString("kitid"))).findFirst().ifPresent(k -> g.player_request_kit(get((Player) e.getWhoClicked()), OMGKit.kits.stream().filter(k1 -> k1 == k).findFirst().orElse(null)));
Inventories.openFakeInv(Inventories.kits, get((Player) e.getWhoClicked()));
e.setCancelled(true);
} else if (e.getClickedInventory().getTitle().equals("Hotbar Editor")) {
if (e.getCurrentItem() != null) {
e.setCancelled(true);
if (get((Player) e.getWhoClicked()).selectedHBESlot != -1) {
String order = g.player_hotbarOrder(get((Player) e.getWhoClicked()));
int b = Integer.parseInt(e.getCurrentItem().getItemMeta().getDisplayName()) - 1;
char[] ss = order.toCharArray();
ss[order.indexOf(get((Player) e.getWhoClicked()).selectedHBESlot + "")] = (b + "").charAt(0);
ss[order.indexOf(b + "")] = (get((Player) e.getWhoClicked()).selectedHBESlot + "").charAt(0);
g.player_set_hotbarOrder(get((Player) e.getWhoClicked()), new String(ss));
get((Player) e.getWhoClicked()).hotbarEdit();
} else {
get((Player) e.getWhoClicked()).selectedHBESlot = Integer.parseInt(e.getCurrentItem().getItemMeta().getDisplayName()) - 1;
e.getClickedInventory().clear(e.getSlot());
}
}
e.setCancelled(true);
} else if (e.getClickedInventory().getTitle().equals(Inventories.gameShop.getTitle())) {
List<String> nbts = g.gamefig.getStringList("gameShop");
if (e.getSlot() < nbts.size()) {
NBTParser nbt = new NBTParser(nbts.get(e.getSlot()));
if (!nbt.getString("id").toLowerCase().contains("air"))
g.player_giveShopItem(get((Player) e.getWhoClicked()), nbt);
}
e.setCancelled(true);
}
}
}