Solved How to put colored wools in GUI

Discussion in 'Plugin Development' started by nathampa0909, Sep 30, 2014.

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

    nathampa0909

    Hello, I have a problem with GUI. I watched this video: and I wanted put WOOL, 1, DyeColor.BLACK for example.

    My Code:

    Code:java
    1. private void openGUI(Player pl) {
    2. Inventory invr = Bukkit.createInventory(null, 18, ChatColor.GREEN + "Escolha seu cavalo!");
    3.  
    4. ItemStack wool = new ItemStack(Material.WOOL, 1, DyeColor.BLACK.getData());
    5. ItemStack cavalo1 = new ItemStack(wool);
    6. ItemMeta cavalo1Meta = cavalo1.getItemMeta();
    7. cavalo1Meta.setDisplayName(getConfig().getString("NomeDosCavalos.Cavalo1").replace("&", "ยง"));
    8. cavalo1.setItemMeta(cavalo1Meta);
    9.  
    10. pl.openInventory(invr);
    11.  
    12. }
    13.  
    14. @EventHandler
    15. public void onInteract(PlayerInteractEvent e) {
    16. Action a = e.getAction();
    17. ItemStack as = e.getItem();
    18.  
    19. if ((a == Action.PHYSICAL) || (as == null)
    20. || (as.getType() == Material.AIR)) {
    21. return;
    22. }
    23. }
    24.  
    25. @EventHandler
    26. public void onInventory(InventoryClickEvent e) {
    27. if (!ChatColor.stripColor(e.getInventory().getName()).equalsIgnoreCase(
    28. "Escolha seu cavalo!"))
    29. return;
    30.  
    31. Player p = (Player) e.getWhoClicked();
    32. e.setCancelled(true);
    33.  
    34. if (e.getCurrentItem() == null
    35. || e.getCurrentItem().getType().equals(Material.AIR)
    36. || !e.getCurrentItem().hasItemMeta()) {
    37. p.closeInventory();
    38. return;
    39. }
    40.  
    41. switch (e.getCurrentItem().getType()){
    42.  
    43.  
    44. case WOOL:
    45. makeHorse(p, Horse.Color.BLACK);
    46. p.closeInventory();
    47. break;
    48.  
    49. default:
    50. p.closeInventory();
    51. break;
    52. }
    53. }
    54. And ...


    The GUI:

    [​IMG]

    @EDIT

    What I meant is that the GUI with colored wool does not work in WOOL CASE.

    Sorry for my bad english!
     
  2. Offline

    d3v1n302418

    nathampa0909 Because you never check to make sure its colored... Try if (e.getCurrentItem().getDurability() == DyeColor.BLACK.ordinal()){
     
  3. Offline

    ChipDev

    Nah.
    Code:java
    1. Wool wool = new Wool(DyeColor.RED);
    2. ItemStack colored = wool.toItemStack();
     
  4. Offline

    nathampa0909

    Thanks!! This topic is solved!
     
  5. Offline

    moo3oo3oo3

    make sure to add he solve prefix to the thread
     
Thread Status:
Not open for further replies.

Share This Page