Update and bugfixes

This commit is contained in:
tyuXX 2025-06-23 23:03:22 +03:00
parent c9a22d3c0e
commit 2845cc512f
35 changed files with 315 additions and 28 deletions

View file

@ -3,13 +3,16 @@ package org.gsdistance.grimmsServer.Indexers;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.gsdistance.grimmsServer.Constructable.WorldConstructor;
import org.gsdistance.grimmsServer.GrimmsServer;
public class DynamicDimensionGen {
public static World newDimension(WorldConstructor worldConstructor) {
public static void newDimension(WorldConstructor worldConstructor) {
GrimmsServer.logger.info("Creating new world: " + worldConstructor.name() + " with type: " + worldConstructor.type());
if (Bukkit.getWorld(worldConstructor.name()) != null) {
return Bukkit.getWorld(worldConstructor.name());
GrimmsServer.logger.info("World with name '" + worldConstructor.name() + "' already exists.");
Bukkit.getWorld(worldConstructor.name());
} else {
// Create a new world with the specified name and type
WorldCreator worldCreator = new WorldCreator(worldConstructor.name());
@ -20,14 +23,21 @@ public class DynamicDimensionGen {
worldCreator.environment(World.Environment.NORMAL);
}
worldCreator.generateStructures(worldConstructor.generateStructures());
return worldCreator.createWorld();
try {
worldCreator.type(WorldType.valueOf(worldConstructor.worldType()));
} catch (EnumConstantNotPresentException e) {
// If the world type is not recognized, default to NORMAL
worldCreator.type(WorldType.NORMAL);
}
GrimmsServer.logger.info("World created with name: " + worldCreator.name() + ", type: " + worldCreator.type() + ", environment: " + worldCreator.environment());
worldCreator.createWorld();
}
}
public static void loadWorlds() {
GrimmsServer.logger.info("Loading worlds from worldConstructors...");
WorldConstructor[] worldConstructors = WorldConstructor.getAllWorldConstructors();
if (worldConstructors == null || worldConstructors.length == 0) {
if (worldConstructors.length == 0) {
GrimmsServer.logger.warning("No world constructors found to load.");
return;
}