use of de.dytanic.cloudnet.lib.player.CloudPlayer in project CloudNet by Dytanic.
the class ProxiedListener method handlePlayerServerSwitch.
@EventHandler(priority = EventPriority.HIGHEST)
public void handlePlayerServerSwitch(ServerSwitchEvent e) {
CloudPlayer cloudPlayer = CloudProxy.getInstance().getCloudPlayers().get(e.getPlayer().getUniqueId());
cloudPlayer.setServer(e.getPlayer().getServer().getInfo().getName());
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutUpdateOnlinePlayer(cloudPlayer));
CloudAPI.getInstance().sendCustomSubProxyMessage("cloudnet_internal", "player_server_switch", new Document("player", cloudPlayer).append("server", e.getPlayer().getServer().getInfo().getName()));
if (CloudProxy.getInstance().getProxyGroup() != null && CloudProxy.getInstance().getProxyGroup().getProxyConfig().isEnabled() && CloudProxy.getInstance().getProxyGroup().getProxyConfig().getTabList().isEnabled())
initTabHeaderFooter(e.getPlayer());
}
use of de.dytanic.cloudnet.lib.player.CloudPlayer in project CloudNet by Dytanic.
the class CloudAPI method getOfflinePlayer.
/**
* Returns a offline player which registerd or null
*
* @param uniqueId
*/
public OfflinePlayer getOfflinePlayer(UUID uniqueId) {
CloudPlayer cloudPlayer = checkAndGet(uniqueId);
if (cloudPlayer != null)
return cloudPlayer;
Result result = networkConnection.getPacketManager().sendQuery(new PacketAPIOutGetOfflinePlayer(uniqueId), networkConnection);
return result.getResult().getObject("player", new TypeToken<OfflinePlayer>() {
}.getType());
}
use of de.dytanic.cloudnet.lib.player.CloudPlayer 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);
}
use of de.dytanic.cloudnet.lib.player.CloudPlayer in project CloudNet by Dytanic.
the class CloudNet method bootstrap.
@Override
public boolean bootstrap() throws Exception {
if (!optionSet.has("disable-autoupdate"))
checkForUpdates();
dbHandlers = new DatabaseBasicHandlers(databaseManager);
dbHandlers.getStatisticManager().addStartup();
this.moduleManager.setDisabledModuleList(config.getDisabledModules());
if (!optionSet.has("disable-modules")) {
System.out.println("Loading Modules...");
moduleManager.loadModules();
}
for (WrapperMeta wrapperMeta : config.getWrappers()) {
System.out.println("Loading Wrapper " + wrapperMeta.getId() + " @ " + wrapperMeta.getHostName());
this.wrappers.put(wrapperMeta.getId(), new Wrapper(wrapperMeta));
}
// Packet Init
this.users = config.getUsers();
// Groups Loading
NetworkUtils.addAll(this.serverGroups, config.getServerGroups(), new Acceptable<ServerGroup>() {
@Override
public boolean isAccepted(ServerGroup value) {
System.out.println("Loading ServerGroup: " + value.getName());
setupGroup(value);
return true;
}
});
NetworkUtils.addAll(this.proxyGroups, config.getProxyGroups(), new Acceptable<ProxyGroup>() {
@Override
public boolean isAccepted(ProxyGroup value) {
System.out.println("Loading ProxyGroup: " + value.getName());
setupProxy(value);
return true;
}
});
webServer = new WebServer(optionSet.has("ssl"), config.getWebServerConfig().getAddress(), config.getWebServerConfig().getPort());
// CommandManager Appending
this.initialCommands();
this.initWebHandlers();
this.initPacketHandlers();
// Scheduler Startup
{
Thread thread = new Thread(scheduler);
thread.setDaemon(true);
thread.start();
}
{
Thread thread = new Thread(subScheduler);
thread.setDaemon(true);
thread.start();
}
for (ConnectableAddress connectableAddress : config.getAddresses()) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
new CloudNetServer(optionSet, connectableAddress);
}
});
thread.setDaemon(true);
thread.start();
}
webServer.bind();
RUNNING = true;
Runtime.getRuntime().addShutdownHook(new Thread(this));
/*==================================*/
{
if (!optionSet.has("onlyConsole")) {
CloudStartupHandler cloudStartupHandler = new CloudStartupHandler();
CloudPriorityStartupHandler cloudPriorityStartupHandler = new CloudPriorityStartupHandler();
CloudPriorityGroupStartupHandler cloudPriorityGroupStartupHandler = new CloudPriorityGroupStartupHandler();
CloudPlayerRemoverHandler cloudPlayerRemoverHandler = new CloudPlayerRemoverHandler();
scheduler.runTaskRepeatSync(cloudStartupHandler, 0, cloudStartupHandler.getTicks());
scheduler.runTaskRepeatSync(cloudPriorityGroupStartupHandler, 0, cloudPriorityGroupStartupHandler.getTicks());
scheduler.runTaskRepeatSync(cloudPriorityStartupHandler, 0, cloudPriorityStartupHandler.getTicks());
scheduler.runTaskRepeatSync(cloudPlayerRemoverHandler, 0, cloudPlayerRemoverHandler.getTicks());
}
CloudStopCheckHandler cloudStopCheck = new CloudStopCheckHandler();
scheduler.runTaskRepeatSync(cloudStopCheck, 0, cloudStopCheck.getTicks());
scheduler.runTaskRepeatSync(serverLogManager, 0, 2000);
scheduler.runTaskRepeatSync(new Runnable() {
@Override
public void run() {
for (CloudPlayer cloudPlayer : networkManager.getWaitingPlayers().values()) {
if ((cloudPlayer.getLoginTimeStamp().getTime() + 10000L) < System.currentTimeMillis()) {
networkManager.getWaitingPlayers().remove(cloudPlayer.getUniqueId());
}
}
}
}, 0, 100);
}
if (!optionSet.has("disable-modules"))
System.out.println("Enabling Modules...");
moduleManager.enableModules();
// Event Init
eventManager.callEvent(new CloudInitEvent());
new LocalCloudWrapper().run(optionSet);
return true;
}
Aggregations