Advertisement
Guest User

Untitled

a guest
Oct 7th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.65 KB | None | 0 0
  1. public class StartEndCommand implements CommandExecutor {
  2.  
  3. private Main instance;
  4. public StartEndCommand(Main instance) {
  5. this.instance = instance;
  6. }
  7.  
  8. ScoreboardAPI sc = new ScoreboardAPI();
  9.  
  10. int counttime = 10;
  11.  
  12. public Double arena(Player p) {
  13. FileConfiguration config = instance.getConfig();
  14. for (Double a = config.getDouble("spawn.arena1.x"); a < config.getDouble("spawn.arena2.x"); a++) {
  15. for (Double a1 = config.getDouble("spawn.arena2.x"); a < config.getDouble("spawn.arena1.x"); a++) {
  16. for (Double i = config.getDouble("spawn.arena1.y"); a < config.getDouble("spawn.arena2.y"); a++) {
  17. for (Double i1 = config.getDouble("spawn.arena2.y"); a < config.getDouble("spawn.arena1.y"); a++) {
  18. for (Double u = config.getDouble("spawn.arena1.z"); a < config.getDouble("spawn.arena2.z"); a++) {
  19. Block block = p.getWorld().getBlockAt(new Location(p.getWorld(), a, i, u));
  20. block.setTypeIdAndData(35, (byte) 4, true);
  21. for (Double u1 = config.getDouble("spawn.arena2.z"); a < config.getDouble("spawn.arena1.z"); a++) {
  22. Block block1 = p.getWorld().getBlockAt(new Location(p.getWorld(), a1, i1, u1));
  23. block1.setTypeIdAndData(35, (byte) 4, true);
  24. }
  25. }
  26. }
  27. }
  28. }
  29. }
  30. return null;
  31. }
  32.  
  33. public boolean onCommand(final CommandSender send, Command cmd, String label, String[] args) {
  34. final FileConfiguration config = instance.getConfig();
  35. if (cmd.getName().equalsIgnoreCase("start")) {
  36. for (final Player p : Bukkit.getOnlinePlayers()) {
  37. arena(p);
  38. new BukkitRunnable() {
  39. final Location loc = p.getLocation();
  40. final org.bukkit.World world = p.getWorld();
  41. public void run() {
  42. if (counttime == 0) {
  43. p.teleport(new Location(world, config.getDouble("spawn.game.x"), config.getDouble("spawn.game.y"), config.getDouble("spawn.game.z")));
  44. p.sendTitle("ゲームスタート", "~~Block Party~~", 50, 50, 50);
  45.  
  46. sc.bp.setDisplaySlot(DisplaySlot.SIDEBAR);
  47. this.cancel();
  48. }
  49. else {
  50. p.sendMessage(ChatColor.YELLOW + "ゲーム開始まで " + ChatColor.RESET + String.valueOf(counttime) + ChatColor.YELLOW + "秒");
  51. p.playSound(loc, Sound.UI_BUTTON_CLICK, 50, 50);
  52. }
  53. counttime--;
  54. }
  55. }.runTaskTimer(instance, 0L, 20L);
  56. new BukkitRunnable() {
  57. int round = 20;
  58. int round_starttime = 20;
  59. int default_round = 20;
  60.  
  61. int save_round_time = 20;
  62. String sc_player = null;
  63. String sc_spec = null;
  64. Boolean a = false;
  65. public void run() {
  66. if (round == 0 && sc.bp_player.getSize() == 0) {
  67. p.sendTitle("ゲーム終了", "~~Block Party~~", 50, 50, 50);
  68. this.cancel();
  69. }
  70. if (round_starttime == 0) {
  71. a=false;
  72. round_starttime+=(save_round_time-1);
  73. save_round_time-=1;
  74. }
  75. else {
  76. a=true;
  77. TextComponent timer = new TextComponent();
  78. timer.setText(String.valueOf(round_starttime));
  79. p.spigot().sendMessage(ChatMessageType.ACTION_BAR, timer);
  80. round_starttime--;
  81. }
  82.  
  83. if (a == true) {
  84. arena(p);
  85. send.sendMessage("あいうえお");
  86. }
  87.  
  88. if (sc_player != null) {
  89. sc.bp.getScoreboard().resetScores(sc_player);
  90. }
  91. sc_player = (ChatColor.GREEN + " プレイヤー: " + sc.bp_player.getSize());
  92. sc.bp.getScore(sc_player).setScore(9);
  93.  
  94. if (sc_spec != null) {
  95. sc.bp.getScoreboard().resetScores(sc_spec);
  96. }
  97. sc_spec = (ChatColor.GRAY + " 観戦者: " + sc.bp_spec.getSize());
  98. sc.bp.getScore(sc_spec).setScore(8);
  99. }
  100. }.runTaskTimer(instance, 0L, 20L);
  101.  
  102. }
  103. }
  104. return true;
  105. }
  106. }
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement