51 lines
1.5 KiB
Java
51 lines
1.5 KiB
Java
package eu.univento.trashgames.timers;
|
|
|
|
import eu.univento.core.Core;
|
|
import eu.univento.core.api.game.PlayerManager;
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import eu.univento.trashgames.TrashGames;
|
|
import eu.univento.trashgames.game.GameState;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.Sound;
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
/**
|
|
* @author joethei
|
|
* @version 0.1
|
|
*/
|
|
public class LobbyCountdown extends BukkitRunnable{
|
|
|
|
private int time = 60;
|
|
|
|
public LobbyCountdown() {
|
|
runTaskTimer(TrashGames.getInstance(), 20L, 20L);
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
if(PlayerManager.size() == 2) {
|
|
time--;
|
|
for(CustomPlayer player : Core.getOnlinePlayers()) {
|
|
player.setLevel(time);
|
|
player.playSound(player.getEyeLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0F, 1.0F);
|
|
}
|
|
}
|
|
if(time == 0) {
|
|
if(PlayerManager.size() == 2) {
|
|
this.cancel();
|
|
TrashGames.setState(GameState.GAME);
|
|
new GameCountdown();
|
|
for(CustomPlayer players : Core.getOnlinePlayers()) {
|
|
players.setHealth(20.0D);
|
|
players.setFoodLevel(20);
|
|
players.clearPotionEffects();
|
|
players.getInventory().clear();
|
|
}
|
|
}else{
|
|
Bukkit.broadcastMessage("Und noch mal warten");
|
|
this.cancel();
|
|
new LobbyCountdown();
|
|
}
|
|
}
|
|
}
|
|
} |