NoAnvil.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:SurvivalPlus 作者:
@EventHandler
public void onInventoryClick(InventoryClickEvent e)
{
    Inventory inv = e.getInventory();

    if(inv instanceof AnvilInventory)
    {
        AnvilInventory anvil = (AnvilInventory)inv;
        InventoryView view = e.getView();
        int rawSlot = e.getRawSlot();

        // compare raw slot to the inventory view to make sure we are in the upper inventory
        if(rawSlot == view.convertSlot(rawSlot))
        {
            // 2 = result slot
            if(rawSlot == 2)
            {
                // item in the left slot
                ItemStack item = anvil.getContents()[0];

                if(item != null)
                {
                    if
                    (
                        item.getType() == Material.GOLD_AXE
                        || item.getType() == Material.GOLD_PICKAXE
                        || item.getType() == Material.GOLD_SPADE
                        || item.getType() == Material.GOLD_HOE
                        || item.getType() == Material.GOLD_SWORD
                        || item.getType() == Material.WOOD_AXE
                        || item.getType() == Material.WOOD_PICKAXE
                        || item.getType() == Material.WOOD_SPADE
                        || item.getType() == Material.WOOD_HOE
                        || item.getType() == Material.WOOD_SWORD
                    )
                    {
                        e.setCancelled(true);
                        e.getWhoClicked().closeInventory();
                        e.getWhoClicked().sendMessage(ChatColor.RED + Survival.Words.get("You cannot rename or repair ") + item.getItemMeta().getDisplayName() + ChatColor.RED + Survival.Words.get("period"));
                    }
                }
            }
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号