88 lines
3.1 KiB
Java
88 lines
3.1 KiB
Java
package com.alttd.cometskyblock;
|
|
|
|
import com.alttd.cometskyblock.commands.challenges.ChallengeCommand;
|
|
import com.alttd.cometskyblock.commands.island.IslandCommand;
|
|
import com.alttd.cometskyblock.configuration.*;
|
|
import com.alttd.cometskyblock.listeners.PlayerJoinListener;
|
|
import com.alttd.cometskyblock.managers.IslandManager;
|
|
import com.alttd.cometskyblock.managers.PlayerManager;
|
|
import com.alttd.cometskyblock.worldgenerator.MasterWorldGenerator;
|
|
import lombok.Getter;
|
|
import org.bukkit.plugin.PluginManager;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
import org.slf4j.Logger;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
public class CometSkyBlockPlugin extends JavaPlugin implements CometSkyBlockAPI {
|
|
|
|
@Getter private static CometSkyBlockPlugin instance;
|
|
|
|
@Getter private ConfigurationContainer<PluginConfiguration> pluginConfiguration;
|
|
@Getter private ConfigurationContainer<DatabaseConfiguration> databaseConfiguration;
|
|
@Getter private ConfigurationContainer<MessageConfiguration> messagesConfiguration;
|
|
@Getter private ConfigurationContainer<ChallengesConfiguration> challengesConfiguration;
|
|
|
|
@Getter private IslandManager islandManager;
|
|
@Getter private PlayerManager playerManager;
|
|
@Getter private MasterWorldGenerator worldGenerator;
|
|
|
|
@Override
|
|
public void onLoad() {
|
|
instance = this;
|
|
CometSkyBlockAPI.Provider.register(instance);
|
|
}
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
// Load configurations
|
|
loadConfiguration();
|
|
|
|
// Load commands
|
|
loadCommands();
|
|
|
|
// Load event listeners
|
|
loadEventListeners();
|
|
|
|
// load data from storage
|
|
|
|
// run cleanup tasks
|
|
// CleanupAndDeleteOldIslands and playerdata
|
|
|
|
// load worlds & manager
|
|
islandManager = new IslandManager(this);
|
|
playerManager = new PlayerManager(this);
|
|
worldGenerator = new MasterWorldGenerator(this);
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
// Cancel all running tasks
|
|
getServer().getScheduler().cancelTasks(this);
|
|
|
|
// close data connection
|
|
}
|
|
|
|
public void loadConfiguration() {
|
|
Path path = this.getDataFolder().toPath();
|
|
Logger logger = this.getSLF4JLogger();
|
|
pluginConfiguration = ConfigurationContainer.load(logger, path, PluginConfiguration.class, "config");
|
|
databaseConfiguration = ConfigurationContainer.load(logger, path, DatabaseConfiguration.class, "database");
|
|
messagesConfiguration = ConfigurationContainer.load(logger, path, MessageConfiguration.class, "messages");
|
|
challengesConfiguration = ConfigurationContainer.load(logger, path, ChallengesConfiguration.class, "challenges");
|
|
}
|
|
|
|
public void loadCommands() {
|
|
getCommand("island").setExecutor(new IslandCommand(this));
|
|
getCommand("challenges").setExecutor(new ChallengeCommand(this));
|
|
// getCommand("cometskyblock").setExecutor( new AdminCommands(this));
|
|
}
|
|
|
|
public void loadEventListeners() {
|
|
// TODO - Use reflection to load all of these
|
|
final PluginManager pm = getServer().getPluginManager();
|
|
pm.registerEvents(new PlayerJoinListener(this), this);
|
|
}
|
|
|
|
}
|