Inventory GUI Not working.

Discussion in 'Plugin Development' started by DatRefillDoe, Jul 23, 2014.

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

    DatRefillDoe

    Code:
        @EventHandler
        public void invenopen(PlayerInteractEvent e){
            Player p = e.getPlayer();
           
            if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR){
               
                if(p.getItemInHand().getType() == Material.CHEST){
                   
                    e.setCancelled(true);
     
     
                    Inventory kiv = plugin.kitinv;
                   
                    kiv.clear();
                   
                    ItemStack ber = new ItemStack(Material.FIRE);
                    ItemStack kan = new ItemStack(Material.FIREWORK);
                    ItemStack stom = new ItemStack(Material.IRON_BOOTS);
     
                    ItemMeta berm = ber.getItemMeta();
                    ItemMeta kanm = kan.getItemMeta();
                    ItemMeta stomn = stom.getItemMeta();
     
                    if(p.hasPermission("kits.berserker") || p.isOp()){
                        berm.setDisplayName(ChatColor.GREEN + "Berserker");
                    }else{
                        berm.setDisplayName(ChatColor.RED + "Berserker");
                    }
                    if(p.hasPermission("kits.kangaroo")|| p.isOp()){
                        kanm.setDisplayName(ChatColor.GREEN + "Kangaroo");
                    }else{
                        kanm.setDisplayName(ChatColor.RED + "Kangaroo");
                    }
                    if(p.hasPermission("kits.stomper")|| p.isOp()){
                        stomn.setDisplayName(ChatColor.GREEN + "Stomper");
                    }else{
                        stomn.setDisplayName(ChatColor.RED + "Stomper");
                    }
     
                    ber.setItemMeta(berm);
                    kan.setItemMeta(kanm);
                    stom.setItemMeta(stomn);
     
                    kiv.addItem(ber);
                    kiv.addItem(kan);
                    kiv.addItem(stom);
                   
                }
            }
        }
    ^
    That code, literallly returns nothing. Can I have some help?
     
  2. Offline

    agent6262

    Did you register you event?
     
  3. Offline

    DatRefillDoe

    Code:
    getServer().getPluginManager().registerEvents(new CommandKits(this), this);
    Yeah I did.
     
  4. Offline

    AXCoding

    You cancel the event right away?????
    Code:
                    e.setCancelled(true);
    
     
  5. Offline

    DatRefillDoe

  6. Offline

    _LB

    Canceling the event is not the issue. The issue is that you never call Player.openInventory()
     
  7. Offline

    DatRefillDoe

    AXCoding That's not the problem, I'm setting cancelled so they can't place the chest. setCancelled wont cancell the event.

    *facepalm* I'm so stupid, thanks _LB

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  8. Offline

    agent6262

    I do believe _LB has it right.
     
Thread Status:
Not open for further replies.

Share This Page