chore: pre-commit changes [skip ci]

This commit is contained in:
github-actions[bot] 2024-11-13 11:02:32 +00:00 committed by Sekwah
parent dd72123d4b
commit d687e88e65
27 changed files with 692 additions and 694 deletions

View File

@ -1,25 +1,25 @@
package com.sekwah.advancedportals.bungee;
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyContainer;
import com.sekwah.advancedportals.core.ProxyMessages;
import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore;
import net.md_5.bungee.api.plugin.Plugin;
public class AdvancedPortalsBungeePlugin extends Plugin {
private AdvancedPortalsProxyCore proxyCore;
@Override
public void onEnable() {
this.proxyCore = new AdvancedPortalsProxyCore(new BungeeInfoLogger(this), new BungeeProxyContainer(this));
this.proxyCore.onEnable();
getProxy().registerChannel(ProxyMessages.CHANNEL_NAME);
getProxy().getPluginManager().registerListener(this, new EventListener(this, this.proxyCore));
}
@Override
public void onDisable() {
this.proxyCore.onDisable();
}
}
package com.sekwah.advancedportals.bungee;
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyContainer;
import com.sekwah.advancedportals.core.ProxyMessages;
import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore;
import net.md_5.bungee.api.plugin.Plugin;
public class AdvancedPortalsBungeePlugin extends Plugin {
private AdvancedPortalsProxyCore proxyCore;
@Override
public void onEnable() {
this.proxyCore = new AdvancedPortalsProxyCore(new BungeeInfoLogger(this), new BungeeProxyContainer(this));
this.proxyCore.onEnable();
getProxy().registerChannel(ProxyMessages.CHANNEL_NAME);
getProxy().getPluginManager().registerListener(this, new EventListener(this, this.proxyCore));
}
@Override
public void onDisable() {
this.proxyCore.onDisable();
}
}

View File

@ -1,47 +1,47 @@
package com.sekwah.advancedportals.bungee;
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyPlayerContainer;
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyServerContainer;
import com.sekwah.advancedportals.core.ProxyMessages;
import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.ServerConnectedEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
public class EventListener implements Listener {
private final AdvancedPortalsBungeePlugin plugin;
private final AdvancedPortalsProxyCore proxyCore;
public EventListener(AdvancedPortalsBungeePlugin plugin, AdvancedPortalsProxyCore proxyCore) {
this.plugin = plugin;
this.proxyCore = proxyCore;
}
@EventHandler
public void onMessageReceived(PluginMessageEvent event) {
if(!event.getTag().equalsIgnoreCase(ProxyMessages.CHANNEL_NAME)) return;
event.setCancelled(true);
if(!(event.getSender() instanceof Server)) return;
if(event.getReceiver() instanceof ProxiedPlayer player) {
this.proxyCore.incomingMessage(new BungeeProxyPlayerContainer(player), event.getData());
}
}
@EventHandler
public void onServerConnected(ServerConnectedEvent event) {
this.proxyCore.onServerConnect(new BungeeProxyServerContainer(event.getServer()), new BungeeProxyPlayerContainer(event.getPlayer()));
}
@EventHandler
public void onDisconnect(PlayerDisconnectEvent event) {
this.proxyCore.onPlayerDisconnect(new BungeeProxyPlayerContainer(event.getPlayer()));
}
}
package com.sekwah.advancedportals.bungee;
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyPlayerContainer;
import com.sekwah.advancedportals.bungee.connector.container.BungeeProxyServerContainer;
import com.sekwah.advancedportals.core.ProxyMessages;
import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.ServerConnectedEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
public class EventListener implements Listener {
private final AdvancedPortalsBungeePlugin plugin;
private final AdvancedPortalsProxyCore proxyCore;
public EventListener(AdvancedPortalsBungeePlugin plugin, AdvancedPortalsProxyCore proxyCore) {
this.plugin = plugin;
this.proxyCore = proxyCore;
}
@EventHandler
public void onMessageReceived(PluginMessageEvent event) {
if(!event.getTag().equalsIgnoreCase(ProxyMessages.CHANNEL_NAME)) return;
event.setCancelled(true);
if(!(event.getSender() instanceof Server)) return;
if(event.getReceiver() instanceof ProxiedPlayer player) {
this.proxyCore.incomingMessage(new BungeeProxyPlayerContainer(player), event.getData());
}
}
@EventHandler
public void onServerConnected(ServerConnectedEvent event) {
this.proxyCore.onServerConnect(new BungeeProxyServerContainer(event.getServer()), new BungeeProxyPlayerContainer(event.getPlayer()));
}
@EventHandler
public void onDisconnect(PlayerDisconnectEvent event) {
this.proxyCore.onPlayerDisconnect(new BungeeProxyPlayerContainer(event.getPlayer()));
}
}

View File

@ -1,38 +1,38 @@
package com.sekwah.advancedportals.bungee.connector.container;
import com.sekwah.advancedportals.bungee.AdvancedPortalsBungeePlugin;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import net.md_5.bungee.api.chat.TextComponent;
public class BungeeProxyContainer implements ProxyContainer {
private final AdvancedPortalsBungeePlugin plugin;
public BungeeProxyContainer(AdvancedPortalsBungeePlugin plugin) {
this.plugin = plugin;
}
@Override
public void invokeCommand(ProxyPlayerContainer proxyPlayer, String command) {
// Should never not be true but just to be safe
if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) {
plugin.getProxy().getPluginManager().dispatchCommand(playerContainer.getPlayer(), command);
}
}
@Override
public void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName) {
// Should never not be true but just to be safe
if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) {
var serverInfo = plugin.getProxy().getServerInfo(serverName);
var player = playerContainer.getPlayer();
if(serverInfo == null) {
player.sendMessage(new TextComponent(Lang.convertColors("&cCould not find server: &e") + serverName));
return;
}
player.connect(serverInfo);
}
}
}
package com.sekwah.advancedportals.bungee.connector.container;
import com.sekwah.advancedportals.bungee.AdvancedPortalsBungeePlugin;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import net.md_5.bungee.api.chat.TextComponent;
public class BungeeProxyContainer implements ProxyContainer {
private final AdvancedPortalsBungeePlugin plugin;
public BungeeProxyContainer(AdvancedPortalsBungeePlugin plugin) {
this.plugin = plugin;
}
@Override
public void invokeCommand(ProxyPlayerContainer proxyPlayer, String command) {
// Should never not be true but just to be safe
if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) {
plugin.getProxy().getPluginManager().dispatchCommand(playerContainer.getPlayer(), command);
}
}
@Override
public void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName) {
// Should never not be true but just to be safe
if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) {
var serverInfo = plugin.getProxy().getServerInfo(serverName);
var player = playerContainer.getPlayer();
if(serverInfo == null) {
player.sendMessage(new TextComponent(Lang.convertColors("&cCould not find server: &e") + serverName));
return;
}
player.connect(serverInfo);
}
}
}

View File

@ -1,33 +1,33 @@
package com.sekwah.advancedportals.bungee.connector.container;
import com.sekwah.advancedportals.core.ProxyMessages;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class BungeeProxyPlayerContainer implements ProxyPlayerContainer {
private final ProxiedPlayer player;
public BungeeProxyPlayerContainer(ProxiedPlayer player) {
this.player = player;
}
public ProxiedPlayer getPlayer() {
return this.player;
}
@Override
public String getUUID() {
return this.player.getUniqueId().toString();
}
@Override
public String getName() {
return this.player.getName();
}
public void sendServerPluginMessage(byte[] data) {
this.player.getServer().sendData(ProxyMessages.CHANNEL_NAME, data);
}
}
package com.sekwah.advancedportals.bungee.connector.container;
import com.sekwah.advancedportals.core.ProxyMessages;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class BungeeProxyPlayerContainer implements ProxyPlayerContainer {
private final ProxiedPlayer player;
public BungeeProxyPlayerContainer(ProxiedPlayer player) {
this.player = player;
}
public ProxiedPlayer getPlayer() {
return this.player;
}
@Override
public String getUUID() {
return this.player.getUniqueId().toString();
}
@Override
public String getName() {
return this.player.getName();
}
public void sendServerPluginMessage(byte[] data) {
this.player.getServer().sendData(ProxyMessages.CHANNEL_NAME, data);
}
}

View File

@ -1,17 +1,17 @@
package com.sekwah.advancedportals.bungee.connector.container;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer;
import net.md_5.bungee.api.connection.Server;
public class BungeeProxyServerContainer implements ProxyServerContainer {
private final Server server;
public BungeeProxyServerContainer(Server server) {
this.server = server;
}
@Override
public String getServerName() {
return this.server.getInfo().getName();
}
}
package com.sekwah.advancedportals.bungee.connector.container;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer;
import net.md_5.bungee.api.connection.Server;
public class BungeeProxyServerContainer implements ProxyServerContainer {
private final Server server;
public BungeeProxyServerContainer(Server server) {
this.server = server;
}
@Override
public String getServerName() {
return this.server.getInfo().getName();
}
}

View File

@ -1,4 +1,4 @@
main: com.sekwah.advancedportals.bungee.AdvancedPortalsBungeePlugin
name: AdvancedPortals
version: ${pluginVersion}
author: sekwah41
main: com.sekwah.advancedportals.bungee.AdvancedPortalsBungeePlugin
name: AdvancedPortals
version: ${pluginVersion}
author: sekwah41

View File

@ -50,4 +50,3 @@ def generateTemplates = tasks.register('generateTemplates', Copy) { task ->
}
sourceSets.main.java.srcDir(generateTemplates.map { it.outputs })

View File

@ -1,18 +1,18 @@
package com.sekwah.advancedportals.core;
/**
* messages going to the proxy will start with proxy: messages going to the server will start with server:
*/
public class ProxyMessages {
/**
* Could split by channel messages we will handle it ourselves
*/
public static final String CHANNEL_NAME = "advancedportals:message";
public static final String PROXY_TRANSFER_DESTI = "proxy:transfer_desti";
public static final String PROXY_TRANSFER = "proxy:transfer";
public static final String PROXY_COMMAND = "proxy:command";
public static final String SERVER_DESTI = "server:destination";
}
package com.sekwah.advancedportals.core;
/**
* messages going to the proxy will start with proxy: messages going to the server will start with server:
*/
public class ProxyMessages {
/**
* Could split by channel messages we will handle it ourselves
*/
public static final String CHANNEL_NAME = "advancedportals:message";
public static final String PROXY_TRANSFER_DESTI = "proxy:transfer_desti";
public static final String PROXY_TRANSFER = "proxy:transfer";
public static final String PROXY_COMMAND = "proxy:command";
public static final String SERVER_DESTI = "server:destination";
}

View File

@ -1,5 +1,5 @@
package com.sekwah.advancedportals.core.network;
public interface Packet {
byte[] encode();
}
package com.sekwah.advancedportals.core.network;
public interface Packet {
byte[] encode();
}

View File

@ -1,30 +1,30 @@
package com.sekwah.advancedportals.core.network;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages;
public class ProxyCommandPacket implements Packet {
private final String command;
public ProxyCommandPacket(String command) {
this.command = command;
}
public byte[] encode() {
ByteArrayDataOutput buffer = ByteStreams.newDataOutput();
buffer.writeUTF(ProxyMessages.PROXY_COMMAND);
buffer.writeUTF(this.command);
return buffer.toByteArray();
}
public static ProxyCommandPacket decode(ByteArrayDataInput buffer) {
return new ProxyCommandPacket(buffer.readUTF());
}
public String getCommand() {
return command;
}
}
package com.sekwah.advancedportals.core.network;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages;
public class ProxyCommandPacket implements Packet {
private final String command;
public ProxyCommandPacket(String command) {
this.command = command;
}
public byte[] encode() {
ByteArrayDataOutput buffer = ByteStreams.newDataOutput();
buffer.writeUTF(ProxyMessages.PROXY_COMMAND);
buffer.writeUTF(this.command);
return buffer.toByteArray();
}
public static ProxyCommandPacket decode(ByteArrayDataInput buffer) {
return new ProxyCommandPacket(buffer.readUTF());
}
public String getCommand() {
return command;
}
}

View File

@ -1,38 +1,38 @@
package com.sekwah.advancedportals.core.network;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages;
public class ProxyTransferDestiPacket implements Packet {
private final String serverName;
private final String destination;
public ProxyTransferDestiPacket(String serverName, String destination) {
this.serverName = serverName;
this.destination = destination;
}
public byte[] encode() {
ByteArrayDataOutput buffer = ByteStreams.newDataOutput();
buffer.writeUTF(ProxyMessages.PROXY_TRANSFER_DESTI);
buffer.writeUTF(this.serverName);
buffer.writeUTF(this.destination);
return buffer.toByteArray();
}
public static ProxyTransferDestiPacket decode(ByteArrayDataInput buffer) {
return new ProxyTransferDestiPacket(buffer.readUTF(), buffer.readUTF());
}
public String getServerName() {
return serverName;
}
public String getDestination() {
return destination;
}
}
package com.sekwah.advancedportals.core.network;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages;
public class ProxyTransferDestiPacket implements Packet {
private final String serverName;
private final String destination;
public ProxyTransferDestiPacket(String serverName, String destination) {
this.serverName = serverName;
this.destination = destination;
}
public byte[] encode() {
ByteArrayDataOutput buffer = ByteStreams.newDataOutput();
buffer.writeUTF(ProxyMessages.PROXY_TRANSFER_DESTI);
buffer.writeUTF(this.serverName);
buffer.writeUTF(this.destination);
return buffer.toByteArray();
}
public static ProxyTransferDestiPacket decode(ByteArrayDataInput buffer) {
return new ProxyTransferDestiPacket(buffer.readUTF(), buffer.readUTF());
}
public String getServerName() {
return serverName;
}
public String getDestination() {
return destination;
}
}

View File

@ -1,31 +1,31 @@
package com.sekwah.advancedportals.core.network;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages;
public class ProxyTransferPacket implements Packet {
private final String serverName;
public ProxyTransferPacket(String serverName) {
this.serverName = serverName;
}
public byte[] encode() {
ByteArrayDataOutput buffer = ByteStreams.newDataOutput();
buffer.writeUTF(ProxyMessages.PROXY_TRANSFER);
buffer.writeUTF(this.serverName);
return buffer.toByteArray();
}
public static ProxyTransferPacket decode(ByteArrayDataInput buffer) {
return new ProxyTransferPacket(buffer.readUTF());
}
public String getServerName() {
return serverName;
}
}
package com.sekwah.advancedportals.core.network;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages;
public class ProxyTransferPacket implements Packet {
private final String serverName;
public ProxyTransferPacket(String serverName) {
this.serverName = serverName;
}
public byte[] encode() {
ByteArrayDataOutput buffer = ByteStreams.newDataOutput();
buffer.writeUTF(ProxyMessages.PROXY_TRANSFER);
buffer.writeUTF(this.serverName);
return buffer.toByteArray();
}
public static ProxyTransferPacket decode(ByteArrayDataInput buffer) {
return new ProxyTransferPacket(buffer.readUTF());
}
public String getServerName() {
return serverName;
}
}

View File

@ -1,31 +1,31 @@
package com.sekwah.advancedportals.core.network;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages;
public class ServerDestiPacket implements Packet {
private final String destination;
public ServerDestiPacket(String destination) {
this.destination = destination;
}
public byte[] encode() {
ByteArrayDataOutput buffer = ByteStreams.newDataOutput();
buffer.writeUTF(ProxyMessages.SERVER_DESTI);
buffer.writeUTF(this.destination);
return buffer.toByteArray();
}
public static ServerDestiPacket decode(ByteArrayDataInput buffer) {
return new ServerDestiPacket(buffer.readUTF());
}
public String getDestination() {
return destination;
}
}
package com.sekwah.advancedportals.core.network;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages;
public class ServerDestiPacket implements Packet {
private final String destination;
public ServerDestiPacket(String destination) {
this.destination = destination;
}
public byte[] encode() {
ByteArrayDataOutput buffer = ByteStreams.newDataOutput();
buffer.writeUTF(ProxyMessages.SERVER_DESTI);
buffer.writeUTF(this.destination);
return buffer.toByteArray();
}
public static ServerDestiPacket decode(ByteArrayDataInput buffer) {
return new ServerDestiPacket(buffer.readUTF());
}
public String getDestination() {
return destination;
}
}

View File

@ -1,5 +1,5 @@
package com.sekwah.advancedportals.core;
public class BuildConstants {
public static final String VERSION = "${version}";
}
package com.sekwah.advancedportals.core;
public class BuildConstants {
public static final String VERSION = "${version}";
}

View File

@ -195,4 +195,4 @@ tag.command.permswildcard.disabled= Wildcard &e*&c permission command portals ar
tag.command.proxy.disabled= Proxy command portals are &edisabled &con this server. Please contact a server admin if this is an issue.
tag.proxy.notenabled= Proxy portals are currently &edisabled &con this server. Please contact a server admin to enable them.
tag.proxy.description= Sets the server destination of the portal.
tag.proxy.description= Sets the server destination of the portal.

View File

@ -26,4 +26,3 @@ jar {
it.isDirectory() ? it : zipTree(it)
}
}

View File

@ -1,85 +1,85 @@
package com.sekwah.advancedportals.proxycore;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages;
import com.sekwah.advancedportals.core.network.ProxyCommandPacket;
import com.sekwah.advancedportals.core.network.ProxyTransferDestiPacket;
import com.sekwah.advancedportals.core.network.ProxyTransferPacket;
import com.sekwah.advancedportals.core.network.ServerDestiPacket;
import com.sekwah.advancedportals.core.util.InfoLogger;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyJoinData;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer;
import java.util.HashMap;
public class AdvancedPortalsProxyCore {
private final InfoLogger logger;
private final ProxyContainer proxyContainer;
public HashMap<String, ProxyJoinData> playerJoinMap = new HashMap<>();
public AdvancedPortalsProxyCore(InfoLogger logger, ProxyContainer proxyContainer) {
this.logger = logger;
this.proxyContainer = proxyContainer;
}
public void onEnable() {
this.logger.info(Lang.convertColors("&aSuccessfully enabled!"));
}
public void onDisable() {
this.logger.info(Lang.convertColors("&cDisabling plugin!"));
}
public void onServerConnect(ProxyServerContainer server, ProxyPlayerContainer player) {
if(this.playerJoinMap.containsKey(player.getUUID())) {
var joinData = this.playerJoinMap.get(player.getUUID());
if(joinData.isExpired()) return;
player.sendServerPluginMessage(new ServerDestiPacket(joinData.destination).encode());
this.playerJoinMap.remove(player.getUUID());
}
}
public void onPlayerDisconnect(ProxyPlayerContainer player) {
this.playerJoinMap.remove(player.getUUID());
}
/**
* Messages coming on the ProxyMessages.CHANNEL_NAME from the server, others will be filtered out before now.
* @param player
* @param message
*/
public void incomingMessage(ProxyPlayerContainer player, byte[] message) {
var buffer = ByteStreams.newDataInput(message);
var messageType = buffer.readUTF();
// Might be a bit overboard for some as they'll only have one value, but try to keep the decode behavior with
// the encode behavior in the packets
switch (messageType) {
case ProxyMessages.PROXY_TRANSFER -> {
var transferPacket = ProxyTransferPacket.decode(buffer);
this.logger.info("Transfer request for " + player.getName() + " to " + transferPacket.getServerName());
this.proxyContainer.transferPlayer(player, transferPacket.getServerName());
}
case ProxyMessages.PROXY_COMMAND -> {
var commandPacket = ProxyCommandPacket.decode(buffer);
this.logger.info("Command request for " + player.getName() + " to run /" + commandPacket.getCommand());
this.proxyContainer.invokeCommand(player, commandPacket.getCommand());
}
case ProxyMessages.PROXY_TRANSFER_DESTI -> {
var transferDestiPacket = ProxyTransferDestiPacket.decode(buffer);
this.proxyContainer.transferPlayer(player, transferDestiPacket.getServerName());
this.playerJoinMap.put(player.getUUID(), new ProxyJoinData(transferDestiPacket.getDestination(), transferDestiPacket.getServerName()));
}
default -> {
this.logger.info("Unknown message type: " + messageType);
}
}
}
}
package com.sekwah.advancedportals.proxycore;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages;
import com.sekwah.advancedportals.core.network.ProxyCommandPacket;
import com.sekwah.advancedportals.core.network.ProxyTransferDestiPacket;
import com.sekwah.advancedportals.core.network.ProxyTransferPacket;
import com.sekwah.advancedportals.core.network.ServerDestiPacket;
import com.sekwah.advancedportals.core.util.InfoLogger;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyJoinData;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer;
import java.util.HashMap;
public class AdvancedPortalsProxyCore {
private final InfoLogger logger;
private final ProxyContainer proxyContainer;
public HashMap<String, ProxyJoinData> playerJoinMap = new HashMap<>();
public AdvancedPortalsProxyCore(InfoLogger logger, ProxyContainer proxyContainer) {
this.logger = logger;
this.proxyContainer = proxyContainer;
}
public void onEnable() {
this.logger.info(Lang.convertColors("&aSuccessfully enabled!"));
}
public void onDisable() {
this.logger.info(Lang.convertColors("&cDisabling plugin!"));
}
public void onServerConnect(ProxyServerContainer server, ProxyPlayerContainer player) {
if(this.playerJoinMap.containsKey(player.getUUID())) {
var joinData = this.playerJoinMap.get(player.getUUID());
if(joinData.isExpired()) return;
player.sendServerPluginMessage(new ServerDestiPacket(joinData.destination).encode());
this.playerJoinMap.remove(player.getUUID());
}
}
public void onPlayerDisconnect(ProxyPlayerContainer player) {
this.playerJoinMap.remove(player.getUUID());
}
/**
* Messages coming on the ProxyMessages.CHANNEL_NAME from the server, others will be filtered out before now.
* @param player
* @param message
*/
public void incomingMessage(ProxyPlayerContainer player, byte[] message) {
var buffer = ByteStreams.newDataInput(message);
var messageType = buffer.readUTF();
// Might be a bit overboard for some as they'll only have one value, but try to keep the decode behavior with
// the encode behavior in the packets
switch (messageType) {
case ProxyMessages.PROXY_TRANSFER -> {
var transferPacket = ProxyTransferPacket.decode(buffer);
this.logger.info("Transfer request for " + player.getName() + " to " + transferPacket.getServerName());
this.proxyContainer.transferPlayer(player, transferPacket.getServerName());
}
case ProxyMessages.PROXY_COMMAND -> {
var commandPacket = ProxyCommandPacket.decode(buffer);
this.logger.info("Command request for " + player.getName() + " to run /" + commandPacket.getCommand());
this.proxyContainer.invokeCommand(player, commandPacket.getCommand());
}
case ProxyMessages.PROXY_TRANSFER_DESTI -> {
var transferDestiPacket = ProxyTransferDestiPacket.decode(buffer);
this.proxyContainer.transferPlayer(player, transferDestiPacket.getServerName());
this.playerJoinMap.put(player.getUUID(), new ProxyJoinData(transferDestiPacket.getDestination(), transferDestiPacket.getServerName()));
}
default -> {
this.logger.info("Unknown message type: " + messageType);
}
}
}
}

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.proxycore.connector.container;
public interface ProxyContainer {
void invokeCommand(ProxyPlayerContainer proxyPlayer, String command);
void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName);
}
package com.sekwah.advancedportals.proxycore.connector.container;
public interface ProxyContainer {
void invokeCommand(ProxyPlayerContainer proxyPlayer, String command);
void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName);
}

View File

@ -1,18 +1,18 @@
package com.sekwah.advancedportals.proxycore.connector.container;
public class ProxyJoinData {
public final String destination;
public final String serverName;
public final long joinTime;
public ProxyJoinData(String destination, String serverName) {
this.destination = destination;
this.serverName = serverName;
this.joinTime = System.currentTimeMillis();
}
public boolean isExpired() {
return System.currentTimeMillis() - this.joinTime > 1000 * 15; // 15 seconds
}
}
package com.sekwah.advancedportals.proxycore.connector.container;
public class ProxyJoinData {
public final String destination;
public final String serverName;
public final long joinTime;
public ProxyJoinData(String destination, String serverName) {
this.destination = destination;
this.serverName = serverName;
this.joinTime = System.currentTimeMillis();
}
public boolean isExpired() {
return System.currentTimeMillis() - this.joinTime > 1000 * 15; // 15 seconds
}
}

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.proxycore.connector.container;
public interface ProxyPlayerContainer {
String getUUID();
String getName();
void sendServerPluginMessage(byte[] data);
}
package com.sekwah.advancedportals.proxycore.connector.container;
public interface ProxyPlayerContainer {
String getUUID();
String getName();
void sendServerPluginMessage(byte[] data);
}

View File

@ -1,5 +1,5 @@
package com.sekwah.advancedportals.proxycore.connector.container;
public interface ProxyServerContainer {
String getServerName();
}
package com.sekwah.advancedportals.proxycore.connector.container;
public interface ProxyServerContainer {
String getServerName();
}

View File

@ -1,72 +1,72 @@
package com.sekwah.advancedportals.velocity;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.BuildConstants;
import com.sekwah.advancedportals.core.ProxyMessages;
import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore;
import com.sekwah.advancedportals.velocity.connector.container.VelocityProxyContainer;
import com.sekwah.advancedportals.velocity.connector.container.VelocityProxyPlayerContainer;
import com.sekwah.advancedportals.velocity.connector.container.VelocityProxyServerContainer;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.ServerConnection;
import org.slf4j.Logger;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
@Plugin(authors = {"sekwah41"} ,id = "advancedportals", name = "Advanced Portals",
url = "https://www.spigotmc.org/resources/advanced-portals.14356/",
version = BuildConstants.VERSION)
public class AdvancedPortalsVelocityPlugin {
private AdvancedPortalsProxyCore proxyCore;
private final Logger logger;
private final ProxyServer proxy;
private LegacyChannelIdentifier AP_CHANNEL;
@Inject
public AdvancedPortalsVelocityPlugin(ProxyServer proxy, Logger logger) {
this.proxy = proxy;
this.logger = logger;
this.proxyCore = new AdvancedPortalsProxyCore(new VelocityInfoLogger(this.logger, this.proxy), new VelocityProxyContainer(this.proxy));
this.proxyCore.onEnable();
}
@Subscribe
public void onProxyInitialize(ProxyInitializeEvent event) {
AP_CHANNEL = new LegacyChannelIdentifier(ProxyMessages.CHANNEL_NAME);
proxy.getChannelRegistrar().register(AP_CHANNEL);
}
@Subscribe
public void onPluginMessage(PluginMessageEvent event) {
if (event.getIdentifier().equals(AP_CHANNEL)) {
if(event.getSource() instanceof ServerConnection serverConnection) {
this.proxyCore.incomingMessage(new VelocityProxyPlayerContainer(serverConnection.getPlayer(), AP_CHANNEL), event.getData());
}
// So that client packets don't make it through to the servers, always trigger on this channel.
event.setResult(PluginMessageEvent.ForwardResult.handled());
}
}
@Subscribe
public void postJoinEvent(ServerPostConnectEvent event) {
event.getPlayer().getCurrentServer().ifPresent(serverConnection -> {
this.proxyCore.onServerConnect(new VelocityProxyServerContainer(serverConnection.getServer()), new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL));
});
}
@Subscribe
public void onDisconnect(DisconnectEvent event) {
this.proxyCore.onPlayerDisconnect(new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL));
}
}
package com.sekwah.advancedportals.velocity;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.BuildConstants;
import com.sekwah.advancedportals.core.ProxyMessages;
import com.sekwah.advancedportals.proxycore.AdvancedPortalsProxyCore;
import com.sekwah.advancedportals.velocity.connector.container.VelocityProxyContainer;
import com.sekwah.advancedportals.velocity.connector.container.VelocityProxyPlayerContainer;
import com.sekwah.advancedportals.velocity.connector.container.VelocityProxyServerContainer;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.ServerConnection;
import org.slf4j.Logger;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
@Plugin(authors = {"sekwah41"} ,id = "advancedportals", name = "Advanced Portals",
url = "https://www.spigotmc.org/resources/advanced-portals.14356/",
version = BuildConstants.VERSION)
public class AdvancedPortalsVelocityPlugin {
private AdvancedPortalsProxyCore proxyCore;
private final Logger logger;
private final ProxyServer proxy;
private LegacyChannelIdentifier AP_CHANNEL;
@Inject
public AdvancedPortalsVelocityPlugin(ProxyServer proxy, Logger logger) {
this.proxy = proxy;
this.logger = logger;
this.proxyCore = new AdvancedPortalsProxyCore(new VelocityInfoLogger(this.logger, this.proxy), new VelocityProxyContainer(this.proxy));
this.proxyCore.onEnable();
}
@Subscribe
public void onProxyInitialize(ProxyInitializeEvent event) {
AP_CHANNEL = new LegacyChannelIdentifier(ProxyMessages.CHANNEL_NAME);
proxy.getChannelRegistrar().register(AP_CHANNEL);
}
@Subscribe
public void onPluginMessage(PluginMessageEvent event) {
if (event.getIdentifier().equals(AP_CHANNEL)) {
if(event.getSource() instanceof ServerConnection serverConnection) {
this.proxyCore.incomingMessage(new VelocityProxyPlayerContainer(serverConnection.getPlayer(), AP_CHANNEL), event.getData());
}
// So that client packets don't make it through to the servers, always trigger on this channel.
event.setResult(PluginMessageEvent.ForwardResult.handled());
}
}
@Subscribe
public void postJoinEvent(ServerPostConnectEvent event) {
event.getPlayer().getCurrentServer().ifPresent(serverConnection -> {
this.proxyCore.onServerConnect(new VelocityProxyServerContainer(serverConnection.getServer()), new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL));
});
}
@Subscribe
public void onDisconnect(DisconnectEvent event) {
this.proxyCore.onPlayerDisconnect(new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL));
}
}

View File

@ -1,33 +1,33 @@
package com.sekwah.advancedportals.velocity;
import com.sekwah.advancedportals.core.util.InfoLogger;
import com.sekwah.advancedportals.velocity.connector.MinecraftToAnsi;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.slf4j.Logger;
public class VelocityInfoLogger extends InfoLogger {
private final Logger logger;
private final ProxyServer proxy;
private final LegacyComponentSerializer serializer = LegacyComponentSerializer.builder().character('&').hexCharacter('#').hexColors().build();
public VelocityInfoLogger(Logger logger, ProxyServer proxy) {
this.logger = logger;
this.proxy = proxy;
}
@Override
public void warning(String s) {
logger.warn(MinecraftToAnsi.convert(s));
}
@Override
public void info(String s) {
logger.info(MinecraftToAnsi.convert(s));
}
@Override
public void error(Exception e) {
logger.error(MinecraftToAnsi.convert("\u00A7c" + e.getMessage()), e);
}
}
package com.sekwah.advancedportals.velocity;
import com.sekwah.advancedportals.core.util.InfoLogger;
import com.sekwah.advancedportals.velocity.connector.MinecraftToAnsi;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.slf4j.Logger;
public class VelocityInfoLogger extends InfoLogger {
private final Logger logger;
private final ProxyServer proxy;
private final LegacyComponentSerializer serializer = LegacyComponentSerializer.builder().character('&').hexCharacter('#').hexColors().build();
public VelocityInfoLogger(Logger logger, ProxyServer proxy) {
this.logger = logger;
this.proxy = proxy;
}
@Override
public void warning(String s) {
logger.warn(MinecraftToAnsi.convert(s));
}
@Override
public void info(String s) {
logger.info(MinecraftToAnsi.convert(s));
}
@Override
public void error(Exception e) {
logger.error(MinecraftToAnsi.convert("\u00A7c" + e.getMessage()), e);
}
}

View File

@ -1,55 +1,55 @@
package com.sekwah.advancedportals.velocity.connector;
import java.util.HashMap;
import java.util.Map;
/**
* I believe later versions of velocity have some component handlers for this, and I could just send it to the server as components
* but ive decided to throw this in for now just to use the plugin logger. Also, to try to clone the bungee behavior as close as possible.
*/
public class MinecraftToAnsi {
private static final Map<Character, String> minecraftToAnsiMap = new HashMap<>();
static {
minecraftToAnsiMap.put('0', "\u001B[30m"); // Black
minecraftToAnsiMap.put('1', "\u001B[34m"); // Dark Blue
minecraftToAnsiMap.put('2', "\u001B[32m"); // Dark Green
minecraftToAnsiMap.put('3', "\u001B[36m"); // Dark Aqua
minecraftToAnsiMap.put('4', "\u001B[31m"); // Dark Red
minecraftToAnsiMap.put('5', "\u001B[35m"); // Dark Purple
minecraftToAnsiMap.put('6', "\u001B[33m"); // Gold
minecraftToAnsiMap.put('7', "\u001B[37m"); // Gray
minecraftToAnsiMap.put('8', "\u001B[90m"); // Dark Gray
minecraftToAnsiMap.put('9', "\u001B[94m"); // Blue
minecraftToAnsiMap.put('a', "\u001B[92m"); // Green
minecraftToAnsiMap.put('b', "\u001B[96m"); // Aqua
minecraftToAnsiMap.put('c', "\u001B[91m"); // Red
minecraftToAnsiMap.put('d', "\u001B[95m"); // Light Purple
minecraftToAnsiMap.put('e', "\u001B[93m"); // Yellow
minecraftToAnsiMap.put('f', "\u001B[97m"); // White
minecraftToAnsiMap.put('k', "\u001B[5m"); // Obfuscated (Blinking)
minecraftToAnsiMap.put('l', "\u001B[1m"); // Bold
minecraftToAnsiMap.put('m', "\u001B[9m"); // Strikethrough
minecraftToAnsiMap.put('n', "\u001B[4m"); // Underline
minecraftToAnsiMap.put('o', "\u001B[3m"); // Italic
minecraftToAnsiMap.put('r', "\u001B[0m"); // Reset
}
public static String convert(String text) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '\u00A7' && i + 1 < text.length()) {
char code = Character.toLowerCase(text.charAt(i + 1));
String ansiCode = minecraftToAnsiMap.getOrDefault(code, "");
result.append(ansiCode);
i++;
} else {
result.append(text.charAt(i));
}
}
result.append("\u001B[0m");
return result.toString();
}
}
package com.sekwah.advancedportals.velocity.connector;
import java.util.HashMap;
import java.util.Map;
/**
* I believe later versions of velocity have some component handlers for this, and I could just send it to the server as components
* but ive decided to throw this in for now just to use the plugin logger. Also, to try to clone the bungee behavior as close as possible.
*/
public class MinecraftToAnsi {
private static final Map<Character, String> minecraftToAnsiMap = new HashMap<>();
static {
minecraftToAnsiMap.put('0', "\u001B[30m"); // Black
minecraftToAnsiMap.put('1', "\u001B[34m"); // Dark Blue
minecraftToAnsiMap.put('2', "\u001B[32m"); // Dark Green
minecraftToAnsiMap.put('3', "\u001B[36m"); // Dark Aqua
minecraftToAnsiMap.put('4', "\u001B[31m"); // Dark Red
minecraftToAnsiMap.put('5', "\u001B[35m"); // Dark Purple
minecraftToAnsiMap.put('6', "\u001B[33m"); // Gold
minecraftToAnsiMap.put('7', "\u001B[37m"); // Gray
minecraftToAnsiMap.put('8', "\u001B[90m"); // Dark Gray
minecraftToAnsiMap.put('9', "\u001B[94m"); // Blue
minecraftToAnsiMap.put('a', "\u001B[92m"); // Green
minecraftToAnsiMap.put('b', "\u001B[96m"); // Aqua
minecraftToAnsiMap.put('c', "\u001B[91m"); // Red
minecraftToAnsiMap.put('d', "\u001B[95m"); // Light Purple
minecraftToAnsiMap.put('e', "\u001B[93m"); // Yellow
minecraftToAnsiMap.put('f', "\u001B[97m"); // White
minecraftToAnsiMap.put('k', "\u001B[5m"); // Obfuscated (Blinking)
minecraftToAnsiMap.put('l', "\u001B[1m"); // Bold
minecraftToAnsiMap.put('m', "\u001B[9m"); // Strikethrough
minecraftToAnsiMap.put('n', "\u001B[4m"); // Underline
minecraftToAnsiMap.put('o', "\u001B[3m"); // Italic
minecraftToAnsiMap.put('r', "\u001B[0m"); // Reset
}
public static String convert(String text) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < text.length(); i++) {
if (text.charAt(i) == '\u00A7' && i + 1 < text.length()) {
char code = Character.toLowerCase(text.charAt(i + 1));
String ansiCode = minecraftToAnsiMap.getOrDefault(code, "");
result.append(ansiCode);
i++;
} else {
result.append(text.charAt(i));
}
}
result.append("\u001B[0m");
return result.toString();
}
}

View File

@ -1,33 +1,33 @@
package com.sekwah.advancedportals.velocity.connector.container;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.Component;
public class VelocityProxyContainer implements ProxyContainer {
private final ProxyServer proxy;
public VelocityProxyContainer(ProxyServer proxy) {
this.proxy = proxy;
}
@Override
public void invokeCommand(ProxyPlayerContainer proxyPlayer, String command) {
if(proxyPlayer instanceof VelocityProxyPlayerContainer playerContainer) {
this.proxy.getCommandManager().executeAsync(playerContainer.getPlayer(), command);
}
}
@Override
public void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName) {
if(proxyPlayer instanceof VelocityProxyPlayerContainer playerContainer) {
this.proxy.getServer(serverName).ifPresentOrElse(
server -> {
playerContainer.getPlayer().createConnectionRequest(server).fireAndForget();
},
() -> playerContainer.getPlayer().sendMessage(Component.text("Could not find server: " + serverName))
);
}
}
}
package com.sekwah.advancedportals.velocity.connector.container;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.Component;
public class VelocityProxyContainer implements ProxyContainer {
private final ProxyServer proxy;
public VelocityProxyContainer(ProxyServer proxy) {
this.proxy = proxy;
}
@Override
public void invokeCommand(ProxyPlayerContainer proxyPlayer, String command) {
if(proxyPlayer instanceof VelocityProxyPlayerContainer playerContainer) {
this.proxy.getCommandManager().executeAsync(playerContainer.getPlayer(), command);
}
}
@Override
public void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName) {
if(proxyPlayer instanceof VelocityProxyPlayerContainer playerContainer) {
this.proxy.getServer(serverName).ifPresentOrElse(
server -> {
playerContainer.getPlayer().createConnectionRequest(server).fireAndForget();
},
() -> playerContainer.getPlayer().sendMessage(Component.text("Could not find server: " + serverName))
);
}
}
}

View File

@ -1,36 +1,36 @@
package com.sekwah.advancedportals.velocity.connector.container;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import net.kyori.adventure.text.Component;
public class VelocityProxyPlayerContainer implements ProxyPlayerContainer {
private final Player player;
private final LegacyChannelIdentifier channel;
public VelocityProxyPlayerContainer(Player player, LegacyChannelIdentifier channel) {
this.player = player;
this.channel = channel;
}
@Override
public String getUUID() {
return player.getUniqueId().toString();
}
@Override
public String getName() {
return player.getUsername();
}
@Override
public void sendServerPluginMessage(byte[] data) {
player.getCurrentServer().ifPresent(serverConnection -> serverConnection.sendPluginMessage(channel, data));
}
public Player getPlayer() {
return this.player;
}
}
package com.sekwah.advancedportals.velocity.connector.container;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import net.kyori.adventure.text.Component;
public class VelocityProxyPlayerContainer implements ProxyPlayerContainer {
private final Player player;
private final LegacyChannelIdentifier channel;
public VelocityProxyPlayerContainer(Player player, LegacyChannelIdentifier channel) {
this.player = player;
this.channel = channel;
}
@Override
public String getUUID() {
return player.getUniqueId().toString();
}
@Override
public String getName() {
return player.getUsername();
}
@Override
public void sendServerPluginMessage(byte[] data) {
player.getCurrentServer().ifPresent(serverConnection -> serverConnection.sendPluginMessage(channel, data));
}
public Player getPlayer() {
return this.player;
}
}

View File

@ -1,17 +1,17 @@
package com.sekwah.advancedportals.velocity.connector.container;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
public class VelocityProxyServerContainer implements ProxyServerContainer {
private final RegisteredServer server;
public VelocityProxyServerContainer(RegisteredServer server) {
this.server = server;
}
@Override
public String getServerName() {
return this.server.getServerInfo().getName();
}
}
package com.sekwah.advancedportals.velocity.connector.container;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
public class VelocityProxyServerContainer implements ProxyServerContainer {
private final RegisteredServer server;
public VelocityProxyServerContainer(RegisteredServer server) {
this.server = server;
}
@Override
public String getServerName() {
return this.server.getServerInfo().getName();
}
}