Armour inside a GUI

Discussion in 'Plugin Development' started by Glass_Eater84, Jun 22, 2014.

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

    Glass_Eater84

    Hey everyone!
    Today I have a question on how to place my code into a GUI.
    I have my colored "Disco Armour" code but I want it inside of a gui.
    I would like it to be whenever you (whatever block) I will change it in the code.
    But here is my disco code:

    Code:java
    1. package me.glasseater.disco;
    2.  
    3. import java.util.Random;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.Color;
    7. import org.bukkit.Material;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.inventory.ItemStack;
    10. import org.bukkit.inventory.meta.LeatherArmorMeta;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class Main extends JavaPlugin {
    14.  
    15. public void onEnable() {
    16. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    17. private Random r = new Random();
    18.  
    19. public void run() {
    20. Color c = Color.fromRGB(r.nextInt(255), r.nextInt(255), r.nextInt(255));
    21.  
    22. for (Player p : Bukkit.getServer().getOnlinePlayers()) {
    23. if (p.getInventory().getHelmet() != null && p.getInventory().getHelmet().getType() == Material.LEATHER_HELMET) {
    24. p.getInventory().setHelmet(getColorArmor(Material.LEATHER_HELMET, c));
    25. }
    26.  
    27. if (p.getInventory().getChestplate() != null && p.getInventory().getChestplate().getType() == Material.LEATHER_CHESTPLATE) {
    28. p.getInventory().setChestplate(getColorArmor(Material.LEATHER_CHESTPLATE, c));
    29. }
    30.  
    31. if (p.getInventory().getLeggings() != null && p.getInventory().getLeggings().getType() == Material.LEATHER_LEGGINGS) {
    32. p.getInventory().setLeggings(getColorArmor(Material.LEATHER_LEGGINGS, c));
    33. }
    34.  
    35. if (p.getInventory().getBoots() != null && p.getInventory().getBoots().getType() == Material.LEATHER_BOOTS) {
    36. p.getInventory().setBoots(getColorArmor(Material.LEATHER_BOOTS, c));
    37. }
    38. }
    39. }
    40. }, 0, 1);
    41. }
    42.  
    43. private ItemStack getColorArmor(Material m, Color c) {
    44. ItemStack i = new ItemStack(m, 1);
    45. LeatherArmorMeta meta = (LeatherArmorMeta) i.getItemMeta();
    46. meta.setColor(c);
    47. i.setItemMeta(meta);
    48. return i;
    49. }
    50. }


    Now I just need to put it in a GUI which I need help with.
    Any help is much appreciated.

    Best Regards,
    Glass
     
  2. Offline

    DevRosemberg

  3. Offline

    Glass_Eater84

    Is there a place I can find the GUIMenu?
     
  4. Offline

    Glass_Eater84

Thread Status:
Not open for further replies.

Share This Page