112 lines
3.2 KiB
Java
112 lines
3.2 KiB
Java
package eu.univento.woolget;
|
|
|
|
import eu.univento.commons.server.ServerType;
|
|
import eu.univento.core.api.map.Map;
|
|
import eu.univento.core.api.map.MapDatabase;
|
|
import eu.univento.core.api.map.MapVoting;
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import eu.univento.core.api.server.ServerSettings;
|
|
import eu.univento.woolget.commands.SetPositions;
|
|
import eu.univento.woolget.game.GameStage;
|
|
import eu.univento.woolget.game.LobbyCounter;
|
|
import eu.univento.woolget.listeners.*;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.GameMode;
|
|
import org.bukkit.World;
|
|
import org.bukkit.entity.Entity;
|
|
import org.bukkit.plugin.PluginManager;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
/**
|
|
* @author joethei
|
|
* @version 0.1
|
|
*/
|
|
public class WoolGet extends JavaPlugin{
|
|
|
|
private static WoolGet instance;
|
|
public static WoolGet getInstance() {
|
|
return instance;
|
|
}
|
|
|
|
private static Logger logger = Bukkit.getLogger();
|
|
|
|
public static void log(Level level, String msg) {
|
|
if(ServerSettings.isDebug())
|
|
logger.log(level, "[" + getInstance().getDescription().getName() + "]" + msg);
|
|
}
|
|
|
|
public static int lobbyID;
|
|
public static int warmupID;
|
|
public static int gameID;
|
|
public static int restartID;
|
|
|
|
public static int getMinPlayers() {
|
|
return 2;
|
|
}
|
|
public static int getMaxPlayers() {
|
|
return 12;
|
|
}
|
|
|
|
private static GameStage gameStage;
|
|
public static GameStage getGameStage() {
|
|
return gameStage;
|
|
}
|
|
public static void setGameStage(GameStage gameStage) {
|
|
WoolGet.gameStage = gameStage;
|
|
ServerSettings.setGameState(gameStage.toString());
|
|
}
|
|
|
|
private static ArrayList<CustomPlayer> players = new ArrayList<>();
|
|
public static ArrayList<CustomPlayer> getPlayers() {
|
|
return players;
|
|
}
|
|
|
|
private static MapVoting voting;
|
|
public static MapVoting getVoting() {
|
|
return voting;
|
|
}
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
PluginManager pm = Bukkit.getPluginManager();
|
|
instance = this;
|
|
setGameStage(GameStage.Lobby);
|
|
ServerSettings.setGame(true);
|
|
ServerSettings.setServerType(ServerType.GAME_WOOLGET);
|
|
ServerSettings.setGameMode(GameMode.ADVENTURE);
|
|
|
|
voting = new MapVoting("Map Voting");
|
|
for(Map map : MapDatabase.getAllMaps(ServerType.GAME_WOOLGET)) {
|
|
voting.addMap(map);
|
|
}
|
|
voting.setVotingMaps();
|
|
voting.registerListener(this);
|
|
|
|
pm.registerEvents(new Inventorys(), this);
|
|
pm.registerEvents(new JoinQuit(), this);
|
|
pm.registerEvents(new Blocks(), this);
|
|
pm.registerEvents(new PlayerEvents(), this);
|
|
pm.registerEvents(new ChestManager(), this);
|
|
|
|
new SetPositions(this, "setpositions", "sets all positions", "setpos");
|
|
|
|
ChestManager.fillLists();
|
|
|
|
log(Level.INFO, "Plugin started");
|
|
|
|
lobbyID = getServer().getScheduler().scheduleSyncRepeatingTask(getInstance(), new LobbyCounter(), 20L, 20L);
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
for(World world : Bukkit.getWorlds()) {
|
|
world.getEntities().forEach(Entity::remove);
|
|
}
|
|
log(Level.INFO, "Plugin stopped");
|
|
}
|
|
|
|
} |