Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.05 KB | None | 0 0
  1. package me.Vextricity.sReport;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.plugin.Plugin;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13. public class newMain extends JavaPlugin
  14.  
  15. {
  16.  
  17. public HashMap<String, Long> cooldowns = new HashMap<String, Long>();
  18.  
  19. public void onEnable()
  20.  
  21. {
  22.  
  23. Bukkit.getServer().getLogger().info("sReport has been enabled!");
  24. Bukkit.getServer().getLogger().info("sReport made by Vextricity!");
  25.  
  26. }
  27.  
  28. public void onDisable()
  29.  
  30. {
  31.  
  32. Bukkit.getServer().getLogger().info("sReport has been disabled!");
  33.  
  34. }
  35.  
  36.  
  37.  
  38. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
  39.  
  40. {
  41.  
  42. if (!(sender instanceof Player))
  43.  
  44. {
  45.  
  46. Bukkit.getServer().getLogger().info("You must be a player to run this command!");
  47.  
  48. }
  49.  
  50. else
  51.  
  52. {
  53.  
  54. Player player = (Player) sender;
  55.  
  56. if (cmd.getName().equalsIgnoreCase("report"))
  57.  
  58. {
  59.  
  60. if (player.hasPermission("sreport.report"))
  61.  
  62. {
  63.  
  64. if (args.length == 1)
  65.  
  66. {
  67.  
  68. if (args[0].equalsIgnoreCase("reload"))
  69.  
  70. {
  71.  
  72. if (player.hasPermission("sreport.reload"))
  73.  
  74. {
  75.  
  76. Plugin plugin = this.getServer().getPluginManager().getPlugin("sReport");
  77.  
  78. getConfig();
  79. saveConfig();
  80. this.getServer().getPluginManager().disablePlugin(plugin);
  81. this.getServer().getPluginManager().enablePlugin(plugin);
  82.  
  83. player.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "This plugin has been reloaded!");
  84.  
  85.  
  86. }
  87.  
  88. else
  89.  
  90. {
  91.  
  92. player.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "You do not have permission to do this!");
  93.  
  94. }
  95.  
  96. }
  97.  
  98. else
  99.  
  100. {
  101.  
  102. player.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "Invalid Argument! Do /report <playername> <reason>");
  103.  
  104. }
  105.  
  106. }
  107.  
  108. else if (args.length == 0)
  109.  
  110. {
  111.  
  112. player.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "Invalid Argument! Do /report <playername> <reason>");
  113.  
  114. }
  115.  
  116. else if (args.length > 6)
  117.  
  118. {
  119.  
  120. player.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "This plugin doesn't currently support arguments that long!");
  121.  
  122. }
  123.  
  124. else
  125.  
  126. {
  127.  
  128. if (args.length == 2)
  129.  
  130. {
  131.  
  132. int cooldownTime = getConfig().getInt("cooldownInSeconds");
  133.  
  134. if (cooldowns.containsKey(sender.getName()))
  135.  
  136. {
  137.  
  138. long secondsLeft = ((cooldowns.get(sender.getName())/1000)+cooldownTime) - (System.currentTimeMillis()/1000);
  139.  
  140. if (secondsLeft > 0)
  141.  
  142. {
  143.  
  144. sender.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "You can't use this command for another " + ChatColor.DARK_RED + secondsLeft + ChatColor.RED + " seconds!");
  145.  
  146. return true;
  147.  
  148. }
  149.  
  150. }
  151.  
  152. cooldowns.put(sender.getName(), System.currentTimeMillis());
  153.  
  154. if (args[0].equals(args[0]))
  155.  
  156. {
  157.  
  158. if (args[1].equals(args[1]))
  159.  
  160. {
  161.  
  162. player.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "You have reported " + args[0] + " for " + args[1] + "! This player will be dealt with.");
  163.  
  164. for (Player p : Bukkit.getServer().getOnlinePlayers())
  165.  
  166. {
  167.  
  168. if (p.hasPermission("sreport.recieve"))
  169.  
  170. {
  171.  
  172. p.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + args[0] + " has been reported for " + args[1] + "!");
  173.  
  174. }
  175.  
  176. }
  177.  
  178. }
  179.  
  180. }
  181.  
  182. }
  183.  
  184. else if (args.length == 3)
  185.  
  186. {
  187.  
  188. int cooldownTime = getConfig().getInt("cooldownInSeconds");
  189.  
  190. if (cooldowns.containsKey(sender.getName()))
  191.  
  192. {
  193.  
  194. long secondsLeft = ((cooldowns.get(sender.getName())/1000)+cooldownTime) - (System.currentTimeMillis()/1000);
  195.  
  196. if (secondsLeft > 0)
  197.  
  198. {
  199.  
  200. sender.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "You can't use this command for another " + ChatColor.DARK_RED + secondsLeft + ChatColor.RED + " seconds!");
  201.  
  202. return true;
  203.  
  204. }
  205.  
  206. }
  207.  
  208. cooldowns.put(sender.getName(), System.currentTimeMillis());
  209.  
  210. if (args[0].equals(args[0]))
  211.  
  212. {
  213.  
  214. if (args[1].equals(args[1]))
  215.  
  216. {
  217.  
  218. if (args[2].equals(args[2]))
  219.  
  220. {
  221.  
  222. player.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "You have reported " + args[0] + " for " + args[1] + " " + args[2] + "! This player will be dealt with.");
  223.  
  224. for (Player p : Bukkit.getServer().getOnlinePlayers())
  225.  
  226. {
  227.  
  228. if (p.hasPermission("sreport.recieve"))
  229.  
  230. {
  231.  
  232. p.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + args[0] + " has been reported for " + args[1] + " " + args[2] + "!");
  233.  
  234. }
  235.  
  236. }
  237.  
  238. }
  239.  
  240. }
  241.  
  242. }
  243.  
  244. }
  245.  
  246. else if (args.length == 4)
  247.  
  248. {
  249.  
  250. int cooldownTime = getConfig().getInt("cooldownInSeconds");
  251.  
  252. if (cooldowns.containsKey(sender.getName()))
  253.  
  254. {
  255.  
  256. long secondsLeft = ((cooldowns.get(sender.getName())/1000)+cooldownTime) - (System.currentTimeMillis()/1000);
  257.  
  258. if (secondsLeft > 0)
  259.  
  260. {
  261.  
  262. sender.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "You can't use this command for another " + ChatColor.DARK_RED + secondsLeft + ChatColor.RED + " seconds!");
  263.  
  264. return true;
  265.  
  266. }
  267.  
  268. }
  269.  
  270. cooldowns.put(sender.getName(), System.currentTimeMillis());
  271.  
  272. if (args[0].equals(args[0]))
  273.  
  274. {
  275.  
  276. if (args[1].equals(args[1]))
  277.  
  278. {
  279.  
  280. if (args[2].equals(args[2]))
  281.  
  282. {
  283.  
  284. if (args[3].equals(args[3]))
  285.  
  286. {
  287.  
  288. player.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + args[0] + " has been reported for " + args[1] + " " + args[2] + " " + args[3] + "! This player will be dealt with.");
  289.  
  290. for (Player p : Bukkit.getServer().getOnlinePlayers())
  291.  
  292. {
  293.  
  294. if (p.hasPermission("sreport.recieve"))
  295.  
  296. {
  297.  
  298. p.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + args[0] + " has been reported for " + args[1] + " " + args[2] + " " + args[3] + "!");
  299.  
  300. }
  301.  
  302. }
  303.  
  304. }
  305.  
  306. }
  307.  
  308. }
  309.  
  310. }
  311.  
  312. }
  313.  
  314. else if (args.length == 5)
  315.  
  316. {
  317.  
  318. int cooldownTime = getConfig().getInt("cooldownInSeconds");
  319.  
  320. if (cooldowns.containsKey(sender.getName()))
  321.  
  322. {
  323.  
  324. long secondsLeft = ((cooldowns.get(sender.getName())/1000)+cooldownTime) - (System.currentTimeMillis()/1000);
  325.  
  326. if (secondsLeft > 0)
  327.  
  328. {
  329.  
  330. sender.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "You can't use this command for another " + ChatColor.DARK_RED + secondsLeft + ChatColor.RED + " seconds!");
  331.  
  332. return true;
  333.  
  334. }
  335.  
  336. }
  337.  
  338. cooldowns.put(sender.getName(), System.currentTimeMillis());
  339.  
  340. if (args[1].equals(args[1]))
  341.  
  342. {
  343.  
  344. if (args[2].equals(args[2]))
  345.  
  346. {
  347.  
  348. if (args[3].equals(args[3]))
  349.  
  350. {
  351.  
  352. if (args[4].equals(args[4]))
  353.  
  354. {
  355.  
  356. player.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + args[0] + " has been reported for " + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + "! This player will be dealt with.");
  357.  
  358. for (Player p : Bukkit.getServer().getOnlinePlayers())
  359.  
  360. {
  361.  
  362. if (p.hasPermission("sreport.recieve"))
  363.  
  364. {
  365.  
  366. p.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + args[0] + " has been reported for " + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + "!");
  367.  
  368. }
  369.  
  370. }
  371.  
  372. }
  373.  
  374. }
  375.  
  376. }
  377.  
  378. }
  379.  
  380. }
  381.  
  382. else if (args.length == 6)
  383.  
  384. {
  385.  
  386. int cooldownTime = getConfig().getInt("cooldownInSeconds");
  387.  
  388. if (cooldowns.containsKey(sender.getName()))
  389.  
  390. {
  391.  
  392. long secondsLeft = ((cooldowns.get(sender.getName())/1000)+cooldownTime) - (System.currentTimeMillis()/1000);
  393.  
  394. if (secondsLeft > 0)
  395.  
  396. {
  397.  
  398. sender.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + "You can't use this command for another " + ChatColor.DARK_RED + secondsLeft + ChatColor.RED + " seconds!");
  399.  
  400. return true;
  401.  
  402. }
  403.  
  404. }
  405.  
  406. cooldowns.put(sender.getName(), System.currentTimeMillis());
  407.  
  408. if (args[1].equals(args[1]))
  409.  
  410. {
  411.  
  412. if (args[2].equals(args[2]))
  413.  
  414. {
  415.  
  416. if (args[3].equals(args[3]))
  417.  
  418. {
  419.  
  420. if (args[4].equals(args[4]))
  421.  
  422. {
  423.  
  424. if (args[5].equals(args[5]))
  425.  
  426. {
  427.  
  428. player.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + args[0] + " has been reported for " + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + "! This player will be dealt with.");
  429.  
  430. for (Player p : Bukkit.getServer().getOnlinePlayers())
  431.  
  432. {
  433.  
  434. if (p.hasPermission("sreport.recieve"))
  435.  
  436. {
  437.  
  438. p.sendMessage(ChatColor.DARK_RED + "[sReport] " + ChatColor.RED + args[0] + " has been reported for " + args[1] + " " + args[2] + " " + args[3] + " " + args[4] + " " + args[5] + "!");
  439.  
  440. }
  441.  
  442. }
  443.  
  444. }
  445.  
  446. }
  447.  
  448. }
  449.  
  450. }
  451.  
  452. }
  453.  
  454. }
  455.  
  456. }
  457.  
  458. }
  459.  
  460. else
  461.  
  462. {
  463.  
  464. player.sendMessage(ChatColor.RED + "You do not have permission to do this!");
  465.  
  466. }
  467.  
  468. }
  469.  
  470. }
  471.  
  472. return false;
  473.  
  474. }
  475.  
  476. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement