Stained glass plane item db's.

Discussion in 'Plugin Development' started by iBenjaHD, Feb 28, 2015.

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

    iBenjaHD

    Hello, I'm working on a plugin, and in the GUI, it has to find the purple stained glass, and if you click the purple stained glass, it should run /vip, here's the code that I have / tried.
    Code:
                @EventHandler
                public void onInventoryClickEvent(InventoryClickEvent e) {
                    if(!ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase("Kits"))
                    return;
                    Player p = (Player) e.getWhoClicked();
                    e.setCancelled(true);
                   
                    if(e.getCurrentItem() == null
                            || e.getCurrentItem().getType() == Material.AIR
                            || !e.getCurrentItem().hasItemMeta()) {
                        p.closeInventory();
                        return;
                    }
                   
                    switch (e.getCurrentItem().getType()){
                    case DIAMOND_SWORD:
                        p.performCommand("member");
                        p.closeInventory();
                        break;
                    }
                    if(e.getCurrentItem().getType() == Material.STAINED_GLASS_PANE, 1, (byte) 10)){
                        p.performCommand("vip");
                        p.closeInventory();
                        e.setCancelled(true);
                    }
                }
                
    The way I did member works, but then I can put the stained glass plane as purple, I don't know the way to do so, the vip is just a thing i tested, which gives me an error on STAINED_GLASS_PANE.

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

    TwerkinCraft

    There is a large syntax error in that code, on that line, that if being used, an IDE should have detected.
    "if(e.getCurrentItem().getType() == Material.STAINED_GLASS_PANE, 1, (byte) 10)){"
    First, getType() returns a Material, you gave it a material, an integer, and a byte (invalid syntax).
    The only way to check if it is purple is by first doing osmething like "if(e.getCurrentItem().getType == Material.whateventheitemis" then check the damage/data value to see if it is purple
     
  3. Offline

    stormneo7

    Code:
    if(item.getType() == Material.STAINED_GLASS_PANE && item.getData().getData() == (byte)10){
      // Purple Pane
    }
     
Thread Status:
Not open for further replies.

Share This Page