-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleofCountdown.class
More file actions
64 lines (54 loc) · 1.65 KB
/
ExampleofCountdown.class
File metadata and controls
64 lines (54 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package src.com.GhostMansion.threads;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import src.com.GhostMansion.GhostMansion;
import src.com.GhostMansion.Utils.ChatUtilities;
import src.com.GhostMansion.Utils.TitleManager;
import src.com.GhostMansion.handlers.Game;
public class StartCountdown extends BukkitRunnable {
GhostMansion plugin;
public StartCountdown(GhostMansion pl){
plugin = pl;
}
public static int timeUntilStart;
@SuppressWarnings("deprecation")
@Override
public void run() {
if(Bukkit.getOnlinePlayers().length >= 2){
Game.setCanStart(true);
}
if (timeUntilStart == 0) {
if(!Game.canStart()){
plugin.restartCountdown();
ChatUtilities.broadcast(ChatColor.RED + "Can not start game. Countdown restarting");
return;
}
if(Game.canStart()){
ChatUtilities.broadcast(ChatColor.GREEN + "Game Starting!");
Game.start();
plugin.stopCountdown();
}
}
if (timeUntilStart % 10 == 0 || timeUntilStart < 10 ) {
ChatUtilities.broadcast(String.valueOf(timeUntilStart)
+ " seconds until game starts!");
}
for(Player p : Bukkit.getOnlinePlayers()){
if(timeUntilStart == 3){
TitleManager.sendTitle(p,
"{'color': 'green', 'bold' : 'true', 'text': '3'}");
}
if(timeUntilStart == 2){
TitleManager.sendTitle(p.getPlayer(),
"{'color': 'yellow', 'bold' : 'true', 'text': '2'}");
}
if(timeUntilStart == 1){
TitleManager.sendTitle(p.getPlayer(),
"{'color': 'red', 'bold' : 'true', 'text': '1'}");
}
}
timeUntilStart -= 1;
}
}