use of de.dytanic.cloudnetcore.database.PlayerDatabase in project CloudNet by Dytanic.
the class NetworkManager method handlePlayerLoginRequest.
public void handlePlayerLoginRequest(ProxyServer proxyServer, PlayerConnection cloudPlayerConnection, UUID uniqueId) {
if (this.onlinePlayers.containsKey(cloudPlayerConnection.getUniqueId())) {
proxyServer.sendPacketSynchronized(new PacketOutLoginPlayer(uniqueId, null));
return;
}
LoginRequestEvent loginRequestEvent = new LoginRequestEvent(proxyServer, cloudPlayerConnection);
CloudNet.getInstance().getEventManager().callEvent(loginRequestEvent);
PlayerDatabase playerDatabase = CloudNet.getInstance().getDbHandlers().getPlayerDatabase();
OfflinePlayer offlinePlayer = null;
if (!playerDatabase.containsPlayer(cloudPlayerConnection.getUniqueId()))
offlinePlayer = playerDatabase.registerPlayer(cloudPlayerConnection);
if (offlinePlayer == null)
offlinePlayer = playerDatabase.getPlayer(cloudPlayerConnection.getUniqueId());
CloudPlayer cloudPlayer = new CloudPlayer(offlinePlayer, cloudPlayerConnection, proxyServer.getServerId());
cloudPlayer.setPlayerExecutor(CorePlayerExecutor.INSTANCE);
if (cloudPlayer.getFirstLogin() != null)
cloudPlayer.setFirstLogin(System.currentTimeMillis());
CloudNet.getInstance().getEventManager().callEvent(new PlayerInitEvent(cloudPlayer));
CloudNet.getInstance().getDbHandlers().getNameToUUIDDatabase().append(new MultiValue<>(cloudPlayerConnection.getName(), cloudPlayerConnection.getUniqueId()));
CloudNet.getInstance().getDbHandlers().getNameToUUIDDatabase().replace(new MultiValue<>(cloudPlayerConnection.getUniqueId(), cloudPlayerConnection.getName()));
cloudPlayer.setName(cloudPlayerConnection.getName());
CloudNet.getInstance().getDbHandlers().getPlayerDatabase().updatePlayer(CloudPlayer.newOfflinePlayer(cloudPlayer));
proxyServer.sendPacketSynchronized(new PacketOutLoginPlayer(uniqueId, cloudPlayer));
this.waitingPlayers.put(cloudPlayer.getUniqueId(), cloudPlayer);
handlePlayerLogin(cloudPlayer);
}
Aggregations