use of xyz.derkades.ublisk.modules.UModule in project Ublisk by Derkades.
the class Main method onEnable.
@Override
public void onEnable() {
instance = this;
Ublisk.RESTART_ERROR = false;
PacketListener.RUNNING = true;
Listeners.register();
Command.registerAll();
Mobs.clearMobs();
MobSpawn.startMobSpawning();
for (Task task : Task.values()) task.start();
Logger.startSiteLogger();
TodoList.initialize(DataFile.MYSQL.getConfig().getString("todo.ip"), DataFile.MYSQL.getConfig().getInt("todo.port"), DataFile.MYSQL.getConfig().getString("todo.database"), DataFile.MYSQL.getConfig().getString("todo.user"), DataFile.MYSQL.getConfig().getString("todo.password"));
for (UModule module : UModule.ALL_MODULES) {
try {
module.initialize();
} catch (Exception e) {
Logger.log(LogLevel.SEVERE, "Modules", "An error occured while initializing " + module.getClass().getSimpleName() + ": " + e.getMessage());
e.printStackTrace();
}
}
Bukkit.clearRecipes();
Ublisk.NMS = new V1_12_R1();
new SidebarAPI().onEnable();
new URunnable() {
public void run() {
Logger.log(LogLevel.INFO, "Cache", "Building up cache, expect some lag..");
for (Guild guild : Guild.getGuildsList()) {
guild.getDescription();
guild.getMembers();
guild.getOwner();
guild.getPoints();
}
for (UPlayer player : Ublisk.getOnlinePlayers()) {
player.getXP();
}
Logger.log(LogLevel.INFO, "Cache", "Complete! Now containing " + Cache.size() + " objects.");
Logger.log(LogLevel.INFO, "Guilds", "Deleting empty guilds...");
for (Guild guild : Guild.getGuildsList()) {
if (guild.getMembers().size() == 0) {
Logger.log(LogLevel.WARNING, "Guilds", "Automatically deleted " + guild.getName() + ", because it does not have any members.");
guild.remove();
}
}
}
}.runLater(10 * 20);
for (UPlayer player : Ublisk.getOnlinePlayers()) {
PlayerInfo.resetHashMaps(player);
}
Ublisk.openDatabaseConnection();
}
use of xyz.derkades.ublisk.modules.UModule in project Ublisk by Derkades.
the class Main method onDisable.
@Override
public void onDisable() {
Logger.log(LogLevel.INFO, "Core", "Shutting down...");
Task.stopAll();
// Save data files
for (DataFile dataFile : DataFile.values()) {
dataFile.save();
}
// Stop all running modules
for (UModule module : UModule.ALL_MODULES) {
if (!module.isRunning()) {
Logger.log(LogLevel.WARNING, "Modules", module.getClass().getSimpleName() + " is already terminated.");
}
module.terminate();
}
// Close all open sockets
PacketListener.RUNNING = false;
// Clear remaining tasks in sync queue
SyncQueue.clear();
ServerInfo.syncWithDatabase();
Ublisk.closeDatabaseConnection();
Logger.log(LogLevel.INFO, "Core", "Plugin has been shut down.");
instance = null;
}
Aggregations