Examples of CraftItemEvent


Examples of org.bukkit.event.inventory.CraftItemEvent

    @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
    public void onInventoryCraft(InventoryClickEvent e) {
        if (!(e instanceof CraftItemEvent))
            return;
        CraftItemEvent event = (CraftItemEvent) e;
        // make sure plugin is enabled
        if(!plugin.isEnabled()) return;
       
        // If event is nothing or place, do nothing
        switch (event.getAction()) {
            case NOTHING:
            case PLACE_ONE:
            case PLACE_ALL:
            case PLACE_SOME:
                return;
            default:
                break;
        }
       
        if (event.getAction() == InventoryAction.NOTHING)
            return;
       
        CraftingInventory inv = event.getInventory();
       
        if (!(inv instanceof CraftingInventory) || !event.getSlotType().equals(SlotType.RESULT))
            return;
       
        Recipe recipe = event.getRecipe();
       
        if (recipe == null)
            return;
       
        if (!(event.getWhoClicked() instanceof Player))
            return;
       
        Player player = (Player) event.getWhoClicked();
       
        ItemStack resultStack = recipe.getResult();
       
        if (resultStack == null)
            return;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.