Advertisement
Guest User

Untitled

a guest
Oct 14th, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.40 KB | None | 0 0
  1. package cpr.core;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.command.Command;
  5. import org.bukkit.command.CommandSender;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.plugin.java.JavaPlugin;
  8. import org.bukkit.potion.PotionEffect;
  9. import org.bukkit.potion.PotionEffectType;
  10.  
  11. public class Main extends JavaPlugin {
  12.  
  13. public void onEnable() {
  14. getConfig().options().copyDefaults(true);
  15. saveDefaultConfig();
  16. }
  17.  
  18. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  19. Player p = (Player) sender;
  20. if (cmd.getName().equalsIgnoreCase("NightVision")) {
  21. if (!sender.hasPermission("cmdpotion.nightvision")) {
  22. sender.sendMessage(ChatColor.DARK_RED + "You do not have access to tha command!");
  23. return true;
  24. }
  25.  
  26. if (!(sender instanceof Player)) {
  27. sender.sendMessage("Only players can use this command!");
  28. return true;
  29. }
  30.  
  31. if (args.length < 1) {
  32.  
  33. for (String st : getConfig().getStringList("NightVisionInvalid"))
  34. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  35. return true;
  36.  
  37. } else if (args[0].equalsIgnoreCase("on")) {
  38.  
  39. for (String st : getConfig().getStringList("NightVisionOn"))
  40. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  41. p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1));
  42.  
  43. } else if (args[0].equalsIgnoreCase("off")) {
  44.  
  45. for (String st : getConfig().getStringList("NightVisionOff"))
  46. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  47. p.removePotionEffect(PotionEffectType.NIGHT_VISION);
  48.  
  49. } else {
  50.  
  51. for (String st : getConfig().getStringList("NightVisionInvalid"))
  52. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  53.  
  54. }
  55. }
  56.  
  57. if (cmd.getName().equalsIgnoreCase("speed")) {
  58. if (!sender.hasPermission("cmdpotion.speed")) {
  59. sender.sendMessage(ChatColor.DARK_RED + "You do not have access to tha command!");
  60. return true;
  61. }
  62.  
  63. if (!(sender instanceof Player)) {
  64. sender.sendMessage("Only players can use this command!");
  65. return true;
  66. }
  67.  
  68. if (args.length < 1) {
  69.  
  70. for (String st : getConfig().getStringList("SpeedInvalid"))
  71. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  72.  
  73. return true;
  74.  
  75. } else if (args[0].equalsIgnoreCase("on")) {
  76.  
  77. for (String st : getConfig().getStringList("SpeedOn"))
  78. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  79. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
  80.  
  81. } else if (args[0].equalsIgnoreCase("off")) {
  82.  
  83. for (String st : getConfig().getStringList("SpeedOff"))
  84. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  85. p.removePotionEffect(PotionEffectType.SPEED);
  86.  
  87. } else {
  88.  
  89. for (String st : getConfig().getStringList("SpeedInvalid"))
  90. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  91.  
  92. }
  93. }
  94.  
  95. if (cmd.getName().equalsIgnoreCase("haste")) {
  96. if (!sender.hasPermission("cmdpotion.haste")) {
  97. sender.sendMessage(ChatColor.DARK_RED + "You do not have access to tha command!");
  98. return true;
  99. }
  100.  
  101. if (!(sender instanceof Player)) {
  102. sender.sendMessage("Only players can use this command!");
  103. return true;
  104. }
  105.  
  106. if (args.length < 1) {
  107.  
  108. for (String st : getConfig().getStringList("HasteInvalid"))
  109. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  110.  
  111. return true;
  112.  
  113. } else if (args[0].equalsIgnoreCase("on")) {
  114.  
  115. for (String st : getConfig().getStringList("HasteOn"))
  116. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  117. p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 1));
  118.  
  119. } else if (args[0].equalsIgnoreCase("off")) {
  120.  
  121. for (String st : getConfig().getStringList("HasteOff"))
  122. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  123. p.removePotionEffect(PotionEffectType.FAST_DIGGING);
  124.  
  125. } else {
  126.  
  127. for (String st : getConfig().getStringList("HasteInvalid"))
  128. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  129.  
  130. }
  131. }
  132.  
  133. if (cmd.getName().equalsIgnoreCase("WaterBreathing")) {
  134. if (!sender.hasPermission("cmdpotion.waterbreathing")) {
  135. sender.sendMessage(ChatColor.DARK_RED + "You do not have access to tha command!");
  136. return true;
  137. }
  138.  
  139. if (!(sender instanceof Player)) {
  140. sender.sendMessage("Only players can use this command!");
  141. return true;
  142. }
  143.  
  144. if (args.length < 1) {
  145.  
  146. for (String st : getConfig().getStringList("WaterBreathingInvalid"))
  147. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  148.  
  149. return true;
  150.  
  151. } else if (args[0].equalsIgnoreCase("on")) {
  152.  
  153. for (String st : getConfig().getStringList("WaterBreathingOn"))
  154. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  155. p.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, Integer.MAX_VALUE, 1));
  156.  
  157. } else if (args[0].equalsIgnoreCase("off")) {
  158.  
  159. for (String st : getConfig().getStringList("WaterBreathingOff"))
  160. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  161. p.removePotionEffect(PotionEffectType.WATER_BREATHING);
  162.  
  163. } else {
  164.  
  165. for (String st : getConfig().getStringList("WaterBreathingInvalid"))
  166. p.sendMessage(ChatColor.translateAlternateColorCodes('&', st));
  167.  
  168. }
  169. }
  170. return false;
  171. }
  172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement