Advertisement
Guest User

Untitled

a guest
Jul 9th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.13 KB | None | 0 0
  1. @EventHandler
  2. public void onInventoryClick(InventoryClickEvent e) throws IOException {
  3. Inventory inv = e.getInventory();
  4. if (!inv.getTitle().equals("Chat Colors"))
  5. return;
  6.  
  7. if (!(e.getWhoClicked() instanceof Player))
  8. return;
  9.  
  10. Player p = (Player) e.getWhoClicked();
  11. File swdir = SkysWarsCore.get().getDataFolder();
  12. File swdata = new File(swdir, "player_data");
  13. File pdata = new File(swdata, p.getUniqueId().toString() + ".yml");
  14. YamlConfiguration fc = YamlConfiguration.loadConfiguration(pdata);
  15. ItemStack item = e.getCurrentItem();
  16. if (item.getItemMeta().getDisplayName().equalsIgnoreCase("Dark Blue")) {
  17. fc.set("chat_color", "1");
  18. fc.save(pdata);
  19. e.setCancelled(true);
  20. p.closeInventory();
  21. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.DARK_BLUE + "Dark Blue");
  22. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("dark green")) {
  23. fc.set("chat_color", "2");
  24. fc.save(pdata);
  25. e.setCancelled(true);
  26. p.closeInventory();
  27. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.DARK_GREEN + "Dark Green");
  28. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("blue")) {
  29. fc.set("chat_color", "3");
  30. fc.save(pdata);
  31. e.setCancelled(true);
  32. p.closeInventory();
  33. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.BLUE + "Blue");
  34. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("dark red")) {
  35. fc.set("chat_color", "4");
  36. fc.save(pdata);
  37. e.setCancelled(true);
  38. p.closeInventory();
  39. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.DARK_RED + "Dark Red");
  40. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("purple")) {
  41. fc.set("chat_color", "5");
  42. fc.save(pdata);
  43. e.setCancelled(true);
  44. p.closeInventory();
  45. p.sendMessage(
  46. ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.DARK_PURPLE + "Dark Purple");
  47. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("gold")) {
  48. fc.set("chat_color", "6");
  49. fc.save(pdata);
  50. e.setCancelled(true);
  51. p.closeInventory();
  52. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.GOLD + "Gold");
  53. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("gray")) {
  54. fc.set("chat_color", "7");
  55. fc.save(pdata);
  56. e.setCancelled(true);
  57. p.closeInventory();
  58. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.GRAY + "Gray");
  59. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("dark gray")) {
  60. fc.set("chat_color", "8");
  61. fc.save(pdata);
  62. e.setCancelled(true);
  63. p.closeInventory();
  64. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.DARK_GRAY + "Dark Gray");
  65. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("cyan")) {
  66. fc.set("chat_color", "9");
  67. fc.save(pdata);
  68. e.setCancelled(true);
  69. p.closeInventory();
  70. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.DARK_AQUA + "Cyan");
  71. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("black")) {
  72. fc.set("chat_color", "0");
  73. fc.save(pdata);
  74. e.setCancelled(true);
  75. p.closeInventory();
  76. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.BLACK + "Black");
  77. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("light green")) {
  78. fc.set("chat_color", "a");
  79. fc.save(pdata);
  80. e.setCancelled(true);
  81. p.closeInventory();
  82. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.GREEN + "Light Green");
  83. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("aqua")) {
  84. fc.set("chat_color", "b");
  85. fc.save(pdata);
  86. e.setCancelled(true);
  87. p.closeInventory();
  88. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.AQUA + "Aqua");
  89. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("light red")) {
  90. fc.set("chat_color", "c");
  91. fc.save(pdata);
  92. e.setCancelled(true);
  93. p.closeInventory();
  94. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.RED + "Light Red");
  95. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("light purple")) {
  96. fc.set("chat_color", "d");
  97. fc.save(pdata);
  98. e.setCancelled(true);
  99. p.closeInventory();
  100. p.sendMessage(
  101. ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.LIGHT_PURPLE + "Light Purple");
  102. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("yellow")) {
  103. fc.set("chat_color", "e");
  104. fc.save(pdata);
  105. e.setCancelled(true);
  106. p.closeInventory();
  107. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.YELLOW + "Yellow");
  108. } else if (item.getItemMeta().getDisplayName().equalsIgnoreCase("white")) {
  109. fc.set("chat_color", "f");
  110. fc.save(pdata);
  111. e.setCancelled(true);
  112. p.closeInventory();
  113. p.sendMessage(ChatColor.BLUE + "You have changed your Chat Color to" + ChatColor.WHITE + "White");
  114. }
  115. e.setCancelled(true);
  116. p.closeInventory();
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement