Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.51 KB | None | 0 0
  1. package nl.marcooo.naam;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandExecutor;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9.  
  10. public class NickCommand implements CommandExecutor {
  11.  
  12. String prefix = ChatColor.GRAY + "[" + ChatColor.DARK_AQUA + "Nick" + ChatColor.GRAY + "] ";
  13.  
  14. @Override
  15. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
  16. if(cmd.getName().equalsIgnoreCase("nick")){
  17. if(!(sender instanceof Player)){
  18. sender.sendMessage("'/nick' can only be used by players!!"); return true;
  19. }
  20. Player player = (Player) sender;
  21. if(args.length == 0){
  22. player.sendMessage(prefix + ChatColor.GREEN + "Help Menu:");
  23. player.sendMessage(prefix + ChatColor.AQUA + "/nick set (<player>) " + ChatColor.GRAY + "- " + ChatColor.GREEN + "Set the nick of you/a player.");
  24. player.sendMessage(prefix + ChatColor.AQUA + "/nick check (<player>) " + ChatColor.GRAY + "- " + ChatColor.GREEN + "Check if you/a player has a nick.");
  25. player.sendMessage(prefix + ChatColor.AQUA + "/nick reset (<player>) " + ChatColor.GRAY + "- " + ChatColor.GREEN + "Reset your/a players nick.");
  26. }else{
  27. if(args[0].equalsIgnoreCase("set")){
  28. if(args.length == 1){
  29. player.sendMessage(prefix + ChatColor.RED + "Correct usage: /nick set <nick> (<player>)"); return true;
  30. }else{
  31. if(args.length == 2){
  32. if(player.hasPermission("nick.nick") || player.isOp()){
  33. Main.getMain().setNick(player, args[1]);
  34. player.sendMessage(prefix + ChatColor.GREEN + "You have changed your display name to " + ChatColor.GOLD + ChatColor.translateAlternateColorCodes('&', args[1]));
  35. }
  36. }else if(args.length == 3){
  37. if(player.hasPermission("nick.nick.other") || player.isOp()){
  38. Player c = Bukkit.getPlayer(args[2]);
  39. if(c != null){
  40. Main.getMain().setNick(c, args[1]);
  41. player.sendMessage(prefix + ChatColor.GREEN + "You have changed " + ChatColor.RED + c.getName() + ChatColor.GOLD + " nick to " + ChatColor.translateAlternateColorCodes('&', args[1]));
  42. }else{
  43. player.sendMessage(prefix + ChatColor.RED + "Cannot find player " + args[2] + "!");
  44. }
  45. }
  46. }
  47. }
  48. }else if(args[0].equalsIgnoreCase("check")){
  49. if(args.length == 1){
  50. if(player.hasPermission("nick.check")){
  51. if(Main.getMain().hasNick(player)){
  52. player.sendMessage(prefix + ChatColor.GREEN + "Your active nick is " + ChatColor.translateAlternateColorCodes('&', Main.getMain().getData().getString(player.getUniqueId().toString())));
  53. }else{
  54. player.sendMessage(prefix + ChatColor.GREEN + "You do not have a active nick.");
  55. }
  56. }
  57. }else if(args.length == 2){
  58. if(player.hasPermission("nick.check.other")){
  59. Player c = Bukkit.getPlayer(args[1]);
  60. if(c != null){
  61. if(Main.getMain().hasNick(c)){
  62. player.sendMessage(prefix + ChatColor.RED + c.getName() + ChatColor.GREEN + " active nick is " + ChatColor.translateAlternateColorCodes('&', Main.getMain().getData().getString(c.getUniqueId().toString())));
  63. }else{
  64. player.sendMessage(prefix + ChatColor.RED + c.getName() + ChatColor.GREEN + " does not have a active nick.");
  65. }
  66. }else{
  67. player.sendMessage(prefix + ChatColor.RED + "Cannot find player " + args[1] + "!");
  68. }
  69. }
  70. }
  71. }else if(args[0].equalsIgnoreCase("reset")){
  72. if(args.length == 1){
  73. if(player.hasPermission("nick.reset")){
  74. if(Main.getMain().hasNick(player)){
  75. Main.getMain().resetNick(player);
  76. player.sendMessage(prefix + ChatColor.GREEN + "Reseted you nick.");
  77. }else{
  78. player.sendMessage(prefix + ChatColor.RED + "You do not have nick.");
  79. }
  80. }
  81. }else if(args.length == 2){
  82. if(player.hasPermission("nick.reset.other")){
  83. Player c = Bukkit.getPlayer(args[1]);
  84. if(c != null){
  85. if(Main.getMain().hasNick(c)){
  86. Main.getMain().resetNick(c);
  87. player.sendMessage(prefix + ChatColor.GREEN + "Reseted " + ChatColor.RED + c.getName() + ChatColor.GREEN + "nick.");
  88. }else{
  89. player.sendMessage(prefix + ChatColor.RED + c.getName() + ChatColor.GREEN + " does not have a nick.");
  90. }
  91. }else{
  92. player.sendMessage(prefix + ChatColor.RED + "Cannot find player " + args[1] + "!");
  93. }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. return false;
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement