Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.41 KB | None | 0 0
  1. package Commands;
  2.  
  3. import java.io.IOException;
  4. import java.util.ArrayList;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.Location;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandExecutor;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.entity.Player;
  12.  
  13. import Files.Data;
  14. import me.roimeiqui.bapi.messages.MessageManager;
  15.  
  16.  
  17. public class MainCommands implements CommandExecutor{
  18.  
  19. public static Data data;
  20.  
  21. public static Data getData() {
  22. return data;
  23. }
  24. public static ArrayList<String> list = (ArrayList<String>) Data.fcdata.getStringList("Arenas");
  25. public static ArrayList<Player> players = new ArrayList<Player>();
  26. public static ArrayList<String> s = new ArrayList<String>();
  27. MessageManager mm = new MessageManager();
  28. String prefix = "§7[§3§lRCore§7] ";
  29. @SuppressWarnings("static-access")
  30. @Override
  31. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  32. if(cmd.getName().equalsIgnoreCase("join")) {
  33. if(sender instanceof Player) {
  34. Player pl = (Player)sender;
  35. int rest = players.size()-2;
  36. if(args.length == 1) {
  37. String nameArena = args[0];
  38. if(pl.hasPermission("rcore.join")) {
  39. if(players.contains(pl)) {
  40. mm.message(pl, prefix + "&cYou are already in an Arena!");
  41. return true;
  42. }
  43. if(!players.contains(pl)) {
  44. if(s.contains(nameArena)) {
  45. players.add(pl);
  46. if(players.size()!= 2) {
  47.  
  48. mm.message(pl, prefix + "&cQuedan &a" + rest + " &cjugadores");
  49. }else if(players.size()==2) {
  50. double x = Data.fcdata.getDouble(nameArena + "." + "spawn." + "coords." + "x");
  51. double y = Data.fcdata.getDouble(nameArena + "." + "spawn." + "coords." + "y");
  52. double z = Data.fcdata.getDouble(nameArena + "." + "spawn." + "coords." + "z");
  53. Location l = new Location(Bukkit.getWorld("world"), x, y, z);
  54. for(Player playersarena : Bukkit.getOnlinePlayers()) {
  55. if(players.contains(playersarena)) {
  56. if(players.size()!=2) {
  57. mm.message(playersarena, prefix + "&cQuedan &a" + rest + " &cjugadores");
  58. }
  59. mm.message(playersarena, prefix + "&aLa Arena va a comenzar!");
  60. mm.message(playersarena, prefix + "&aYou have been teleported to &c "+ x + y + z);
  61. pl.teleport(l);
  62. }
  63. }
  64.  
  65. }
  66.  
  67. }else {
  68. mm.message(pl, prefix + "&cThis arena doesen't exist: &7 " + nameArena);
  69. return true;
  70. }
  71. }else {
  72. mm.message(pl, prefix + "&cYou are already in an Arena!");
  73. return true;
  74. }
  75. }else {
  76. mm.message(pl, prefix + "&cYou dont have permissions to do this");
  77. }
  78. }else {
  79. mm.message(pl, prefix + "&cYou must to use: &7/join <Arena>");
  80. return true;
  81. }
  82. return true;
  83. }
  84. }if(cmd.getName().equalsIgnoreCase("leave")) {
  85. if(sender instanceof Player) {
  86. Player pl = (Player)sender;
  87. if(pl.hasPermission("rcore.leave")) {
  88. if(players.contains(pl)) {
  89. players.remove(pl);
  90. mm.message(pl, prefix + "&aYou leaved in the arena");
  91.  
  92. }else {
  93. mm.message(pl, prefix + "&CYou are not in a game");
  94. }
  95. }else {
  96. mm.message(pl, prefix + "&cYou dont have permissions to do this");
  97. }return true;
  98. }
  99. }else if(cmd.getName().equalsIgnoreCase("create")) {
  100. if(sender instanceof Player) {
  101. Player pl = (Player) sender;
  102. if(pl.hasPermission("rcore.admin")) {
  103. if(args.length == 1) {
  104. String nameArena = args[0];
  105.  
  106.  
  107.  
  108. Data.fcdata.set(nameArena + "." + "spawn." + "coords." + "x", 12);
  109. Data.fcdata.set(nameArena + "." + "spawn." + "coords." + "y", 12);
  110. Data.fcdata.set(nameArena + "." + "spawn." + "coords." + "z", 12);
  111. list.add(nameArena);
  112. Data.fcdata.set("Arenas", list);
  113. s.add(nameArena)
  114. ;
  115. try {
  116. Data.fcdata.save(Data.filedata);
  117. } catch (IOException e) {
  118. // TODO Auto-generated catch block
  119. e.printStackTrace();
  120. }
  121. mm.message(pl, prefix + "&aYou created an arena called &c" + nameArena);
  122. return true;
  123. }else {
  124. mm.message(pl, prefix + "&cYou must to use: &7/create <Arena>");
  125. return true;
  126. }
  127. }
  128. }
  129. }else if(cmd.getName().equalsIgnoreCase("setarenaspawn")) {
  130. if(sender instanceof Player) {
  131. Player pl = (Player) sender;
  132. if(pl.hasPermission("rcore.admin")) {
  133. if(args.length == 1) {
  134. String nameArena = args[0];
  135. if(!s.contains(nameArena)) {
  136. mm.message(pl, prefix + "&cThis arena doesen't exist: &7 " + nameArena);
  137. return true;
  138. }else {
  139. Data.fcdata.set(nameArena + "." + "spawn." + "coords." + "x", pl.getLocation().getX());
  140. Data.fcdata.set(nameArena + "." + "spawn." + "coords." + "y", pl.getLocation().getY());
  141. Data.fcdata.set(nameArena + "." + "spawn." + "coords." + "z", pl.getLocation().getZ());
  142. try {
  143. Data.fcdata.save(Data.filedata);
  144. } catch (IOException e) {
  145. // TODO Auto-generated catch block
  146. e.printStackTrace();
  147. }
  148.  
  149. mm.message(pl, prefix + "&cYou succeful set the coords to: &7 " + nameArena);
  150. return true;
  151. }
  152. }else {
  153. mm.message(pl, prefix + "&cYou must to use: &7/setarenaspawn <Arena>");
  154. return true;
  155. }
  156. }
  157. }
  158. }
  159.  
  160. return false;
  161. }
  162.  
  163.  
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement