mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Simplify global respawn logic
This commit is contained in:
1 file changed
+4
-13
@@ -195,25 +195,16 @@ public class EventListener {
|
||||
|
||||
// Respawn the player cross-server if needed
|
||||
if (plugin.getSettings().doCrossServer() && plugin.getSettings().isGlobalRespawning()) {
|
||||
plugin.getDatabase().getRespawnPosition(onlineUser).ifPresentOrElse(respawnPosition -> {
|
||||
if (!respawnPosition.getServer().equals(plugin.getServerName())) {
|
||||
plugin.getDatabase().getRespawnPosition(onlineUser).or(plugin::getSpawn).ifPresent(position -> {
|
||||
if (!position.getServer().equals(plugin.getServerName())) {
|
||||
Teleport.builder(plugin)
|
||||
.teleporter(onlineUser)
|
||||
.type(Teleport.Type.RESPAWN)
|
||||
.target(respawnPosition)
|
||||
.target(position)
|
||||
.toTeleport()
|
||||
.execute();
|
||||
}
|
||||
}, () -> plugin.getSpawn().ifPresent(spawn -> {
|
||||
if (!spawn.getServer().equals(plugin.getServerName())) {
|
||||
Teleport.builder(plugin)
|
||||
.teleporter(onlineUser)
|
||||
.type(Teleport.Type.RESPAWN)
|
||||
.target(spawn)
|
||||
.toTeleport()
|
||||
.execute();
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user