Implement a challenge system. This allows players to work towards them and add some goals to reach. Demo challenges are included in file challenges.yml. This should provide details on how to create your own challenges. --------- Co-authored-by: Teriuihi <teriuihi@alttd.com>
113 lines
4.4 KiB
Java
113 lines
4.4 KiB
Java
package com.alttd.cometskyblock;
|
|
|
|
import com.alttd.cometskyblock.challenges.ChallengeHandler;
|
|
import com.alttd.cometskyblock.challenges.ChallengeLoader;
|
|
import com.alttd.cometskyblock.commands.admin.SkyBlockCommand;
|
|
import com.alttd.cometskyblock.commands.challenges.ChallengeCommand;
|
|
import com.alttd.cometskyblock.commands.island.IslandCommand;
|
|
import com.alttd.cometskyblock.configuration.*;
|
|
import com.alttd.cometskyblock.gui.GUIListener;
|
|
import com.alttd.cometskyblock.island.IslandData;
|
|
import com.alttd.cometskyblock.listeners.BedListener;
|
|
import com.alttd.cometskyblock.listeners.CobbestoneGeneratorListener;
|
|
import com.alttd.cometskyblock.listeners.PlayerJoinListener;
|
|
import com.alttd.cometskyblock.listeners.PlayerListener;
|
|
import com.alttd.cometskyblock.managers.IslandManager;
|
|
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<CobblestoneGeneratorConfiguration> cobblestoneGeneratorConfiguration;
|
|
@Getter private ConfigurationContainer<WorldBorderConfiguration> worldBorderConfiguration;
|
|
|
|
@Getter private IslandManager islandManager;
|
|
@Getter private MasterWorldGenerator worldGenerator;
|
|
@Getter private ChallengeHandler challengeHandler;
|
|
@Getter private ChallengeLoader challengeLoader;
|
|
|
|
@Override
|
|
public void onLoad() {
|
|
instance = this;
|
|
CometSkyBlockAPI.Provider.register(instance);
|
|
}
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
// Load configurations
|
|
loadConfiguration();
|
|
|
|
// Load commands
|
|
loadCommands();
|
|
|
|
// Load event listeners
|
|
loadEventListeners();
|
|
|
|
// Reload island data for top list
|
|
IslandData.reloadAllIslandData();
|
|
|
|
// load data from storage
|
|
|
|
// run cleanup tasks
|
|
// CleanupAndDeleteOldIslands and playerdata
|
|
|
|
// load worlds & manager
|
|
islandManager = new IslandManager(this);
|
|
worldGenerator = new MasterWorldGenerator(this);
|
|
challengeHandler = new ChallengeHandler(this);
|
|
loadChallenges();
|
|
|
|
worldGenerator.checkMasterIslandWorld();
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
// Cancel all running tasks
|
|
getServer().getScheduler().cancelTasks(this);
|
|
|
|
// close data connection
|
|
}
|
|
|
|
public void loadChallenges() {
|
|
challengeHandler.clearChallenges();
|
|
challengeLoader = new ChallengeLoader(this);
|
|
challengeLoader.loadAllChallenges();
|
|
}
|
|
|
|
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");
|
|
cobblestoneGeneratorConfiguration = ConfigurationContainer.load(logger, path, CobblestoneGeneratorConfiguration.class, "coblestonegenerator");
|
|
worldBorderConfiguration = ConfigurationContainer.load(logger, path, WorldBorderConfiguration.class, "worldborder");
|
|
}
|
|
|
|
public void loadCommands() {
|
|
getCommand("island").setExecutor(new IslandCommand(this));
|
|
getCommand("challenges").setExecutor(new ChallengeCommand(this));
|
|
getCommand("skyblock").setExecutor( new SkyBlockCommand(this));
|
|
}
|
|
|
|
public void loadEventListeners() {
|
|
final PluginManager pm = getServer().getPluginManager();
|
|
pm.registerEvents(new PlayerJoinListener(this), this);
|
|
pm.registerEvents(new BedListener(this), this);
|
|
pm.registerEvents(new CobbestoneGeneratorListener(this), this);
|
|
pm.registerEvents(new GUIListener(this), this);
|
|
pm.registerEvents(new PlayerListener(this), this);
|
|
}
|
|
|
|
}
|