Init player before setting its instance

This commit is contained in:
TheMode 2021-08-11 16:15:56 +02:00
parent ea951f9566
commit 8ff4f9432c

View File

@ -371,14 +371,10 @@ public final class ConnectionManager {
PlayerLoginEvent loginEvent = new PlayerLoginEvent(waitingPlayer);
EventDispatcher.call(loginEvent);
final Instance spawningInstance = loginEvent.getSpawningInstance();
Check.notNull(spawningInstance, "You need to specify a spawning instance in the PlayerLoginEvent");
// Spawn the player at Player#getRespawnPoint during the next instance tick
Player finalWaitingPlayer = waitingPlayer;
spawningInstance.scheduleNextTick(instance -> {
finalWaitingPlayer.UNSAFE_init(spawningInstance);
finalWaitingPlayer.setInstance(spawningInstance);
});
waitingPlayer.UNSAFE_init(spawningInstance);
spawningInstance.scheduleNextTick(waitingPlayer::setInstance);
}
}