use of au.com.mineauz.minigames.events.TimerExpireEvent in project Minigames by AddstarMC.
the class MinigameTimer method startTimer.
public void startTimer() {
if (taskID != -1)
stopTimer();
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
time -= 1;
if (minigame.isUsingXPBarTimer()) {
float timeper = ((Integer) time).floatValue() / ((Integer) otime).floatValue();
int level = 0;
if (time / 60 > 0)
level = time / 60;
else
level = time;
for (MinigamePlayer ply : minigame.getPlayers()) {
ply.getPlayer().setExp(timeper);
ply.getPlayer().setLevel(level);
}
}
if (timeMsg.contains(time) && broadcastTime) {
PlayMGSound.playSound(minigame, MGSounds.getSound("timerTick"));
plugin.mdata.sendMinigameMessage(minigame, MinigameUtils.formStr("minigame.timeLeft", MinigameUtils.convertTime(time)), null, null);
}
if (time == 0) {
Bukkit.getServer().getPluginManager().callEvent(new TimerExpireEvent(minigame));
stopTimer();
}
if (time != 0)
Bukkit.getPluginManager().callEvent(new MinigameTimerTickEvent(minigame, minigame.getMinigameTimer()));
}
}, 0, 20);
}
use of au.com.mineauz.minigames.events.TimerExpireEvent in project Minigames by AddstarMC.
the class MinigameTimer method runTimer.
private void runTimer() {
time -= 1;
if (minigame.isUsingXPBarTimer()) {
float timeper = ((Integer) time).floatValue() / ((Integer) otime).floatValue();
int level = 0;
if (time / 60 > 0)
level = time / 60;
else
level = time;
for (MinigamePlayer ply : minigame.getPlayers()) {
if (timeper < 0) {
ply.getPlayer().setExp(0);
ply.getPlayer().setLevel(0);
} else {
ply.getPlayer().setExp(timeper);
ply.getPlayer().setLevel(level);
}
}
}
if (timeMsg.contains(time) && broadcastTime) {
PlayMGSound.playSound(minigame, MGSounds.getSound("timerTick"));
plugin.getMinigameManager().sendMinigameMessage(minigame, MinigameUtils.formStr("minigame.timeLeft", MinigameUtils.convertTime(time)));
}
if (time <= 0) {
Bukkit.getServer().getPluginManager().callEvent(new TimerExpireEvent(minigame));
stopTimer();
}
if (time > 0)
Bukkit.getPluginManager().callEvent(new MinigameTimerTickEvent(minigame, minigame.getMinigameTimer()));
}
Aggregations