mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-25 12:05:13 +01:00
Fix paper-implementation not detecting additional worlds correctly
This commit is contained in:
parent
aecbd23ba7
commit
0613037093
@ -109,6 +109,14 @@ public BukkitPlugin() {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
//save world so the level.dat is present on new worlds
|
||||
if (!FoliaSupport.IS_FOLIA) {
|
||||
Logger.global.logInfo("Saving all worlds once, to make sure the level.dat is present...");
|
||||
for (World world : getServer().getWorlds()) {
|
||||
world.save();
|
||||
}
|
||||
}
|
||||
|
||||
//register events
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
getServer().getPluginManager().registerEvents(eventForwarder, this);
|
||||
|
@ -25,6 +25,7 @@
|
||||
package de.bluecolored.bluemap.bukkit;
|
||||
|
||||
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
|
||||
import de.bluecolored.bluemap.core.resources.datapack.DataPack;
|
||||
import de.bluecolored.bluemap.core.util.Key;
|
||||
import de.bluecolored.bluemap.core.world.mca.MCAWorld;
|
||||
import org.bukkit.World;
|
||||
@ -43,8 +44,15 @@ public BukkitWorld(World delegate) {
|
||||
this.delegate = new WeakReference<>(delegate);
|
||||
Path worldFolder = delegate.getWorldFolder().toPath();
|
||||
|
||||
var id = delegate.key();
|
||||
this.dimension = new Key(id.namespace(), id.value());
|
||||
this.dimension = switch (delegate.getEnvironment()) {
|
||||
case NORMAL -> DataPack.DIMENSION_OVERWORLD;
|
||||
case NETHER -> DataPack.DIMENSION_THE_NETHER;
|
||||
case THE_END -> DataPack.DIMENSION_THE_END;
|
||||
case CUSTOM -> {
|
||||
var id = delegate.key();
|
||||
yield new Key(id.namespace(), id.value());
|
||||
}
|
||||
};
|
||||
|
||||
// fix for hybrids
|
||||
Path dimensionFolder = MCAWorld.resolveDimensionFolder(worldFolder, dimension);
|
||||
@ -58,17 +66,18 @@ public BukkitWorld(World delegate) {
|
||||
this.worldFolder = worldFolder;
|
||||
}
|
||||
|
||||
/* Not supported by folia
|
||||
@Override
|
||||
public boolean persistWorldChanges() {
|
||||
World world = delegate.get();
|
||||
if (world != null) {
|
||||
world.save();
|
||||
return true;
|
||||
if (!FoliaSupport.IS_FOLIA) {
|
||||
World world = delegate.get();
|
||||
if (world != null) {
|
||||
world.save();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Path getWorldFolder() {
|
||||
|
@ -0,0 +1,19 @@
|
||||
package de.bluecolored.bluemap.bukkit;
|
||||
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
|
||||
public class FoliaSupport {
|
||||
|
||||
public static final boolean IS_FOLIA = isFolia();
|
||||
|
||||
private static boolean isFolia() {
|
||||
try {
|
||||
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
||||
Logger.global.logInfo("Folia detected, enabling folia-support mode.");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user