Solved Open Inventory NullPointer

Discussion in 'Plugin Development' started by Hugs, Oct 31, 2013.

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

    Hugs

    [SOLVED] made the hashmaps static.

    Hey guys, does anyone know why this is happening? I want to open an inventory I stored in a hashmap but it only works if I access it with a command instead of the click event.

    [​IMG]

    I put the stuff in here the first time someone uses the command:

    [​IMG]

    & Defined it at the top

    [​IMG]

    The addToInv method just adds an item to the inventory. The command is in the same class and does the same thing, ((Player)sender).openInventory(invs.get("..."));
     
  2. Offline

    Retherz_

    @EventHandler
    public void playerinteract(PlayerInteractEvent e){
    if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
    e.getPlayer().openInventory(invs.get(e.getPlayer().getName());
    }






    did u try that..?
     
  3. Offline

    Hugs

    This is happening when you click a menu button in the main menu inventory so inventory click event is correct, it just keeps throwing nullpointer

    Possibly a bukkit bug? :\ As far as I can tell there's nothing null to throw a null pointer..

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page