fix: redis disconnecting when RTP could not find the world on the target server (#648)

* fix: redis disconnecting when the world is not found
This commit is contained in:
Preva1l authored and GitHub committed 2024-06-25 16:12:45 +01:00
1 parent 6e0e51f4f7
commit 2b9a9ae467
1 file changed
+7 -1
@@ -146,8 +146,14 @@ public abstract class Broker {
Optional<World> world = plugin.getWorlds().stream()
.filter(w -> w.getName().equals(request.getWorldName())).findFirst();
if (world.isEmpty()) {
throw new RuntimeException("%s requested a position in a world we don't have! World: %s"
plugin.log(Level.SEVERE, "%s requested a position in a world we don't have! World: %s"
.formatted(message.getSourceServer(), request.getWorldName()));
Message.builder()
.type(Message.Type.RTP_LOCATION)
.target(request.getUsername())
.payload(Payload.empty())
.build().send(plugin.getMessenger(), request.getUsername());
return;
}
plugin.getRandomTeleportEngine().getRandomPosition(world.get(), null)
.thenAccept((position) -> {