159 lines
4.5 KiB
Java
159 lines
4.5 KiB
Java
package eu.univento.core;
|
|
|
|
import eu.univento.core.api.BossBar;
|
|
import eu.univento.core.api.Config;
|
|
import eu.univento.core.api.SignInput;
|
|
import eu.univento.core.api.database.MySQL;
|
|
import eu.univento.core.api.events.MoveEventFilter;
|
|
import eu.univento.core.api.fakeplayer.PlayerKi;
|
|
import eu.univento.core.api.player.TeamSpeak;
|
|
import eu.univento.core.api.server.ServerSettings;
|
|
import eu.univento.core.commands.*;
|
|
import eu.univento.core.listeners.*;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.plugin.PluginManager;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import java.io.IOException;
|
|
import java.sql.SQLException;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
/**
|
|
* main class
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
public class Core extends JavaPlugin{
|
|
|
|
//TODO: rewrite time critical database functions from MySQL to MongoDB
|
|
|
|
/**
|
|
* plugin instance
|
|
*/
|
|
public static Core instance;
|
|
/**
|
|
* @return plugin instance
|
|
*/
|
|
public static Core getInstance() {
|
|
return instance;
|
|
}
|
|
|
|
/**
|
|
* mysql stuff
|
|
*/
|
|
private static MySQL sql = new MySQL(getInstance(), Config.readString("MySQL.Host"), Config.readString("MySQL.Port"), Config.readString("MySQL.DB"), Config.readString("MySQL.User"), Config.readString("MySQL.Pass"));
|
|
/**
|
|
* @return sql
|
|
*/
|
|
public static MySQL returnSQL() {
|
|
return sql;
|
|
}
|
|
|
|
private static TeamSpeak ts;
|
|
|
|
public static TeamSpeak getTs() {
|
|
return ts;
|
|
}
|
|
/**
|
|
* logging and stuff
|
|
*/
|
|
private static Logger log = Bukkit.getLogger();
|
|
|
|
/**
|
|
* @param level Log level
|
|
* @param string String
|
|
*/
|
|
public static void log(Level level, String string) {
|
|
if(ServerSettings.isDebug()) {
|
|
log.log(level, "[Core] " + string);
|
|
}
|
|
}
|
|
|
|
private SignInput signInput;
|
|
|
|
public SignInput getSignInput() {
|
|
return signInput;
|
|
}
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
ServerSettings.setDebug(true);
|
|
try {
|
|
Config.writeDefault();
|
|
} catch (ClassNotFoundException | SQLException | IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
instance = this;
|
|
this.signInput = new SignInput(this);
|
|
if(ServerSettings.isDebug()) log(Level.INFO, "Debug Modus aktiviert");
|
|
PluginManager pm = Bukkit.getPluginManager();
|
|
pm.registerEvents(new Commands(), this);
|
|
pm.registerEvents(new JoinQuit(), this);
|
|
pm.registerEvents(new Chat(), this);
|
|
pm.registerEvents(new Blocks(), this);
|
|
pm.registerEvents(new Events(), this);
|
|
pm.registerEvents(new MoveEventFilter(getServer()), this);
|
|
pm.registerEvents(new BossBar(), this);
|
|
pm.registerEvents(new PlayerKi(), this);
|
|
|
|
log(Level.INFO, "Events registriert");
|
|
|
|
String[] fix = {""};
|
|
if(ServerSettings.isGame()) new Fix(this, "fix", "Fixe dich oder andere Spieler", fix);
|
|
|
|
String[] runas = {""};
|
|
new RunAs(this, "RunAs", "Sende einen Befehl als ein anderer Spieler", runas);
|
|
|
|
String[] systeminfo = {""};
|
|
new SystemInfo(this, "SystemInfo", "Gibt Infos über den ServerPinger aus", systeminfo);
|
|
|
|
String[] vanish = {""};
|
|
new Vanish(this, "vanish", "Lässt dich verschwinden", vanish);
|
|
|
|
String[] gamemode = {"gm"};
|
|
new GameMode(this, "gamemode" , "Setzt deinen GameMode", gamemode);
|
|
|
|
String[] setrank = {"sr"};
|
|
new SetRank(this, "setrank" , "Setzt den Rang eines Spielers", setrank);
|
|
|
|
String[] globalmute = {"globalmute"};
|
|
new GlobalMute(this, "globalmute", "Muted den gesamten ServerPinger", globalmute);
|
|
|
|
String[] youtuber = {""};
|
|
new Youtuber(this, "youtuber", "setzt Spieler in den Youtuber Rang", youtuber);
|
|
|
|
String[] ts = {""};
|
|
new TS(this, "ts", "verifiziert Spieler auf dem TS", ts);
|
|
|
|
String[] ban = {""};
|
|
new Ban(this, "ban", "Bannt Spieler", ban);
|
|
|
|
String[] build = {"b"};
|
|
new Build(this, "build", "Setzt den Spieler in den Bau Modus", build);
|
|
|
|
String[] chatclear = {"cc"};
|
|
new ChatClear(this, "chatclear", "Cleart den Chat", chatclear);
|
|
|
|
if(ServerSettings.isGame()) {
|
|
String[] nick = {""};
|
|
new Nick(this, "nick", "ändert das Verhalten des Nicksystems", nick);
|
|
log(Level.INFO, "/nick aktiviert");
|
|
}
|
|
|
|
log(Level.INFO, "Alle Befehle registriert");
|
|
|
|
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
|
|
|
this.ts = new TeamSpeak();
|
|
|
|
log(Level.INFO, "Plugin ver. " + getDescription().getVersion() + " gestartet");
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
log(Level.INFO, "Plugin beendet");
|
|
getTs().disconnect();
|
|
}
|
|
|
|
} |