Files
src
build.gradle
Code
20 1,393
src/main/java/com/locossmp/skyblock/SkyblockPlugin.java
package com.locossmp.skyblock;
import com.locossmp.skyblock.command.IslandCommand;
import com.locossmp.skyblock.inventory.gui.GUIListener;
import com.locossmp.skyblock.inventory.gui.GUIManager;
import com.locossmp.skyblock.island.IslandManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class SkyblockPlugin extends JavaPlugin {
private IslandManager islandManager;
private GUIManager guiManager;
private World skyblockWorld;
@Override
public void onEnable() {
saveDefaultConfig();
this.loadSkyblockWorld();
this.islandManager = new IslandManager(this);
this.guiManager = new GUIManager();
this.registerCommands();
this.registerListeners();
getLogger().info("LocosSkyblock has been enabled!");
}
@Override
public void onDisable() {
if (this.islandManager != null) {
this.islandManager.saveAllIslands();
}
getLogger().info("LocosSkyblock has been disabled!");
}
private void loadSkyblockWorld() {
String worldName = getConfig().getString("world-name", "skyblock_world");
World existing = Bukkit.getWorld(worldName);
if (existing != null) {
this.skyblockWorld = existing;
getLogger().info("Loaded existing skyblock world: " + worldName);
} else {
WorldCreator creator = new WorldCreator(worldName);
creator.environment(World.Environment.NORMAL);
creator.generator(new com.locossmp.skyblock.world.VoidWorldGenerator());
creator.generateStructures(false);
getLogger().info("Creating NEW void world: " + worldName);
getLogger().info("This world will be completely empty (void)");
this.skyblockWorld = creator.createWorld();
}
if (this.skyblockWorld != null) {
this.skyblockWorld.setSpawnLocation(0, getConfig().getInt("island-height", 64), 0);
this.skyblockWorld.setKeepSpawnInMemory(false);
this.skyblockWorld.setAutoSave(true);
getLogger().info("===========================================");
getLogger().info("Skyblock world: " + this.skyblockWorld.getName());
getLogger().info("Environment: " + this.skyblockWorld.getEnvironment());
getLogger().info("Generator: VoidWorldGenerator (completely empty)");
getLogger().info("Island height: " + getConfig().getInt("island-height", 64));
getLogger().info("===========================================");
} else {
getLogger().severe("FAILED TO CREATE SKYBLOCK WORLD!");
getLogger().severe("Check your server console for world creation errors!");
}
}
private void registerCommands() {
getCommand("island").setExecutor(new IslandCommand(this));
}
private void registerListeners() {
Bukkit.getPluginManager().registerEvents(new GUIListener(this.guiManager), this);
}
public String getPrefix() {
return getConfig().getString("messages.prefix", "&7[Skyblock] &r");
}
}