Guest User

CommandEvent.java | GCNT Development

a guest
May 19th, 2019
72
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2. //for (String s : CommandsFile.get().getCommands()) {
  3. if (CommandsFile.get().getCommands().contains(e.getMessage().replace("/", ""))) {
  4. e.getPlayer().sendMessage("DEBUG: 1");
  5. String s = e.getMessage().replace("/", "");
  6. e.setCancelled(true);
  7. if (CommandsFile.get().getPermission(s).equals("null") || e.getPlayer().hasPermission(CommandsFile.get().getPermission(s))) {
  8. if (CommandsFile.get().getCooldown(s) > 0 && getCooldown(e.getPlayer(), s) > 0) {
  9. // cooldown
  10.  
  11. String timer = "";
  12. String s1 = "0";
  13. String m = "0";
  14. String h = "0";
  15. long tmr = getCooldown(e.getPlayer(), s) / 20;
  16. s1 = String.valueOf(tmr % 60);
  17. m = String.valueOf((int) Math.floor(tmr / 60));
  18. h = String.valueOf((int) Math.floor(tmr / 3600));
  19.  
  20. if (Integer.valueOf(h) > 0) {
  21. timer = h + "h";
  22. }
  23. if (Integer.valueOf(m) > 0) {
  24. if (!timer.isEmpty()) {
  25. timer += " " + m + "m";
  26. } else {
  27. timer = m + "m";
  28. }
  29. }
  30. if (Integer.valueOf(s1) > 0) {
  31. if (!timer.isEmpty()) {
  32. timer += " " + s1 + "s";
  33. } else {
  34. timer = s1 + "s";
  35. }
  36. }
  37.  
  38.  
  39. e.getPlayer().sendMessage(Utils.get().c(CommandsFile.get().getCooldownMessage(s).replace("%time%", timer)));
  40. return;
  41. }
  42.  
  43. List<String> actions = CommandsFile.get().getActions(s);
  44. EventActions ea = new EventActions(e.getPlayer());
  45. String[] pargs = e.getMessage().split(" ");
  46. String[] args = s.split(" ");
  47. if (args.length > 1) {
  48. for (int i = 1; i < args.length; i++) {
  49. if (args[i].equalsIgnoreCase("{player}")) {
  50. if (Bukkit.getPlayer(pargs[i]) == null) {
  51. e.getPlayer().sendMessage(ChatColor.RED + "Player '" + pargs[i] + "' is not online");
  52. return;
  53. }
  54. } else if (args[i].equalsIgnoreCase("{integer}")) {
  55. if (!Utils.get().isInt(pargs[i])) {
  56. e.getPlayer().sendMessage(ChatColor.RED + "'" + pargs[i] + "' is not an integer");
  57. return;
  58. }
  59. } else if (args[i].equalsIgnoreCase("{double}")) {
  60. if (!Utils.get().isDouble(pargs[i])) {
  61. e.getPlayer().sendMessage(ChatColor.RED + "'" + pargs[i] + "' is not a double");
  62. return;
  63. }
  64. }
  65. }
  66. }
  67.  
  68. for (int i = 0; i < actions.size(); i++) {
  69. String s1 = actions.get(i);
  70. ea.addAction(s1);
  71. if (s1.toLowerCase().contains("[everyone]") ||
  72. s1.toLowerCase().contains("[iedereen]")) {
  73. for (Player p : Bukkit.getOnlinePlayers()) {
  74. ea.addPlayerToAction(p, i);
  75. }
  76. } else {
  77. ea.addPlayerToAction(e.getPlayer(), i);
  78. }
  79. }
  80.  
  81. if (args.length > 1) {
  82. for (int i = 1; i < args.length; i++) {
  83. ea.addCustomPlaceholder("{arg" + i + "}", pargs[i]);
  84. }
  85. }
  86.  
  87. ea.perform();
  88.  
  89. if (CommandsFile.get().getCooldown(s) > 0) {
  90. setCooldown(e.getPlayer(), s, CommandsFile.get().getCooldown(s));
  91. }
  92. return;
  93. } else {
  94. e.getPlayer().sendMessage(Utils.get().c(CommandsFile.get().getNoPermissionMessage(s)));
  95. return;
  96. }
  97. }
  98. else {
  99. String[] pargs = e.getMessage().replaceFirst("/", "").split(" ");
  100.  
  101. for (String s : CommandsFile.get().getCommands()) {
  102. String[] args = s.split(" ");
  103. if (args[0].equalsIgnoreCase(pargs[0]) && pargs.length == args.length) {
  104. e.setCancelled(true);
  105. performCommand(s, e.getPlayer(), e.getMessage());
  106. return;
  107. } else if (args[0].equalsIgnoreCase(pargs[0]) && pargs.length != args.length) {
  108. /*for (String a : CommandsFile.get().getCommands()) {
  109. String[] arg = a.split(" ");
  110. if (a.startsWith(args[0]) && Utils.get().hasCommandArgument(a) && !a.equals(s)) {
  111. for (int i=0;i<pargs.length;i++) {
  112. if (pargs[i].equalsIgnoreCase(arg[i])) {
  113. //
  114. }
  115. }
  116. }
  117. }*/
  118. }
  119. }
  120. }
  121.  
  122. for (Menu menu : MenuFile.getMenus(e.getPlayer())) {
  123. if (StringUtils.equalsIgnoreCase(e.getMessage(), "/"+ menu.getOpenCommand())) {
  124. if (menu.getPermission().equals("null") || e.getPlayer().hasPermission(menu.getPermission())) {
  125. e.setCancelled(true);
  126. menu.open(e.getPlayer());
  127. }
  128. else {
  129. e.setCancelled(true);
  130. e.getPlayer().sendMessage(menu.getNoPermission());
  131. }
  132. }
  133. }
  134. }
RAW Paste Data