use of com.iridium.iridiumskyblock.gui.GUI in project IridiumSkyblock by Iridium-Development.
the class IridiumSkyblock method onEnable.
/**
* Plugin startup logic.
*/
@Override
public void onEnable() {
super.onEnable();
// Convert old IridiumSkyblock data
DataConverter.copyLegacyData();
// Initialize the commands
this.commandManager = new CommandManager("iridiumskyblock");
// Initialize the manager classes (bad) and create the world
this.islandManager = new IslandManager();
this.userManager = new UserManager();
this.islandManager.createWorld(World.Environment.NORMAL, configuration.worldName);
this.islandManager.createWorld(World.Environment.NETHER, configuration.worldName + "_nether");
this.islandManager.createWorld(World.Environment.THE_END, configuration.worldName + "_the_end");
this.databaseManager = new DatabaseManager();
// Try to connect to the database
try {
databaseManager.init();
} catch (SQLException exception) {
// We don't want the plugin to start if the connection fails
exception.printStackTrace();
Bukkit.getPluginManager().disablePlugin(this);
return;
}
this.missionManager = new MissionManager();
this.shopManager = new ShopManager();
shopManager.reloadCategories();
this.schematicManager = new SchematicManager();
// Initialize Vault economy support
Bukkit.getScheduler().runTask(this, () -> this.economy = setupEconomy());
this.stackerSupport = registerBlockStackerSupport();
registerPlaceholderSupport();
// Send island border to all players
Bukkit.getOnlinePlayers().forEach(player -> getIslandManager().getIslandViaLocation(player.getLocation()).ifPresent(island -> PlayerUtils.sendBorder(player, island)));
// Auto recalculate islands
if (getConfiguration().islandRecalculateInterval > 0) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
ListIterator<Integer> islands = getDatabaseManager().getIslandTableManager().getEntries().stream().map(Island::getId).collect(Collectors.toList()).listIterator();
@Override
public void run() {
if (!islands.hasNext()) {
islands = getDatabaseManager().getIslandTableManager().getEntries().stream().map(Island::getId).collect(Collectors.toList()).listIterator();
} else {
getIslandManager().getIslandById(islands.next()).ifPresent(island -> getIslandManager().recalculateIsland(island));
}
}
}, 0, getConfiguration().islandRecalculateInterval * 20L);
}
// Automatically update all inventories
Bukkit.getScheduler().runTaskTimer(this, () -> Bukkit.getServer().getOnlinePlayers().forEach(player -> {
InventoryHolder inventoryHolder = player.getOpenInventory().getTopInventory().getHolder();
if (inventoryHolder instanceof GUI) {
((GUI) inventoryHolder).addContent(player.getOpenInventory().getTopInventory());
}
}), 0, 20);
// Register worlds with multiverse
if (Bukkit.getPluginManager().isPluginEnabled("Multiverse-Core")) {
Bukkit.getScheduler().runTaskLater(this, () -> {
registerMultiverse(islandManager.getWorld());
registerMultiverse(islandManager.getNetherWorld());
registerMultiverse(islandManager.getEndWorld());
}, 1);
}
resetIslandMissions();
if (!isTesting()) {
Metrics metrics = new Metrics(this, 5825);
metrics.addCustomChart(new SimplePie("database_type", () -> sql.driver.name()));
if (getConfiguration().enableCheckVersion) {
UpdateChecker.init(this, 62480).checkEveryXHours(24).setDownloadLink(62480).setColoredConsoleOutput(true).checkNow();
}
}
getLogger().info("----------------------------------------");
getLogger().info("");
getLogger().info(getDescription().getName() + " Enabled!");
getLogger().info("Version: " + getDescription().getVersion());
getLogger().info("");
getLogger().info("----------------------------------------");
}
Aggregations