@@ -1,7 +1,6 @@
|
||||
package net.md_5.bungee;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.module.ModuleManager;
|
||||
import com.google.common.io.ByteStreams;
|
||||
@@ -127,11 +126,9 @@ public class BungeeCord extends ProxyServer
|
||||
@Getter
|
||||
private final Logger logger;
|
||||
public final Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer( 5 ) )
|
||||
.registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create();
|
||||
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer( 5 ) ).create();
|
||||
public final Gson gsonLegacy = new GsonBuilder()
|
||||
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer( 4 ) )
|
||||
.registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create();
|
||||
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer( 4 ) ).create();
|
||||
@Getter
|
||||
private ConnectionThrottle connectionThrottle;
|
||||
private final ModuleManager moduleManager = new ModuleManager();
|
||||
|
@@ -1,7 +1,12 @@
|
||||
package net.md_5.bungee.conf;
|
||||
|
||||
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.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@@ -11,7 +16,6 @@ import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import javax.imageio.ImageIO;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ProxyConfig;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ConfigurationAdapter;
|
||||
@@ -51,7 +55,7 @@ public class Configuration implements ProxyConfig
|
||||
private Collection<String> disabledCommands;
|
||||
private int throttle = 4000;
|
||||
private boolean ipFoward;
|
||||
private Favicon favicon;
|
||||
public String favicon;
|
||||
|
||||
public void load()
|
||||
{
|
||||
@@ -63,8 +67,28 @@ public class Configuration implements ProxyConfig
|
||||
{
|
||||
try
|
||||
{
|
||||
favicon = Favicon.create( ImageIO.read( fav ) );
|
||||
} catch ( IOException | IllegalArgumentException ex )
|
||||
BufferedImage image = ImageIO.read( fav );
|
||||
if ( image != null )
|
||||
{
|
||||
if ( image.getHeight() == 64 && image.getWidth() == 64 )
|
||||
{
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
ImageIO.write( image, "png", bytes );
|
||||
favicon = "data:image/png;base64," + BaseEncoding.base64().encode( bytes.toByteArray() );
|
||||
if ( favicon.length() > Short.MAX_VALUE )
|
||||
{
|
||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Favicon file too large for server to process" );
|
||||
favicon = null;
|
||||
}
|
||||
} else
|
||||
{
|
||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Server icon must be exactly 64x64 pixels" );
|
||||
}
|
||||
} else
|
||||
{
|
||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not load server icon for unknown reason. Please double check its format." );
|
||||
}
|
||||
} catch ( IOException ex )
|
||||
{
|
||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not load server icon", ex );
|
||||
}
|
||||
@@ -119,15 +143,4 @@ public class Configuration implements ProxyConfig
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getFavicon()
|
||||
{
|
||||
return getFaviconObject().getEncoded();
|
||||
}
|
||||
|
||||
public Favicon getFaviconObject()
|
||||
{
|
||||
return favicon;
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.*;
|
||||
import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.Favicon;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@@ -131,7 +130,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
public void handle(LegacyPing ping) throws Exception
|
||||
{
|
||||
ServerPing legacy = new ServerPing( new ServerPing.Protocol( bungee.getGameVersion(), bungee.getProtocolVersion() ),
|
||||
new ServerPing.Players( listener.getMaxPlayers(), bungee.getOnlineCount(), null ), listener.getMotd(), (Favicon) null );
|
||||
new ServerPing.Players( listener.getMaxPlayers(), bungee.getOnlineCount(), null ), listener.getMotd(), null );
|
||||
legacy = bungee.getPluginManager().callEvent( new ProxyPingEvent( this, legacy ) ).getResponse();
|
||||
|
||||
String kickMessage = ChatColor.DARK_BLUE
|
||||
@@ -180,7 +179,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
pingBack.done( new ServerPing(
|
||||
new ServerPing.Protocol( bungee.getGameVersion(), protocol ),
|
||||
new ServerPing.Players( listener.getMaxPlayers(), bungee.getOnlineCount(), null ),
|
||||
motd, BungeeCord.getInstance().config.getFaviconObject() ),
|
||||
motd, BungeeCord.getInstance().config.favicon ),
|
||||
null );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user