Search in sources :

Example 16 with Server

use of net.md_5.bungee.api.connection.Server 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 Server

use of net.md_5.bungee.api.connection.Server in project CloudNet by Dytanic.

the class CommandCloudDev method execute.

@Override
public void execute(CommandSender commandSender, String[] args) {
    if (!(commandSender instanceof ProxiedPlayer))
        return;
    switch(args.length) {
        case 0:
            for (ServerInfo serverInfo : CloudProxy.getInstance().getCachedServers().values()) {
                if (serverInfo.getServerConfig().getProperties().contains(NetworkUtils.DEV_PROPERTY)) {
                    DevService service = serverInfo.getServerConfig().getProperties().getObject(NetworkUtils.DEV_PROPERTY, DevService.class);
                    if (service.getUniqueId().equals(((ProxiedPlayer) commandSender).getUniqueId())) {
                        ((ProxiedPlayer) commandSender).connect(ProxyServer.getInstance().getServerInfo(serverInfo.getServiceId().getServerId()));
                        return;
                    }
                }
            }
            commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cdev forTemplate <group> <template>");
            commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cdev forTemplate <group>");
            commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cdev testServer <group>");
            commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cdev testServer <group> <template>");
            break;
        case 2:
            {
                for (ServerInfo serverInfo : CloudProxy.getInstance().getCachedServers().values()) {
                    if (serverInfo.getServerConfig().getProperties().contains(NetworkUtils.DEV_PROPERTY)) {
                        DevService service = serverInfo.getServerConfig().getProperties().getObject(NetworkUtils.DEV_PROPERTY, DevService.class);
                        if (service.getUniqueId().equals(((ProxiedPlayer) commandSender).getUniqueId())) {
                            ((ProxiedPlayer) commandSender).connect(ProxyServer.getInstance().getServerInfo(serverInfo.getServiceId().getServerId()));
                            return;
                        }
                    }
                }
                if (args[0].equalsIgnoreCase("forTemplate")) {
                    if (!CloudAPI.getInstance().getServerGroupMap().containsKey(args[1])) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The group doesn't exist");
                        return;
                    }
                    ServerConfig serverConfig = new ServerConfig(true, commandSender.getName(), new Document(NetworkUtils.DEV_PROPERTY, new DevService(((ProxiedPlayer) commandSender).getUniqueId(), true)), System.currentTimeMillis());
                    CloudAPI.getInstance().startGameServer(CloudAPI.getInstance().getServerGroupData(args[1]), serverConfig, "Dev" + args[1] + "-" + commandSender.getName());
                    ((ProxiedPlayer) commandSender).sendMessage(CloudAPI.getInstance().getPrefix() + "The server will start up now...");
                    return;
                }
                if (args[0].equalsIgnoreCase("testServer")) {
                    if (!CloudAPI.getInstance().getServerGroupMap().containsKey(args[1])) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The group doesn't exist");
                        return;
                    }
                    ServerConfig serverConfig = new ServerConfig(true, commandSender.getName(), new Document(), System.currentTimeMillis());
                    CloudAPI.getInstance().startCloudServer("TestServer-" + ((ProxiedPlayer) commandSender).getUniqueId(), serverConfig, 356, true);
                    ((ProxiedPlayer) commandSender).sendMessage(CloudAPI.getInstance().getPrefix() + "The server will start up now...");
                    return;
                }
            }
        case 3:
            {
                for (ServerInfo serverInfo : CloudProxy.getInstance().getCachedServers().values()) {
                    if (serverInfo.getServerConfig().getProperties().contains(NetworkUtils.DEV_PROPERTY)) {
                        DevService service = serverInfo.getServerConfig().getProperties().getObject(NetworkUtils.DEV_PROPERTY, DevService.class);
                        if (service.getUniqueId().equals(((ProxiedPlayer) commandSender).getUniqueId())) {
                            ((ProxiedPlayer) commandSender).connect(ProxyServer.getInstance().getServerInfo(serverInfo.getServiceId().getServerId()));
                            return;
                        }
                    }
                }
                if (args[0].equalsIgnoreCase("forTemplate")) {
                    if (!CloudAPI.getInstance().getServerGroupMap().containsKey(args[1])) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The group doesn't exist");
                        return;
                    }
                    ServerGroup serverGroup = CloudAPI.getInstance().getServerGroup(args[1]);
                    if (CollectionWrapper.filter(serverGroup.getTemplates(), new Acceptable<Template>() {

                        @Override
                        public boolean isAccepted(Template template) {
                            return template.getName().equalsIgnoreCase(args[2]);
                        }
                    }) == null) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The template doesn't exist");
                        return;
                    }
                    ServerConfig serverConfig = new ServerConfig(true, commandSender.getName(), new Document(NetworkUtils.DEV_PROPERTY, new DevService(((ProxiedPlayer) commandSender).getUniqueId(), true)), System.currentTimeMillis());
                    CloudAPI.getInstance().startGameServer(CloudAPI.getInstance().getServerGroupData(args[1]), serverConfig, CloudAPI.getInstance().getServerGroupData(args[1]).getMemory(), true, new Properties(), CollectionWrapper.filter(serverGroup.getTemplates(), new Acceptable<Template>() {

                        @Override
                        public boolean isAccepted(Template e) {
                            return e.getName().equalsIgnoreCase(args[2]);
                        }
                    }), "Dev" + args[1] + "-" + commandSender.getName());
                    ((ProxiedPlayer) commandSender).sendMessage(CloudAPI.getInstance().getPrefix() + "The server will start up now...");
                    return;
                }
                if (args[0].equalsIgnoreCase("testServer")) {
                    if (!CloudAPI.getInstance().getServerGroupMap().containsKey(args[1])) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The group doesn't exist");
                        return;
                    }
                    ServerGroup serverGroup = CloudAPI.getInstance().getServerGroup(args[1]);
                    if (CollectionWrapper.filter(serverGroup.getTemplates(), new Acceptable<Template>() {

                        @Override
                        public boolean isAccepted(Template template) {
                            return template.getName().equalsIgnoreCase(args[2]);
                        }
                    }) == null) {
                        commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The template doesn't exist");
                        return;
                    }
                    ServerConfig serverConfig = new ServerConfig(true, commandSender.getName(), new Document(), System.currentTimeMillis());
                    /*
                    CloudAPI.getInstance().startGameServer(CloudAPI.getInstance().getServerGroupData(args[1]), serverConfig,
                            CloudAPI.getInstance().getServerGroupData(args[1]).getMemory(),
                            new String[0], null, "TestServer-" + commandSender.getName(), false, true, new Properties(),
                            null, Arrays.asList()
                            , "Dev" + args[1] + "-" + commandSender.getName());
                    */
                    CloudAPI.getInstance().startCloudServer("TestServer-" + ((ProxiedPlayer) commandSender).getUniqueId(), serverConfig, 356, true);
                    ((ProxiedPlayer) commandSender).sendMessage(CloudAPI.getInstance().getPrefix() + "The server will start up now...");
                    return;
                }
            }
            break;
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) ServerConfig(de.dytanic.cloudnet.lib.server.ServerConfig) ServerGroup(de.dytanic.cloudnet.lib.server.ServerGroup) ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo) DevService(de.dytanic.cloudnet.lib.server.advanced.DevService) Document(de.dytanic.cloudnet.lib.utility.document.Document) Properties(java.util.Properties) Template(de.dytanic.cloudnet.lib.server.template.Template)

Example 18 with Server

use of net.md_5.bungee.api.connection.Server in project ChangeSkin by games647.

the class SkinApplier method run.

@Override
public void run() {
    if (!isConnected()) {
        return;
    }
    UUID receiverUUID = receiver.getUniqueId();
    if (invoker instanceof ProxiedPlayer) {
        if (targetSkin != null && core.getConfig().getBoolean("bukkit-permissions")) {
            Server server = ((ProxiedPlayer) invoker).getServer();
            boolean skinPerm = core.getConfig().getBoolean("skinPermission");
            ChannelMessage message = new CheckPermMessage(targetSkin, receiverUUID, skinPerm, bukkitOp);
            plugin.sendPluginMessage(server, message);
            return;
        }
        // uuid was successful resolved, we could now make a cooldown check
        core.getCooldownService().trackPlayer(((ProxiedPlayer) invoker).getUniqueId());
    }
    // check if that specific player is online
    UserPreference preferences = plugin.getLoginSession(receiver.getPendingConnection());
    if (preferences == null) {
        preferences = plugin.getStorage().getPreferences(receiverUUID);
    }
    save(preferences);
    applySkin();
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Server(net.md_5.bungee.api.connection.Server) CheckPermMessage(com.github.games647.changeskin.core.message.CheckPermMessage) UserPreference(com.github.games647.changeskin.core.model.UserPreference) UUID(java.util.UUID) ChannelMessage(com.github.games647.changeskin.core.message.ChannelMessage)

Example 19 with Server

use of net.md_5.bungee.api.connection.Server in project Parties by AlessioDP.

the class BungeeListener method sendPlayerServer.

private void sendPlayerServer(String uuid, String server, String message) {
    ServerInfo s = plugin.getProxy().getServerInfo(server);
    if (message != null && !message.isEmpty())
        plugin.getProxy().getPlayer(UUID.fromString(uuid)).sendMessage(TextComponent.fromLegacyText(message));
    plugin.getProxy().getPlayer(UUID.fromString(uuid)).connect(s);
}
Also used : ServerInfo(net.md_5.bungee.api.config.ServerInfo)

Example 20 with Server

use of net.md_5.bungee.api.connection.Server in project Parties by AlessioDP.

the class BungeeMetrics method loadConfig.

/**
 * Loads the bStats configuration.
 *
 * @throws IOException If something did not work :(
 */
private void loadConfig() throws IOException {
    Path configPath = plugin.getDataFolder().toPath().getParent().resolve("bStats");
    configPath.toFile().mkdirs();
    File configFile = new File(configPath.toFile(), "config.yml");
    if (!configFile.exists()) {
        writeFile(configFile, "#bStats collects some data for plugin authors like how many servers are using their plugins.", "#To honor their work, you should not disable it.", "#This has nearly no effect on the server performance!", "#Check out https://bStats.org/ to learn more :)", "enabled: true", "serverUuid: \"" + UUID.randomUUID().toString() + "\"", "logFailedRequests: false");
    }
    Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
    // Load configuration
    enabled = configuration.getBoolean("enabled", true);
    serverUUID = configuration.getString("serverUuid");
    logFailedRequests = configuration.getBoolean("logFailedRequests", false);
}
Also used : Path(java.nio.file.Path) Configuration(net.md_5.bungee.config.Configuration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) File(java.io.File)

Aggregations

EventHandler (net.md_5.bungee.event.EventHandler)6 Document (de.dytanic.cloudnet.lib.utility.document.Document)5 ServerInfo (net.md_5.bungee.api.config.ServerInfo)5 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)5 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)4 File (java.io.File)4 Configuration (net.md_5.bungee.config.Configuration)4 YamlConfiguration (net.md_5.bungee.config.YamlConfiguration)4 Path (java.nio.file.Path)3 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)3 TextComponent (net.md_5.bungee.api.chat.TextComponent)3 UserPreference (com.github.games647.changeskin.core.model.UserPreference)2 ConnectableAddress (de.dytanic.cloudnet.lib.ConnectableAddress)2 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)2 ServerConfig (de.dytanic.cloudnet.lib.server.ServerConfig)2 ServerGroup (de.dytanic.cloudnet.lib.server.ServerGroup)2 Template (de.dytanic.cloudnet.lib.server.template.Template)2 ServerInstallablePlugin (de.dytanic.cloudnet.lib.service.plugin.ServerInstallablePlugin)2 SimpledUser (de.dytanic.cloudnet.lib.user.SimpledUser)2 Properties (java.util.Properties)2