mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-22 10:35:16 +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
|
@Override
|
||||||
public void onEnable() {
|
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
|
//register events
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
getServer().getPluginManager().registerEvents(eventForwarder, this);
|
getServer().getPluginManager().registerEvents(eventForwarder, this);
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
package de.bluecolored.bluemap.bukkit;
|
package de.bluecolored.bluemap.bukkit;
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
|
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.util.Key;
|
||||||
import de.bluecolored.bluemap.core.world.mca.MCAWorld;
|
import de.bluecolored.bluemap.core.world.mca.MCAWorld;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -43,8 +44,15 @@ public BukkitWorld(World delegate) {
|
|||||||
this.delegate = new WeakReference<>(delegate);
|
this.delegate = new WeakReference<>(delegate);
|
||||||
Path worldFolder = delegate.getWorldFolder().toPath();
|
Path worldFolder = delegate.getWorldFolder().toPath();
|
||||||
|
|
||||||
var id = delegate.key();
|
this.dimension = switch (delegate.getEnvironment()) {
|
||||||
this.dimension = new Key(id.namespace(), id.value());
|
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
|
// fix for hybrids
|
||||||
Path dimensionFolder = MCAWorld.resolveDimensionFolder(worldFolder, dimension);
|
Path dimensionFolder = MCAWorld.resolveDimensionFolder(worldFolder, dimension);
|
||||||
@ -58,17 +66,18 @@ public BukkitWorld(World delegate) {
|
|||||||
this.worldFolder = worldFolder;
|
this.worldFolder = worldFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Not supported by folia
|
|
||||||
@Override
|
@Override
|
||||||
public boolean persistWorldChanges() {
|
public boolean persistWorldChanges() {
|
||||||
World world = delegate.get();
|
if (!FoliaSupport.IS_FOLIA) {
|
||||||
if (world != null) {
|
World world = delegate.get();
|
||||||
world.save();
|
if (world != null) {
|
||||||
return true;
|
world.save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path getWorldFolder() {
|
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