Maya/src/main/java/eu/univento/maya/Maya.java

107 lines
2.5 KiB
Java

package eu.univento.maya;
import eu.univento.commons.server.ServerType;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.maya.game.GameStage;
import eu.univento.maya.game.LobbyCounter;
import eu.univento.maya.listener.PlayerEvents;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
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;
/**
* main class
* @author joethei
* @version 0.1
*/
public class Maya extends JavaPlugin{
/**
* instance
*/
private static Maya instance;
/**
* @return plugin instance
*/
public static Maya getInstance() {
return instance;
}
/**
* logging and stuff
*/
private static Logger logger = Bukkit.getLogger();
/**
* game stage
*/
private static GameStage stage;
/**
* @return GameStage
*/
public static GameStage getStage() {
return stage;
}
/**
* sets gamestage
* @param stage GameStage
*/
public static void setStage(GameStage stage) {
Maya.stage = stage;
}
public static int getMinPlayers() {
return 1;
}
public static int getMaxPlayers() {
return 12;
}
private static ArrayList<Player> players = new ArrayList<>();
public static ArrayList<Player> getPlayers() {
return players;
}
public static int lobbyID;
public static int warmupID;
public static int gameID;
public static int buyID;
public static int deathmatchID;
public static int restartID;
/**
* @param level Log level
* @param string String
*/
public static void log(Level level, String string) {
logger.log(level, "[" + getInstance().getDescription().getName() + "] " + string);
}
@SuppressWarnings("deprecation")
@Override
public void onEnable() {
instance = this;
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerEvents(), this);
ServerSettings.setServerType(ServerType.GAME_MAYA);
ServerSettings.setGameMode(GameMode.ADVENTURE);
log(Level.INFO, "Plugin Version: " + getDescription().getVersion() + " gestartet");
stage = GameStage.Lobby;
lobbyID = getServer().getScheduler().scheduleSyncRepeatingTask(getInstance(), new LobbyCounter(), 20L, 20L);
}
@Override
public void onDisable() {
log(Level.INFO, "Plugin beendet");
}
}