View difference between Paste ID: Y7dRSCyk and XET3WE6K
SHOW: | | - or go back to the newest paste.
1
public class StartCommand implements CommandExecutor {
2
3
	  private Main instance;
4
	  public StartCommand(Main instance) {
5
	    this.instance = instance;
6
	  }
7
8
	  public Integer counttime = ScoreboardAPI.counttime;
9
	  public Integer gametime = ScoreboardAPI.gametime;
10
	  ScoreboardAPI sc = new ScoreboardAPI();
11
12
	  boolean check = false;
13
14
	public boolean onCommand(final CommandSender send, Command cmd, String label, String[] args) {
15
		if (cmd.getName().equalsIgnoreCase("start")) {
16
			if (check == true) {
17
				send.sendMessage("すでにゲームが実行されています。");
18
				return true;
19
			}
20
			new BukkitRunnable() {
21
				public void run() {
22
					check=true;
23
					for (Player p : Bukkit.getOnlinePlayers()) {
24
                        if (counttime <= 0) {
25
                        	counttime+=10;
26
                            p.sendTitle("ゲームスタート", "~~Mob_Attacker~~", 10, 10, 10);
27
                            sc.mob.setDisplaySlot(DisplaySlot.SIDEBAR);
28
                            this.cancel();
29
                        }
30
                        else {
31
                            p.sendMessage("ゲーム開始まで " + String.valueOf(counttime) + "秒");
32
                            p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 50, 50);
33
                            counttime--;
34
                        }
35
					}
36
					gametime--;
37
				}
38
			}.runTaskTimer(instance, 0L, 20L);
39
			new BukkitRunnable() {
40
				public void run() {
41
					for (Player p : Bukkit.getOnlinePlayers()) {
42
                        if (gametime == 0) {
43
                        	gametime+=910;
44
                        	sc.mob.setDisplayName("Mob_Attacker");
45
                            p.sendTitle("ゲーム終了", "~~Mob_Attacker~~", 10, 10, 10);
46
                            check=false;
47
                            this.cancel();
48
                        }
49
                        else {
50-
                        	String time = String.valueOf(gametime % 60 - 1);
50+
                        	String time = String.valueOf(gametime % 60);
51-
                        	String time2 = String.valueOf(gametime % 60);
51+
52
                        	gametime--;
53
				String time2 = String.valueOf(gametime % 60);
54
						    sc.mob.getScore(String.valueOf((gametime%3600) / 60) + ":" + String.valueOf(gametime % 60)).setScore(22);;
55
						    sc.board.resetScores(String.valueOf((gametime%3600) / 60) + ":" + time2);
56
						    p.setScoreboard(sc.board);
57
                        }
58
					}
59
				}
60
			}.runTaskTimer(instance, 0L, 20L);
61
		}
62
		return false;
63
	}
64
}
65