From 37dc600fe09b3d9be9001244582dc4e6d7c796d0 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 23 Oct 2013 20:44:48 +1100 Subject: [PATCH] BungeeCord can into server icon --- api/src/main/java/net/md_5/bungee/api/ServerPing.java | 1 + proxy/src/main/java/net/md_5/bungee/BungeeCord.java | 10 ++++++++++ .../net/md_5/bungee/connection/InitialHandler.java | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/net/md_5/bungee/api/ServerPing.java b/api/src/main/java/net/md_5/bungee/api/ServerPing.java index 2458d133..17ec67ea 100644 --- a/api/src/main/java/net/md_5/bungee/api/ServerPing.java +++ b/api/src/main/java/net/md_5/bungee/api/ServerPing.java @@ -35,4 +35,5 @@ public class ServerPing private int online; } private String description; + private String favicon; } 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 badcac32..8001582e 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -1,6 +1,8 @@ package net.md_5.bungee; +import com.google.common.io.BaseEncoding; import com.google.common.io.ByteStreams; +import com.google.common.io.Files; import net.md_5.bungee.log.BungeeLogger; import net.md_5.bungee.reconnect.YamlReconnectHandler; import net.md_5.bungee.scheduler.BungeeScheduler; @@ -122,6 +124,7 @@ public class BungeeCord extends ProxyServer public final Gson gson = new Gson(); @Getter private ConnectionThrottle connectionThrottle; + public String favicon; { @@ -187,6 +190,13 @@ public class BungeeCord extends ProxyServer } isRunning = true; + File fav = new File( "server-icon.png" ); + if ( fav.exists() ) + { + + favicon = "data:image/png;base64," + BaseEncoding.base64().encode( Files.toByteArray( fav ) ); + } + pluginManager.loadAndEnablePlugins(); connectionThrottle = new ConnectionThrottle( config.getThrottle() ); diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 89f9d299..a8aff99d 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -166,7 +166,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection pingBack.done( new ServerPing( new ServerPing.Protocol( bungee.getGameVersion(), bungee.getProtocolVersion() ), new ServerPing.Players( listener.getMaxPlayers(), bungee.getOnlineCount() ), - motd ), + motd, BungeeCord.getInstance().favicon ), null ); }