geforkt von Mirrors/Paper
Expand world key API
Dieser Commit ist enthalten in:
Ursprung
a032df8427
Commit
d0185eb56e
@ -521,5 +521,10 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
public io.papermc.paper.world.MoonPhase getMoonPhase() {
|
||||
return io.papermc.paper.world.MoonPhase.getPhase(this.getHandle().dayTime() / 24000L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.NamespacedKey getKey() {
|
||||
return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.getHandle().getLevel().dimension().location());
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
@ -1185,9 +1185,15 @@ public final class CraftServer implements Server {
|
||||
File folder = new File(this.getWorldContainer(), name);
|
||||
World world = this.getWorld(name);
|
||||
|
||||
if (world != null) {
|
||||
return world;
|
||||
// Paper start
|
||||
World worldByKey = this.getWorld(creator.key());
|
||||
if (world != null || worldByKey != null) {
|
||||
if (world == worldByKey) {
|
||||
return world;
|
||||
}
|
||||
throw new IllegalArgumentException("Cannot create a world with key " + creator.key() + " and name " + name + " one (or both) already match a world that exists");
|
||||
}
|
||||
// Paper end
|
||||
|
||||
if (folder.exists()) {
|
||||
Preconditions.checkArgument(folder.isDirectory(), "File (%s) exists and isn't a folder", name);
|
||||
@ -1313,7 +1319,7 @@ public final class CraftServer implements Server {
|
||||
} else if (name.equals(levelName + "_the_end")) {
|
||||
worldKey = net.minecraft.world.level.Level.END;
|
||||
} else {
|
||||
worldKey = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace(name.toLowerCase(Locale.ROOT)));
|
||||
worldKey = ResourceKey.create(Registries.DIMENSION, ResourceLocation.fromNamespaceAndPath(creator.key().namespace(), creator.key().value()));
|
||||
}
|
||||
|
||||
// If set to not keep spawn in memory (changed from default) then adjust rule accordingly
|
||||
@ -1409,6 +1415,15 @@ public final class CraftServer implements Server {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public World getWorld(net.kyori.adventure.key.Key worldKey) {
|
||||
ServerLevel worldServer = console.getLevel(ResourceKey.create(net.minecraft.core.registries.Registries.DIMENSION, io.papermc.paper.adventure.PaperAdventure.asVanilla(worldKey)));
|
||||
if (worldServer == null) return null;
|
||||
return worldServer.getWorld();
|
||||
}
|
||||
// Paper end
|
||||
|
||||
public void addWorld(World world) {
|
||||
// Check if a World already exists with the UID.
|
||||
if (this.getWorld(world.getUID()) != null) {
|
||||
|
@ -538,6 +538,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
public int nextEntityId() {
|
||||
return net.minecraft.world.entity.Entity.nextEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMainLevelName() {
|
||||
return ((net.minecraft.server.dedicated.DedicatedServer) net.minecraft.server.MinecraftServer.getServer()).getProperties().levelName;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren