Anvil Canceling not working

Discussion in 'Plugin Development' started by monkeymanboy, Oct 9, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    monkeymanboy

    I am trying to cancel the anvil for specific items it works but the player can click rapidly with any item(one that I'm canceling or not) and it will give me a ton of errors(with what I am trying to do still working) heres my code
    Code:java
    1.  
    2. @EventHandler
    3. public void NoAnvil(InventoryClickEvent event) {
    4. if (event.getInventory().getType() == InventoryType.ANVIL && event.getSlotType() == SlotType.CRAFTING) {
    5. ItemMeta im = event.getCursor().getItemMeta();
    6. if(im.hasLore())
    7. if(im.getLore().contains(ChatColor.DARK_AQUA + "Freebuild Item"))
    8. event.setCancelled(true);
    9. }
    10. }
     
  2. Offline

    chasechocolate

    What are the errors?
     
  3. Offline

    monkeymanboy

    chasechocolate Oops forgot here
    Code:
    Caused by: java.lang.NullPointerException
            at com.icloud.dcljr.MinecloudCore.fb.NoAnvil(fb.java:59)
            at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425)
            ... 15 more
    
    Edit: line 59 in the hasLore part I have no idea why it's giving me an error there
     
  4. Offline

    chasechocolate

    monkeymanboy check if event.getCursor().hasItemMeta() before creating the ItemMeta variable.
     
  5. Offline

    monkeymanboy

    chasechocolate It works now except now if the player puts it in say their 9 slot then click 9 it moves the item there then they can make the item any way around that?
     
  6. Offline

    monkeymanboy

Thread Status:
Not open for further replies.

Share This Page