Add backup world resolution by environment name

This commit is contained in:
William278 committed 2023-03-27 13:25:19 +01:00
1 parent db988349ca
commit f0ffed0d3b
1 file changed
+13 -2
@@ -24,11 +24,22 @@ public final class BukkitAdapter {
if (world == null) {
world = Bukkit.getWorld(location.getWorld().getUuid());
}
if (world == null) {
world = Bukkit.getWorlds().stream()
.filter(w -> w.getEnvironment().name().equalsIgnoreCase(location.getWorld().getEnvironment().name()))
.findFirst().orElse(null);
}
if (world == null) {
return Optional.empty();
}
return Optional.of(new org.bukkit.Location(world, location.getX(), location.getY(), location.getZ(),
location.getYaw(), location.getPitch()));
return Optional.of(new org.bukkit.Location(
world,
location.getX(),
location.getY(),
location.getZ(),
location.getYaw(),
location.getPitch()
));
}
/**