本文整理汇总了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);
}
}
}