111 lines
4.8 KiB
Java
111 lines
4.8 KiB
Java
package eu.univento.woolget.game;
|
|
|
|
import eu.univento.core.Core;
|
|
import eu.univento.core.api.Config;
|
|
import eu.univento.core.api.game.Team;
|
|
import eu.univento.core.api.game.TeamManager;
|
|
import eu.univento.core.api.map.Map;
|
|
import eu.univento.core.api.map.MapDownloader;
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import eu.univento.core.api.schematic.Cuboid;
|
|
import eu.univento.woolget.WoolGet;
|
|
import eu.univento.woolget.listeners.Blocks;
|
|
import eu.univento.woolget.listeners.PlayerEvents;
|
|
import eu.univento.woolget.utils.TeamChooser;
|
|
import org.bukkit.*;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.inventory.ItemStack;
|
|
import org.bukkit.inventory.meta.ItemMeta;
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
/**
|
|
* runnable for lobby counter
|
|
* @author joethei
|
|
* @version 0.2
|
|
*/
|
|
public class LobbyCounter extends BukkitRunnable{
|
|
|
|
private int time = 60;
|
|
|
|
public void run() {
|
|
if(WoolGet.getGameStage() == GameStage.Lobby && Bukkit.getOnlinePlayers().size() >= WoolGet.getMinPlayers()) {
|
|
for(Player players : Bukkit.getOnlinePlayers()) {
|
|
players.setLevel(time);
|
|
if(time == 30) {
|
|
players.playSound(players.getEyeLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 1.0F);
|
|
}
|
|
if(time <= 10) {
|
|
players.playSound(players.getEyeLocation(), Sound.ENTITY_ARROW_HIT, 1.0F, 1.0F);
|
|
}
|
|
}
|
|
|
|
if(time == 10) {
|
|
Map map = WoolGet.getVoting().getWinningMap();
|
|
Bukkit.broadcastMessage("Das Voting ist beendet, gewonnen hat " + map.getName());
|
|
for(CustomPlayer players : Core.getOnlinePlayers())
|
|
players.getInventory().clear();
|
|
World world = MapDownloader.loadMap(map);
|
|
assert world != null;
|
|
world.setPVP(true);
|
|
world.setDifficulty(Difficulty.PEACEFUL);
|
|
world.setAutoSave(false);
|
|
}
|
|
|
|
if(time == 0) {
|
|
TeamManager.addTeam(new Team("blue", "§9"));
|
|
TeamManager.addTeam(new Team("yellow", "§e"));
|
|
Blocks.setTeams();
|
|
PlayerEvents.setTeams();
|
|
|
|
Map map = WoolGet.getVoting().getWinningMap();
|
|
Cuboid blue = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Blue.MinPos"), Config.readLocation("Strive." + map.getName() + ".Blue.MaxPos"));
|
|
Cuboid yellow = new Cuboid(Config.readLocation("Strive." + map.getName() + ".Yellow.MinPos"), Config.readLocation("Strive." + map.getName() + ".Yellow.MaxPos"));
|
|
|
|
TeamChooser.addToTeams();
|
|
|
|
WoolGet.setGameStage(GameStage.Warmup);
|
|
WoolGet.warmupID = WoolGet.getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(WoolGet.getInstance(), new WarmupCounter(), 20L, 20L);
|
|
Bukkit.getScheduler().cancelTask(WoolGet.lobbyID);
|
|
|
|
for(CustomPlayer players : WoolGet.getPlayers()) {
|
|
CustomPlayer p = CustomPlayer.getPlayer(players);
|
|
Team teamBlue = TeamManager.getTeam("blue");
|
|
Team teamYellow = TeamManager.getTeam("yellow");
|
|
|
|
teamBlue.getScoreboardTeam().setOption(org.bukkit.scoreboard.Team.Option.NAME_TAG_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.FOR_OWN_TEAM);
|
|
teamYellow.getScoreboardTeam().setOption(org.bukkit.scoreboard.Team.Option.NAME_TAG_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.FOR_OWN_TEAM);
|
|
|
|
players.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
|
|
|
players.setGameMode(GameMode.SURVIVAL);
|
|
|
|
if(teamBlue.isPlayer(p)) {
|
|
p.teleport(blue.getRandomLocation());
|
|
p.sendMessage("§aDu bist in Team Blau");
|
|
|
|
ItemStack item = new ItemStack(Material.WOOL, 1, (short) 11);
|
|
ItemMeta meta = item.getItemMeta();
|
|
meta.setDisplayName("§9Dein Block");
|
|
item.setItemMeta(meta);
|
|
|
|
p.getInventory().clear();
|
|
p.getInventory().addItem(item);
|
|
}
|
|
if(teamYellow.isPlayer(p)) {
|
|
p.teleport(yellow.getRandomLocation());
|
|
p.sendMessage("§aDu bist in Team Gelb");
|
|
|
|
ItemStack item = new ItemStack(Material.WOOL, 1, (short) 4);
|
|
ItemMeta meta = item.getItemMeta();
|
|
meta.setDisplayName("§eDein Block");
|
|
item.setItemMeta(meta);
|
|
|
|
p.getInventory().clear();
|
|
p.getInventory().addItem(item);
|
|
}
|
|
}
|
|
}
|
|
time--;
|
|
}
|
|
}
|
|
} |