Search in sources :

Example 16 with CloudPlayer

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());
}
Also used : CloudPlayer(de.dytanic.cloudnet.lib.player.CloudPlayer) Document(de.dytanic.cloudnet.lib.utility.document.Document) EventHandler(net.md_5.bungee.event.EventHandler)

Example 17 with CloudPlayer

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());
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) CloudPlayer(de.dytanic.cloudnet.lib.player.CloudPlayer) Result(de.dytanic.cloudnet.lib.network.protocol.packet.result.Result)

Example 18 with CloudPlayer

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);
}
Also used : PlayerDatabase(de.dytanic.cloudnetcore.database.PlayerDatabase) CloudPlayer(de.dytanic.cloudnet.lib.player.CloudPlayer) OfflinePlayer(de.dytanic.cloudnet.lib.player.OfflinePlayer)

Example 19 with 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;
}
Also used : LocalCloudWrapper(de.dytanic.cloudnetcore.setup.LocalCloudWrapper) ProxyGroup(de.dytanic.cloudnet.lib.server.ProxyGroup) CloudPlayer(de.dytanic.cloudnet.lib.player.CloudPlayer) CloudInitEvent(de.dytanic.cloudnetcore.api.event.network.CloudInitEvent) ConnectableAddress(de.dytanic.cloudnet.lib.ConnectableAddress) CloudNetServer(de.dytanic.cloudnetcore.network.CloudNetServer) DatabaseBasicHandlers(de.dytanic.cloudnetcore.database.DatabaseBasicHandlers) WebServer(de.dytanic.cloudnet.web.server.WebServer) LocalCloudWrapper(de.dytanic.cloudnetcore.setup.LocalCloudWrapper)

Aggregations

CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)19 TypeToken (com.google.gson.reflect.TypeToken)5 Result (de.dytanic.cloudnet.lib.network.protocol.packet.result.Result)4 OfflinePlayer (de.dytanic.cloudnet.lib.player.OfflinePlayer)3 ProxyGroup (de.dytanic.cloudnet.lib.server.ProxyGroup)3 Document (de.dytanic.cloudnet.lib.utility.document.Document)3 EventHandler (net.md_5.bungee.event.EventHandler)3 PlayerConnection (de.dytanic.cloudnet.lib.player.PlayerConnection)2 GroupEntityData (de.dytanic.cloudnet.lib.player.permission.GroupEntityData)2 MinecraftServer (de.dytanic.cloudnetcore.network.components.MinecraftServer)2 ProxyServer (de.dytanic.cloudnetcore.network.components.ProxyServer)2 NetworkHandler (de.dytanic.cloudnet.api.handlers.NetworkHandler)1 PlayerExecutorBridge (de.dytanic.cloudnet.api.player.PlayerExecutorBridge)1 CloudPermissble (de.dytanic.cloudnet.bridge.internal.util.CloudPermissble)1 CloudPlayerCommandSender (de.dytanic.cloudnet.bridge.internal.util.CloudPlayerCommandSender)1 ConnectableAddress (de.dytanic.cloudnet.lib.ConnectableAddress)1 WrapperInfo (de.dytanic.cloudnet.lib.network.WrapperInfo)1 PlayerExecutor (de.dytanic.cloudnet.lib.player.PlayerExecutor)1 PermissionEntity (de.dytanic.cloudnet.lib.player.permission.PermissionEntity)1 AutoSlot (de.dytanic.cloudnet.lib.proxylayout.AutoSlot)1