mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-27 20:59:12 +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.io.PrintStream;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -44,7 +42,6 @@ import jline.internal.Log;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.Synchronized;
|
import lombok.Synchronized;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.ReconnectHandler;
|
import net.md_5.bungee.api.ReconnectHandler;
|
||||||
@ -492,8 +489,7 @@ public class BungeeCord extends ProxyServer
|
|||||||
{
|
{
|
||||||
getConsole().sendMessage( message );
|
getConsole().sendMessage( message );
|
||||||
// TODO: Here too
|
// TODO: Here too
|
||||||
String encoded = BungeeCord.getInstance().gson.toJson( message );
|
broadcast( new Chat( Util.stupify( message ) ) );
|
||||||
broadcast( new Chat( "{\"text\":" + encoded + "}" ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addConnection(UserConnection con)
|
public void addConnection(UserConnection con)
|
||||||
|
@ -255,7 +255,7 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
if ( ch.getHandle().isActive() )
|
if ( ch.getHandle().isActive() )
|
||||||
{
|
{
|
||||||
bungee.getLogger().log( Level.INFO, "[" + getName() + "] disconnected with: " + reason );
|
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();
|
ch.close();
|
||||||
if ( server != null )
|
if ( server != null )
|
||||||
{
|
{
|
||||||
@ -275,8 +275,7 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
public void sendMessage(String message)
|
public void sendMessage(String message)
|
||||||
{
|
{
|
||||||
// TODO: Fix this
|
// TODO: Fix this
|
||||||
String encoded = BungeeCord.getInstance().gson.toJson( message );
|
unsafe().sendPacket( new Chat( Util.stupify( message ) ) );
|
||||||
unsafe().sendPacket( new Chat( "{\"text\":" + encoded + "}" ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,4 +70,10 @@ public class Util
|
|||||||
|
|
||||||
return ( ret.length() == 0 ) ? "" : ret.substring( 0, ret.length() - separators.length() );
|
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() )
|
if ( !ch.isClosed() )
|
||||||
{
|
{
|
||||||
unsafe().sendPacket( new Kick( BungeeCord.getInstance().gson.toJson( reason ) ) );
|
unsafe().sendPacket( new Kick( Util.stupify( reason ) ) );
|
||||||
ch.close();
|
ch.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user