Advertisement
Guest User

Untitled

a guest
May 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. package com.commented.reclaim;
  2.  
  3. import org.bukkit.plugin.java.*;
  4. import org.bukkit.command.*;
  5. import org.bukkit.entity.*;
  6. import org.bukkit.*;
  7. import org.bukkit.configuration.file.*;
  8. import java.util.*;
  9.  
  10. public class Main extends JavaPlugin
  11. {
  12. private static Main plugin;
  13. List<String> used;
  14.  
  15. public Main() {
  16. this.used = new ArrayList<String>();
  17. }
  18.  
  19. public static Main getPlugin() {
  20. return Main.plugin;
  21. }
  22.  
  23. public void onEnable() {
  24. (Main.plugin = this).saveDefaultConfig();
  25. }
  26.  
  27. public boolean onCommand(final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) {
  28. if (sender instanceof Player) {
  29. final Player p = (Player)sender;
  30. final FileConfiguration config = this.getConfig();
  31. String groupName = VaultChecker.getVaultPermission().getPlayerGroups(p)[0];
  32. final String redeemedPlayers = "Reclaim.redeemedPlayers.";
  33. final String groups = "Reclaim.groups.";
  34. if (commandLabel.equalsIgnoreCase("reclaim")) {
  35. if (config.getString(String.valueOf(groups) + groupName) == null) {
  36. p.sendMessage(ChatColor.RED + "You dont have anything to reclaim!");
  37. }
  38. else {
  39. if (config.getStringList(String.valueOf(redeemedPlayers) + groupName) != null) {
  40. this.used.addAll(config.getStringList(String.valueOf(redeemedPlayers) + groupName));
  41. }
  42. if (this.used.contains(p.getName().toLowerCase())) {
  43. p.sendMessage(ChatColor.RED + "You have already reclaimed your rewards.");
  44. }
  45. else {
  46. this.used.add(p.getName().toUpperCase());
  47. config.set(String.valueOf(redeemedPlayers) + groupName, (Object)this.used);
  48. this.saveConfig();
  49. for (final String reclaimCommand : config.getStringList(String.valueOf(groups) + groupName)) {
  50. Bukkit.getServer().dispatchCommand((CommandSender)Bukkit.getConsoleSender(), reclaimCommand.replace("{PLAYER}", p.getName()));
  51. }
  52. if (config.getBoolean("Broadcast")) {
  53. Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', config.getString("Message").replace("{PLAYER}", p.getName()).replace("{GROUP}", groupName)));
  54. }
  55. }
  56. }
  57. }
  58. if (commandLabel.equalsIgnoreCase("resetreclaim")) {
  59. if (args.length == 0) {
  60. sender.sendMessage(ChatColor.RED + "Usage: /resetreclaim <player>");
  61. }
  62. else if (args.length >= 1) {
  63. if (sender.hasPermission("reclaim.reset")) {
  64. groupName = VaultChecker.getVaultPermission().getPlayerGroups(Bukkit.getPlayer(args[0]))[0];
  65. if (this.used.contains(args[0].toLowerCase())) {
  66. this.used.remove(args[0].toLowerCase());
  67. this.used.remove(args[0].toLowerCase());
  68. config.set(String.valueOf(redeemedPlayers) + groupName, (Object)this.used);
  69. config.set(String.valueOf(redeemedPlayers) + groupName, (Object)this.used);
  70. this.saveConfig();
  71. sender.sendMessage(ChatColor.GREEN + "You have reset " + ChatColor.YELLOW + args[0] + ChatColor.GREEN + " reclaims.");
  72. }
  73. else {
  74. sender.sendMessage(ChatColor.YELLOW + args[0] + ChatColor.GREEN + " has no reclaims.");
  75. }
  76. }
  77. else {
  78. sender.sendMessage(ChatColor.RED + "You don't have permission for this command.");
  79. }
  80. }
  81. }
  82. if (sender.hasPermission("reclaim.reload")) {
  83. if (args[0].equalsIgnoreCase("reload")) {
  84. this.reloadConfig();
  85. sender.sendMessage(ChatColor.GREEN + "You have reloaded the config.");
  86. }
  87. }
  88. else {
  89. sender.sendMessage(ChatColor.RED + "You don't have permission for this command.");
  90. }
  91. }
  92. {
  93. }
  94. return false;
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement