Don't add players to the waiting list in the constructor, but in the registration method

This commit is contained in:
themode 2020-12-28 12:41:15 +01:00
parent 924fac562b
commit 87e8e550f1
4 changed files with 7 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import com.google.common.collect.Queues;
import net.minestom.server.MinecraftServer;
import net.minestom.server.chat.ChatColor;
import net.minestom.server.chat.ColoredText;
import net.minestom.server.entity.fakeplayer.FakePlayerOption;
import net.minestom.server.event.player.AsyncPlayerPreLoginEvent;
import net.minestom.server.event.player.PlayerLoginEvent;
import net.minestom.server.instance.Instance;
@ -79,9 +80,10 @@ public final class EntityManager {
* If the {@link Player} hasn't been kicked, add him to the waiting list.
* <p>
* Can be considered as a pre-init thing,
* currently executed in {@link Player#Player(UUID, String, PlayerConnection)}.
* currently executed in {@link ConnectionManager#createPlayer(UUID, String, PlayerConnection)}
* and {@link net.minestom.server.entity.fakeplayer.FakePlayer#initPlayer(UUID, String, FakePlayerOption, Consumer)}.
*
* @param player the {@link Player} to add
* @param player the {@link Player player} to add to the waiting list
*/
public void addWaitingPlayer(@NotNull Player player) {

View File

@ -220,8 +220,6 @@ public class Player extends LivingEntity implements CommandSender {
// FakePlayer init its connection there
playerConnectionInit();
MinecraftServer.getEntityManager().addWaitingPlayer(this);
}
/**

View File

@ -63,6 +63,8 @@ public class FakePlayer extends Player {
}
});
}
MinecraftServer.getEntityManager().addWaitingPlayer(fakePlayer);
}
/**

View File

@ -334,6 +334,7 @@ public final class ConnectionManager {
public Player createPlayer(@NotNull UUID uuid, @NotNull String username, @NotNull PlayerConnection connection) {
final Player player = getPlayerProvider().createPlayer(uuid, username, connection);
createPlayer(player);
MinecraftServer.getEntityManager().addWaitingPlayer(player);
return player;
}