Use sponge world UUIDs instead of the formatted resource-key to ensure uniqueness

This commit is contained in:
Lukas Rieger (Blue) 2022-08-03 17:51:29 +02:00
parent c289fd8c13
commit 35cbdf67d6
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
4 changed files with 6 additions and 4 deletions

View File

@ -234,7 +234,8 @@ public Optional<ServerWorld> getWorld(Object world) {
if (world instanceof String) {
ResourceKey resourceKey = ResourceKey.resolve((String) world);
if (resourceKey != null) world = resourceKey;
var serverWorld = Sponge.server().worldManager().world(resourceKey).orElse(null);
if (serverWorld != null) world = serverWorld;
}
if (world instanceof ResourceKey) {

View File

@ -63,7 +63,7 @@ public Dimension getDimension() {
public Optional<String> getId() {
var world = delegate.get();
if (world != null) {
return Optional.of(world.key().formatted());
return Optional.of(world.uniqueId().toString());
}
return Optional.empty();
}

View File

@ -234,7 +234,8 @@ public Optional<ServerWorld> getWorld(Object world) {
if (world instanceof String) {
ResourceKey resourceKey = ResourceKey.resolve((String) world);
if (resourceKey != null) world = resourceKey;
var serverWorld = Sponge.server().worldManager().world(resourceKey).orElse(null);
if (serverWorld != null) world = serverWorld;
}
if (world instanceof ResourceKey) {

View File

@ -63,7 +63,7 @@ public Dimension getDimension() {
public Optional<String> getId() {
var world = delegate.get();
if (world != null) {
return Optional.of(world.key().formatted());
return Optional.of(world.uniqueId().toString());
}
return Optional.empty();
}