fix: don't teleport users locally to beds if broken

This commit is contained in:
William committed 2023-12-26 15:34:57 +00:00
1 parent 69159d194f
commit bcac151410
1 file changed
+8 -2
@@ -256,12 +256,18 @@ public class EventListener {
plugin.getDatabase() plugin.getDatabase()
.getRespawnPosition(onlineUser) .getRespawnPosition(onlineUser)
.flatMap(pos -> {
if (pos.getServer().equals(plugin.getServerName()) && onlineUser.getBedSpawnPosition().isEmpty()) {
return Optional.empty();
}
return Optional.of(pos);
})
.or(() -> { .or(() -> {
builder.type(Teleport.Type.TELEPORT); builder.type(Teleport.Type.TELEPORT);
return plugin.getSpawn(); return plugin.getSpawn();
}) })
.ifPresent(position -> { .ifPresent(pos -> {
builder.target(position); builder.target(pos);
try { try {
builder.toTeleport().execute(); builder.toTeleport().execute();
} catch (TeleportationException e) { } catch (TeleportationException e) {