Guest User

Untitled

a guest
Oct 24th, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.67 KB | None | 0 0
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package cmds;
  7.  
  8. import java.io.File;
  9. import java.io.IOException;
  10. import java.util.HashMap;
  11. import java.util.Iterator;
  12. import java.util.UUID;
  13. import net.md_5.bungee.BungeeCord;
  14. import net.md_5.bungee.api.CommandSender;
  15. import net.md_5.bungee.api.chat.ClickEvent;
  16. import net.md_5.bungee.api.chat.TextComponent;
  17. import net.md_5.bungee.api.chat.ClickEvent.Action;
  18. import net.md_5.bungee.api.connection.ProxiedPlayer;
  19. import net.md_5.bungee.api.plugin.Command;
  20. import org.bukkit.configuration.file.YamlConfiguration;
  21. import p1.Report.Class;
  22.  
  23. public class Report extends Command {
  24. private HashMap<UUID, Long> time = new HashMap();
  25. private int cooldown = 120000;
  26. public static String type = null;
  27. public static String msg = "";
  28. public static File file = new File("plugins//SchillerBungeeMain", "Reports");
  29. public static YamlConfiguration cfg;
  30.  
  31. static {
  32. cfg = YamlConfiguration.loadConfiguration(file);
  33. }
  34.  
  35. public Report(String name) {
  36. super(name);
  37. }
  38.  
  39. public void execute(CommandSender cs, String[] args) {
  40. if(cs instanceof ProxiedPlayer) {
  41. ProxiedPlayer p = (ProxiedPlayer)cs;
  42. if(!p.hasPermission("report.use")) {
  43. p.sendMessage(new TextComponent(Class.prefix + "Keine Permission: REPORT.USE"));
  44. return;
  45. }
  46.  
  47. if(args.length == 0 || args.length == 1 || args.length == 2 || args.length <= 3) {
  48. p.sendMessage(new TextComponent(Class.prefix + "/report <Spieler> <Typ> <Grund>"));
  49. p.sendMessage(new TextComponent(Class.prefix + "Verfügbare Reporttypen: bug, hacker, anderes"));
  50. return;
  51. }
  52.  
  53. if(args.length == 3) {
  54. ProxiedPlayer t = BungeeCord.getInstance().getPlayer(args[0]);
  55. String person = cfg.getString("report." + args[0] + ".person");
  56. if(person == t.getName()) {
  57. p.sendMessage(new TextComponent(Class.prefix + "Der Spieler wurde bereits gemeldet."));
  58. return;
  59. }
  60.  
  61. String server = t.getServer().getInfo().getName();
  62. if(person == t.getName()) {
  63. if(t == null || !t.isConnected()) {
  64. p.sendMessage(new TextComponent(Class.prefix + "Der Spieler " + t + " ist nicht online."));
  65. return;
  66. }
  67.  
  68. if(t != null && t.isConnected()) {
  69. if(!this.canReport(p.getUniqueId())) {
  70. double var16 = (double)Math.round((float)((((Long)this.time.get(p.getUniqueId())).longValue() + (long)this.cooldown - System.currentTimeMillis()) / 1000L * 100L));
  71. p.sendMessage(new TextComponent(Class.prefix + "Du kannst einen neuen Spieler in " + var16 / 100.0D + " Sekunden melden!"));
  72. return;
  73. }
  74.  
  75. if(this.canReport(p.getUniqueId())) {
  76. if(args[1].equalsIgnoreCase("bug")) {
  77. type = "Bug";
  78. } else if(args[1].equalsIgnoreCase("hacker")) {
  79. type = "Hacker";
  80. } else if(args[1].equalsIgnoreCase("anderes")) {
  81. type = "Anderes";
  82. } else {
  83. p.sendMessage(new TextComponent(Class.prefix + "Du hast einen falschen Typ angegeben"));
  84. }
  85. }
  86.  
  87. if(type == null || type.isEmpty()) {
  88. p.sendMessage(new TextComponent(Class.prefix + "Du musst einen Typ angeben."));
  89. return;
  90. }
  91.  
  92. if(type != null && !type.isEmpty()) {
  93. this.time.put(p.getUniqueId(), Long.valueOf(System.currentTimeMillis()));
  94.  
  95. for(int pp = 2; pp < args.length; ++pp) {
  96. msg = msg + args[pp] + " ";
  97. }
  98.  
  99. if(msg != null && !msg.isEmpty()) {
  100. msg = msg.substring(0, msg.length() - 1);
  101. }
  102.  
  103. p.sendMessage(new TextComponent(Class.prefix + "Danke für deinen Report. Senden..."));
  104. p.sendMessage(new TextComponent(Class.prefix + "Dein Report wurde gesendet!"));
  105. cfg.addDefault("report." + args[0] + ".sender", p.getName());
  106. cfg.options().copyDefaults(true);
  107.  
  108. try {
  109. cfg.save(file);
  110. } catch (IOException var14) {
  111. var14.printStackTrace();
  112. }
  113.  
  114. cfg.addDefault("report." + args[0] + ".person", t.getName());
  115. cfg.options().copyDefaults(true);
  116.  
  117. try {
  118. cfg.save(file);
  119. } catch (IOException var13) {
  120. var13.printStackTrace();
  121. }
  122.  
  123. cfg.addDefault("report." + args[0] + ".server", server);
  124. cfg.options().copyDefaults(true);
  125.  
  126. try {
  127. cfg.save(file);
  128. } catch (IOException var12) {
  129. var12.printStackTrace();
  130. }
  131.  
  132. cfg.addDefault("report." + args[0] + ".typ", type);
  133. cfg.options().copyDefaults(true);
  134.  
  135. try {
  136. cfg.save(file);
  137. } catch (IOException var11) {
  138. var11.printStackTrace();
  139. }
  140.  
  141. cfg.addDefault("report." + args[0] + ".grund", msg);
  142. cfg.options().copyDefaults(true);
  143.  
  144. try {
  145. cfg.save(file);
  146. } catch (IOException var10) {
  147. var10.printStackTrace();
  148. }
  149.  
  150. Iterator var8 = BungeeCord.getInstance().getPlayers().iterator();
  151.  
  152. while(var8.hasNext()) {
  153. ProxiedPlayer var15 = (ProxiedPlayer)var8.next();
  154. if(var15.hasPermission("report.getnot")) {
  155. var15.sendMessage(new TextComponent(Class.prefix + "Es ist ein neuer Report eingegangen:"));
  156. TextComponent st = new TextComponent("[Klicken zum Bearbeiten]");
  157. st.setClickEvent(new ClickEvent(Action.RUN_COMMAND, "/srep " + t.getName()));
  158. var15.sendMessage(st);
  159. }
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166.  
  167. }
  168.  
  169. private boolean canReport(UUID uuid) {
  170. if(this.time.containsKey(uuid)) {
  171. long current = System.currentTimeMillis();
  172. return ((Long)this.time.get(uuid)).longValue() + (long)this.cooldown <= current;
  173. } else {
  174. return false;
  175. }
  176. }
  177. }
Advertisement
Add Comment
Please, Sign In to add comment