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());
}
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;
}
}
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();
}
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);
}
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);
}
Aggregations