BeshoGraphix

Untitled

May 17th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.97 KB | None | 0 0
  1. package me.besho.kituser;
  2.  
  3.  
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.player.AsyncPlayerChatEvent;
  12. import org.bukkit.event.player.PlayerJoinEvent;
  13. import org.bukkit.plugin.java.JavaPlugin;
  14.  
  15. public class Main extends JavaPlugin implements Listener {
  16.  
  17. public void onEnable() {
  18. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  19. if (!getConfig().contains("prefix")) {
  20. getConfig().set("prefix", "%p &6: ");
  21. }
  22. }
  23.  
  24. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  25.  
  26. if (!(sender instanceof Player)) {
  27. sender.sendMessage(ChatColor.RED + "Only players can get nicknames!");
  28. }
  29.  
  30. Player p = (Player) sender;
  31. if (cmd.getName().equalsIgnoreCase("mycolor")) {
  32. if (args.length == 0) {
  33. sender.sendMessage("§7================§a[§8MyColor§a]§7================");
  34. sender.sendMessage(ChatColor.DARK_AQUA + "§2MyColor Commands :-");
  35. sender.sendMessage(ChatColor.DARK_AQUA + "/mycolor <color code> §6-> change your name color ");
  36. sender.sendMessage(ChatColor.DARK_AQUA + "/mycolor colors §6-> show all color codes");
  37. sender.sendMessage("§aCreator : BeshoGraphix");
  38. sender.sendMessage("§7================§a[§8MyColor§a]§7================");
  39. return true;
  40. }
  41. else if (args.length == 1){
  42. //-------------------------[ colors ]-------------------------//
  43. if (args[0].equalsIgnoreCase("1")){
  44. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_BLUE + p.getName());
  45. this.getConfig().set(p.getName(), ChatColor.DARK_BLUE + p.getName());
  46. this.saveConfig();
  47. }
  48. if (args[0].equalsIgnoreCase("2")){
  49. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_GREEN + p.getName());
  50. this.getConfig().set(p.getName(), ChatColor.DARK_GREEN + p.getName());
  51. this.saveConfig();
  52. }
  53. if (args[0].equalsIgnoreCase("3")){
  54. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_AQUA + p.getName());
  55. this.getConfig().set(p.getName(), ChatColor.DARK_AQUA + p.getName());
  56. this.saveConfig();
  57. }
  58. if (args[0].equalsIgnoreCase("4")){
  59. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_RED + p.getName());
  60. this.getConfig().set(p.getName(), ChatColor.DARK_RED + p.getName());
  61. this.saveConfig();
  62. }
  63. if (args[0].equalsIgnoreCase("5")){
  64. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_PURPLE + p.getName());
  65. this.getConfig().set(p.getName(), ChatColor.DARK_PURPLE + p.getName());
  66. this.saveConfig();
  67. }
  68. if (args[0].equalsIgnoreCase("6")){
  69. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.GOLD + p.getName());
  70. this.getConfig().set(p.getName(), ChatColor.GOLD + p.getName());
  71. this.saveConfig();
  72. }
  73. if (args[0].equalsIgnoreCase("7")){
  74. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.GRAY + p.getName());
  75. this.getConfig().set(p.getName(), ChatColor.GRAY + p.getName());
  76. this.saveConfig();
  77. }
  78. if (args[0].equalsIgnoreCase("8")){
  79. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.DARK_GRAY + p.getName());
  80. this.getConfig().set(p.getName(), ChatColor.DARK_GRAY + p.getName());
  81. this.saveConfig();
  82. }
  83. if (args[0].equalsIgnoreCase("9")){
  84. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.BLUE + p.getName());
  85. this.getConfig().set(p.getName(), ChatColor.BLUE + p.getName());
  86. this.saveConfig();
  87. }
  88. if (args[0].equalsIgnoreCase("0")){
  89. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.BLACK + p.getName());
  90. this.getConfig().set(p.getName(), ChatColor.BLACK + p.getName());
  91. this.saveConfig();
  92. }
  93. if (args[0].equalsIgnoreCase("a")){
  94. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.GREEN + p.getName());
  95. this.getConfig().set(p.getName(), ChatColor.GREEN + p.getName());
  96. this.saveConfig();
  97. }
  98. if (args[0].equalsIgnoreCase("b")){
  99. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.AQUA + p.getName());
  100. this.getConfig().set(p.getName(), ChatColor.AQUA + p.getName());
  101. this.saveConfig();
  102. }
  103. if (args[0].equalsIgnoreCase("c")){
  104. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.RED + p.getName());
  105. this.getConfig().set(p.getName(), ChatColor.RED + p.getName());
  106. this.saveConfig();
  107. }
  108. if (args[0].equalsIgnoreCase("d")){
  109. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.LIGHT_PURPLE + p.getName());
  110. this.getConfig().set(p.getName(), ChatColor.LIGHT_PURPLE + p.getName());
  111. this.saveConfig();
  112. }
  113. if (args[0].equalsIgnoreCase("e")){
  114. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.YELLOW + p.getName());
  115. this.getConfig().set(p.getName(), ChatColor.YELLOW + p.getName());
  116. this.saveConfig();
  117. }
  118. if (args[0].equalsIgnoreCase("f")){
  119. p.sendMessage(ChatColor.GOLD + "You have changed your name color to " + ChatColor.WHITE + p.getName());
  120. this.getConfig().set(p.getName(), ChatColor.WHITE + p.getName());
  121. this.saveConfig();
  122. }
  123. if (args[0].equalsIgnoreCase("colors")){
  124. p.sendMessage("§11 §r| §22 §r| §33 §r| §44 §r| §55 §r| §66 §r| §77 §r| §88 §r| §99 §r| §00 §r| §aa §r| §bb §r| §cc §r| §dd §r| §ee §r| §ff");
  125. }
  126. //-------------------------[ colors ]-------------------------//
  127. }
  128. }
  129. return true;
  130. }
  131. @EventHandler
  132. public void onPlayerChat(AsyncPlayerChatEvent e) {
  133. if (this.getConfig().getString(e.getPlayer().getName()) != null) {
  134. e.getPlayer().setDisplayName(this.getConfig().getString(e.getPlayer().getName()) + ChatColor.RESET);
  135. e.setFormat(ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix").replace("%p", e.getPlayer().getDisplayName()))+ ChatColor.RESET + ChatColor.translateAlternateColorCodes('&', e.getMessage()));
  136. }
  137. }
  138. @EventHandler
  139. public void player (PlayerJoinEvent t) {
  140. if (this.getConfig().getString(t.getPlayer().getName()) != null) {
  141. t.getPlayer().setPlayerListName(this.getConfig().getString(t.getPlayer().getName()) + ChatColor.RESET);
  142. }
  143.  
  144. }
  145. }
Advertisement
Add Comment
Please, Sign In to add comment