gui not doing anything

Discussion in 'Plugin Development' started by Ethan Rocks 365, Feb 18, 2016.

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

    Ethan Rocks 365

    The code is below
    Code:
    @EventHandler
        public void onInventoryClick(InventoryClickEvent event){
            if(!ChatColor.stripColor(event.getInventory().getName()).equalsIgnoreCase("Test GUI"))
               return;
            Player player = (Player) event.getWhoClicked();
            event.setCancelled(true);
          
            if(event.getCurrentItem()==null || event.getCurrentItem().getType()==Material.AIR||!event.getCurrentItem().hasItemMeta()){
                player.closeInventory();
                return;
            }
          
            switch(event.getCurrentItem().getType()){
            case DRAGON_EGG:
                player.sendMessage(ChatColor.RED + "Test1 works!");
                player.closeInventory();
                break;
            default:
                player.closeInventory();
                break;
            }
        }
    
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event) {
            ItemStack is = event.getItem();
          
            if (is.getType() == Material.AIR || is.getType() == Material.SIGN)
                openGUI(event.getPlayer());
        }
    
    }   
    How ever when i right click a placed sign or a held sign or air it no work.
     
    Last edited: Feb 19, 2016
  2. Offline

    BobTheHamster9

    Have you registered your events?
    Can we see your openGUI method?
     
  3. Offline

    SkyleTyler1337

    @Ethan Rocks 365 are you trying to open the inventory? with
    Code:
     ItemStack is = event.getItem();
     
  4. Offline

    DarkestCodes

    We need to see your openGUI method.
     
  5. Offline

    Ethan Rocks 365

    Will link to video let me find it:​



    That's basically everything i did I'll send all my code when I get home from school
     
  6. Offline

    Protophite

  7. Offline

    Lordloss

    My recommendation is, stop using youtube to learn java/bukkit...
     
    teej107 likes this.
  8. Offline

    Ethan Rocks 365

    no
     
  9. Offline

    Zombie_Striker

    @Sorceresofminecraft
    Did you just quote yourself?


    @Ethan Rocks 365
    1. Don't Learn from the BCBroz. He teachs far too many bad mistakes for anyone to recommend him. He even states in one of his recent videos that he taught so many bad practices that they should not be used. Instead of watching his videos PLEASE Find a tutorial from the following link :https://bukkit.org/threads/plugin-dev-sticky-learning-java-where-to-learn.395662/
    2. I do not see the "OpenGUI" method. Can you post that line?
    3. You cannot check if an itemstack is equal to air. If the type is air, the itemstack would be null and this would throw an NPE! Check if the itemstack is null instead of if it is air.
     
  10. Offline

    Ethan Rocks 365

    I fixed for got to register it
     
  11. Offline

    Lordloss

    So what is the most important advice in every EventListener tutorial? Please mark as solved then o.o
     
Thread Status:
Not open for further replies.

Share This Page