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(); public final Gson gson = new Gson();
@Getter @Getter
private ConnectionThrottle connectionThrottle; private ConnectionThrottle connectionThrottle;
public String favicon;
{ {
@ -187,13 +186,6 @@ public class BungeeCord extends ProxyServer
} }
isRunning = true; 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(); pluginManager.loadAndEnablePlugins();
connectionThrottle = new ConnectionThrottle( config.getThrottle() ); connectionThrottle = new ConnectionThrottle( config.getThrottle() );

View File

@ -1,11 +1,16 @@
package net.md_5.bungee.config; package net.md_5.bungee.config;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.io.BaseEncoding;
import com.google.common.io.Files;
import gnu.trove.map.TMap; import gnu.trove.map.TMap;
import java.io.File;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
import lombok.Getter; import lombok.Getter;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ConfigurationAdapter; import net.md_5.bungee.api.config.ConfigurationAdapter;
@ -45,19 +50,33 @@ public class Configuration
private Collection<String> disabledCommands; private Collection<String> disabledCommands;
private int throttle = 4000; private int throttle = 4000;
private boolean ipFoward; private boolean ipFoward;
public String favicon;
public void load() public void load()
{ {
ConfigurationAdapter adapter = ProxyServer.getInstance().getConfigurationAdapter(); ConfigurationAdapter adapter = ProxyServer.getInstance().getConfigurationAdapter();
adapter.load(); 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(); listeners = adapter.getListeners();
timeout = adapter.getInt( "timeout", timeout ); timeout = adapter.getInt( "timeout", timeout );
uuid = adapter.getString( "stats", uuid ); uuid = adapter.getString( "stats", uuid );
onlineMode = adapter.getBoolean( "online_mode", onlineMode ); onlineMode = adapter.getBoolean( "online_mode", onlineMode );
playerLimit = adapter.getInt( "player_limit", playerLimit ); playerLimit = adapter.getInt( "player_limit", playerLimit );
throttle = adapter.getInt( "connection_throttle", throttle ); 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" ) ) ); 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( pingBack.done( new ServerPing(
new ServerPing.Protocol( bungee.getGameVersion(), bungee.getProtocolVersion() ), new ServerPing.Protocol( bungee.getGameVersion(), bungee.getProtocolVersion() ),
new ServerPing.Players( listener.getMaxPlayers(), bungee.getOnlineCount() ), new ServerPing.Players( listener.getMaxPlayers(), bungee.getOnlineCount() ),
null, motd, BungeeCord.getInstance().favicon ), null, motd, BungeeCord.getInstance().config.favicon),
null ); null );
} }