diff --git a/proxy/pom.xml b/proxy/pom.xml index 69e80274..409948ab 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -19,6 +19,12 @@ Proxy component of the Elastic Portal Suite + + com.google.code.gson + gson + 2.2.4 + compile + io.netty netty-codec diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index bd727d7d..1cc18c31 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -5,6 +5,7 @@ import net.md_5.bungee.log.BungeeLogger; import net.md_5.bungee.reconnect.SQLReconnectHandler; import net.md_5.bungee.scheduler.BungeeScheduler; import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.google.gson.Gson; import com.ning.http.client.AsyncHttpClient; import com.ning.http.client.AsyncHttpClientConfig; import com.ning.http.client.providers.netty.NettyAsyncHttpProvider; @@ -130,6 +131,7 @@ public class BungeeCord extends ProxyServer private ConsoleReader consoleReader; @Getter private final Logger logger; + public final Gson gson = new Gson(); { @@ -488,7 +490,8 @@ public class BungeeCord extends ProxyServer { getConsole().sendMessage( message ); // TODO: Here too - broadcast( new Packet3Chat( "{\"text\":\"" + message + "\"}" )); + String encoded = BungeeCord.getInstance().gson.toJson( message ); + broadcast( new Packet3Chat( "{\"text\":" + encoded + "}" ) ); } public void addConnection(UserConnection con) diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 2c4c80a4..ca592b08 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -266,7 +266,8 @@ public final class UserConnection implements ProxiedPlayer public void sendMessage(String message) { // TODO: Fix this - unsafe().sendPacket( new Packet3Chat( "{\"text\":\"" + message + "\"}" ) ); + String encoded = BungeeCord.getInstance().gson.toJson( message ); + unsafe().sendPacket( new Packet3Chat( "{\"text\":" + encoded + "}" ) ); } @Override diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandAlert.java b/proxy/src/main/java/net/md_5/bungee/command/CommandAlert.java index a1903fb7..1ccae73b 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/CommandAlert.java +++ b/proxy/src/main/java/net/md_5/bungee/command/CommandAlert.java @@ -41,7 +41,6 @@ public class CommandAlert extends Command String message = builder.substring( 0, builder.length() - 1 ); ProxyServer.getInstance().broadcast( message ); - ProxyServer.getInstance().getConsole().sendMessage( message ); } } }