Reload favicon on greload

This commit is contained in:
md_5 2013-10-27 20:07:36 +11:00
parent 8665784bb5
commit e6c1015027
3 changed files with 21 additions and 10 deletions

View File

@ -121,7 +121,6 @@ public class BungeeCord extends ProxyServer
public final Gson gson = new Gson();
@Getter
private ConnectionThrottle connectionThrottle;
public String favicon;
{
@ -187,13 +186,6 @@ 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() );

View File

@ -1,11 +1,16 @@
package net.md_5.bungee.config;
import com.google.common.base.Preconditions;
import com.google.common.io.BaseEncoding;
import com.google.common.io.Files;
import gnu.trove.map.TMap;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Level;
import lombok.Getter;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ConfigurationAdapter;
@ -45,19 +50,33 @@ public class Configuration
private Collection<String> disabledCommands;
private int throttle = 4000;
private boolean ipFoward;
public String favicon;
public void load()
{
ConfigurationAdapter adapter = ProxyServer.getInstance().getConfigurationAdapter();
adapter.load();
File fav = new File( "server-icon.png" );
if ( fav.exists() )
{
try
{
favicon = "data:image/png;base64," + BaseEncoding.base64().encode( Files.toByteArray( fav ) );
} catch ( IOException ex )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not load server icon", ex );
}
}
listeners = adapter.getListeners();
timeout = adapter.getInt( "timeout", timeout );
uuid = adapter.getString( "stats", uuid );
onlineMode = adapter.getBoolean( "online_mode", onlineMode );
playerLimit = adapter.getInt( "player_limit", playerLimit );
throttle = adapter.getInt( "connection_throttle", throttle );
ipFoward = adapter.getBoolean( "ip_forward", ipFoward);
ipFoward = adapter.getBoolean( "ip_forward", ipFoward );
disabledCommands = new CaseInsensitiveSet( (Collection<String>) adapter.getList( "disabled_commands", Arrays.asList( "find" ) ) );

View File

@ -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() ),
null, motd, BungeeCord.getInstance().favicon ),
null, motd, BungeeCord.getInstance().config.favicon),
null );
}