if (message.getStatus() == PlayerStatusMessage.INITIAL_SPAWN) {
server.getEventManager().callEvent(new PlayerConnectEvent(session, (String) session.getDataMap().get("username"), 10));
if (server.debugMode()) {
server.getLogger().info("Login took " + (System.currentTimeMillis() - session.getDataMap().get(VanillaProtocol.LOGIN_TIME)) + " ms");
}
final ManagedMap data = session.getPlayer().getWorld().getData();
final Human human = session.getPlayer().add(Human.class);
final Difficulty difficulty = data.get(VanillaData.DIFFICULTY);
final Dimension dimension = data.get(VanillaData.DIMENSION);
final WorldType worldType = data.get(VanillaData.WORLD_TYPE);
GameMode gamemode;
int entityId = session.getPlayer().getId();
// MC Packet Order: 0x01 Login, 0xFA Custom (ServerTypeName), 0x06 SpawnPos, 0xCA PlayerAbilities, 0x10 BlockSwitch
gamemode = data.get(VanillaData.GAMEMODE);
final PlayerLoginRequestMessage idMsg = new PlayerLoginRequestMessage(entityId, worldType.toString(), gamemode.getId(), (byte) dimension.getId(), difficulty.getId(), (byte) server.getMaxPlayers());
session.send(Session.SendType.FORCE, idMsg);
session.setState(Session.State.GAME);
if (human.getAttachedCount() <= 1) {
// If we haven't logged in before, we want to set all abilities to the default gamemode