mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-25 01:57:55 +01:00
Common method to wrap text. Thanks @lazertester
This commit is contained in:
parent
a7e4854661
commit
e2e32100cd
@ -23,8 +23,6 @@ import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@ -44,7 +42,6 @@ import jline.internal.Log;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.Synchronized;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.ReconnectHandler;
|
||||
@ -492,8 +489,7 @@ public class BungeeCord extends ProxyServer
|
||||
{
|
||||
getConsole().sendMessage( message );
|
||||
// TODO: Here too
|
||||
String encoded = BungeeCord.getInstance().gson.toJson( message );
|
||||
broadcast( new Chat( "{\"text\":" + encoded + "}" ) );
|
||||
broadcast( new Chat( Util.stupify( message ) ) );
|
||||
}
|
||||
|
||||
public void addConnection(UserConnection con)
|
||||
|
@ -255,7 +255,7 @@ public final class UserConnection implements ProxiedPlayer
|
||||
if ( ch.getHandle().isActive() )
|
||||
{
|
||||
bungee.getLogger().log( Level.INFO, "[" + getName() + "] disconnected with: " + reason );
|
||||
unsafe().sendPacket( new Kick( BungeeCord.getInstance().gson.toJson( reason ) ) );
|
||||
unsafe().sendPacket( new Kick( Util.stupify( reason ) ) );
|
||||
ch.close();
|
||||
if ( server != null )
|
||||
{
|
||||
@ -275,8 +275,7 @@ public final class UserConnection implements ProxiedPlayer
|
||||
public void sendMessage(String message)
|
||||
{
|
||||
// TODO: Fix this
|
||||
String encoded = BungeeCord.getInstance().gson.toJson( message );
|
||||
unsafe().sendPacket( new Chat( "{\"text\":" + encoded + "}" ) );
|
||||
unsafe().sendPacket( new Chat( Util.stupify( message ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,4 +70,10 @@ public class Util
|
||||
|
||||
return ( ret.length() == 0 ) ? "" : ret.substring( 0, ret.length() - separators.length() );
|
||||
}
|
||||
|
||||
public static String stupify(String text)
|
||||
{
|
||||
// TODO: Colour text wrapper to work around 1.7 client bug with section sign
|
||||
return "{\"text\":" + BungeeCord.getInstance().gson.toJson( text ) + "}";
|
||||
}
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
{
|
||||
if ( !ch.isClosed() )
|
||||
{
|
||||
unsafe().sendPacket( new Kick( BungeeCord.getInstance().gson.toJson( reason ) ) );
|
||||
unsafe().sendPacket( new Kick( Util.stupify( reason ) ) );
|
||||
ch.close();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user