Guest User

Untitled

a guest
Jan 28th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. package com.knightzmc.basics;
  2.  
  3. import java.util.logging.Logger;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Location;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandExecutor;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.potion.PotionEffect;
  13. import org.bukkit.potion.PotionEffectType;
  14.  
  15. import net.milkbowl.vault.economy.Economy;
  16. import net.milkbowl.vault.economy.EconomyResponse;
  17.  
  18. public class KnightzMCCommandExecutor implements CommandExecutor{
  19. @SuppressWarnings("unused")
  20. private KnightzMCCommandExecutor plugin;
  21.  
  22. public KnightzMCCommandExecutor(KnightzMCBasics knightzMCBasics) {
  23. }
  24.  
  25. public void MyPluginCommandExecutor(KnightzMCCommandExecutor plugin) {
  26. this.plugin = plugin; // Store the plugin in situations where you need it.
  27. }
  28.  
  29. static String bold = ChatColor.BOLD + "";
  30. static String red = ChatColor.RED + "";
  31. static String gold = ChatColor.GOLD + "";
  32. static String aqua = ChatColor.AQUA + "";
  33. static String darkaqua = ChatColor.DARK_AQUA + "";
  34. Economy econ = KnightzMCBasics.econ;
  35. private static final Logger log = Logger.getLogger("Minecraft");
  36.  
  37. @SuppressWarnings("deprecation")
  38. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  39. if (!(sender instanceof Player)) {
  40. log.info("Only players can use this command!");
  41. return true;
  42. }
  43. Player player = (Player) sender;
  44. if(cmd.getLabel().equalsIgnoreCase("profits"))
  45. {
  46. if (player.hasPermission("knightzmc.farmer")) {
  47. for (Player allplayers : Bukkit.getOnlinePlayers()) {
  48. allplayers.sendMessage(
  49. aqua + bold + sender.getName() + gold + bold + " has chosen to give everyone $5000!");
  50. ;
  51. EconomyResponse r = econ.depositPlayer(allplayers, 5000);
  52. allplayers.sendMessage(
  53. String.format(gold + "Your balance is now: " + aqua + "%s", econ.format(r.balance)));
  54. }
  55. }
  56. if (player.hasPermission("knightzmc.merchant")) {
  57. for (Player allplayers : Bukkit.getOnlinePlayers()) {
  58. allplayers.sendMessage(
  59. aqua + bold + sender.getName() + gold + bold + " has chosen to give everyone $8000!");
  60. ;
  61. EconomyResponse r = econ.depositPlayer(allplayers, 8000);
  62. allplayers.sendMessage(
  63. String.format(gold + "Your balance is now: " + aqua + "%s", econ.format(r.balance)));
  64. }
  65. } else
  66. player.sendMessage(gold + "You need a rank to use this command!");
  67. }
  68. if (cmd.getLabel().equalsIgnoreCase("forum")) {
  69. sender.sendMessage(gold + "Forums: " + aqua + "http://forum.knightzmc.com");
  70. }
  71. if (cmd.getName().equalsIgnoreCase("hint")) {
  72. int hintnumber = (int) (Math.random() * 2);
  73. if (hintnumber == 0) {
  74. player.sendMessage(
  75. ChatColor.GOLD + bold + "Hint 1: " + ChatColor.AQUA + bold + "Manual Labor is good for you");
  76. }
  77. if (hintnumber == 1) {
  78. player.sendMessage(ChatColor.GOLD + bold + "Hint 2: " + ChatColor.AQUA + bold
  79. + "You shouldn't be afraid of Ender Pearls. Or cobwebs.");
  80. }
  81. if (hintnumber == 2) {
  82. player.sendMessage(ChatColor.GOLD + bold + "Hint 3: " + ChatColor.AQUA + bold
  83. + "You should be careful in prisons. Always watch your back.");
  84. }
  85. ;
  86. }
  87. if (cmd.getName().equalsIgnoreCase("superheal")) {
  88. if (player.hasPermission("knightzmc.superheal")) {
  89. if (args.length == 1) {
  90. if (args[0].equalsIgnoreCase("on")) {
  91. player.setMaxHealth(1500);
  92. player.setHealth(1500);
  93. player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 1000000, 255));
  94. } else if (args[0].equalsIgnoreCase("off")) {
  95. player.setMaxHealth(20);
  96. player.setHealth(20);
  97. player.removePotionEffect(PotionEffectType.REGENERATION);
  98. } else
  99. player.sendMessage(ChatColor.GOLD + "Usage: " + ChatColor.GREEN + "/superheal on/off");
  100. } else
  101. player.sendMessage(ChatColor.GOLD + "Usage: " + ChatColor.GREEN + "/superheal on/off");
  102. }
  103.  
  104. else
  105. player.sendMessage(
  106. ChatColor.GOLD + "Sorry, you don't have permission to use " + ChatColor.GREEN + commandLabel);
  107. }
  108. if (cmd.getName().equalsIgnoreCase("randomtp")) {
  109. int randomx = (int) (Math.random() * 100000);
  110. int randomz = (int) (Math.random() * 100000);
  111. int randomy = player.getWorld().getHighestBlockYAt(randomx, randomz);
  112.  
  113. Location randomLocation = new Location(player.getWorld(), randomx, randomy, randomz);
  114. player.teleport(randomLocation);
  115. player.sendMessage(
  116. ChatColor.GOLD + "You were teleported to X: " + ChatColor.GREEN + randomx + ChatColor.GOLD + " Y: "
  117. + ChatColor.GREEN + randomy + ChatColor.GOLD + " Z: " + ChatColor.GREEN + randomz);
  118. }
  119. return true;
  120. }
  121. }
Add Comment
Please, Sign In to add comment