Fix formatting
This commit is contained in:
@@ -490,19 +490,21 @@ public class BungeeCord extends ProxyServer
|
||||
public void broadcast(String message)
|
||||
{
|
||||
getConsole().sendMessage( message );
|
||||
broadcast(TextComponent.fromLegacyText(message));
|
||||
broadcast( TextComponent.fromLegacyText( message ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(BaseComponent[] message) {
|
||||
getConsole().sendMessage(BaseComponent.toLegacyText(message));
|
||||
broadcast(new Chat(ComponentSerializer.toString(message)));
|
||||
public void broadcast(BaseComponent[] message)
|
||||
{
|
||||
getConsole().sendMessage( BaseComponent.toLegacyText( message ) );
|
||||
broadcast( new Chat( ComponentSerializer.toString( message ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(BaseComponent message) {
|
||||
public void broadcast(BaseComponent message)
|
||||
{
|
||||
getConsole().sendMessage( message.toLegacyText() );
|
||||
broadcast( new Chat(ComponentSerializer.toString(message)) );
|
||||
broadcast( new Chat( ComponentSerializer.toString( message ) ) );
|
||||
}
|
||||
|
||||
public void addConnection(UserConnection con)
|
||||
|
@@ -43,15 +43,16 @@ public class ServerConnection implements Server
|
||||
@Override
|
||||
public synchronized void disconnect(String reason)
|
||||
{
|
||||
disconnect( TextComponent.fromLegacyText(reason) );
|
||||
disconnect( TextComponent.fromLegacyText( reason ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(BaseComponent[] reason) {
|
||||
if ( !ch.isClosed() )
|
||||
public void disconnect(BaseComponent[] reason)
|
||||
{
|
||||
if (!ch.isClosed())
|
||||
{
|
||||
// TODO: Can we just use a future here?
|
||||
unsafe().sendPacket( new Kick(ComponentSerializer.toString(reason) ) );
|
||||
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
|
||||
ch.getHandle().eventLoop().schedule( new Runnable()
|
||||
{
|
||||
@Override
|
||||
@@ -65,8 +66,9 @@ public class ServerConnection implements Server
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(BaseComponent reason) {
|
||||
disconnect(new BaseComponent[]{reason});
|
||||
public void disconnect(BaseComponent reason)
|
||||
{
|
||||
disconnect( new BaseComponent[]{reason} );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -259,27 +259,29 @@ public final class UserConnection implements ProxiedPlayer
|
||||
@Override
|
||||
public synchronized void disconnect(String reason)
|
||||
{
|
||||
disconnect0( TextComponent.fromLegacyText(reason) );
|
||||
disconnect0( TextComponent.fromLegacyText( reason ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(BaseComponent[] reason) {
|
||||
public void disconnect(BaseComponent[] reason)
|
||||
{
|
||||
disconnect0( reason );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(BaseComponent reason) {
|
||||
disconnect0(new BaseComponent[]{reason});
|
||||
public void disconnect(BaseComponent reason)
|
||||
{
|
||||
disconnect0( new BaseComponent[]{reason} );
|
||||
}
|
||||
|
||||
public synchronized void disconnect0(BaseComponent[] reason)
|
||||
{
|
||||
if ( ch.getHandle().isActive() )
|
||||
if (ch.getHandle().isActive())
|
||||
{
|
||||
bungee.getLogger().log( Level.INFO, "[" + getName() + "] disconnected with: " + BaseComponent.toLegacyText(reason) );
|
||||
unsafe().sendPacket( new Kick( ComponentSerializer.toString(reason) ) );
|
||||
bungee.getLogger().log( Level.INFO, "[" + getName() + "] disconnected with: " + BaseComponent.toLegacyText( reason ) );
|
||||
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
|
||||
ch.close();
|
||||
if ( server != null )
|
||||
if (server != null)
|
||||
{
|
||||
server.disconnect( "Quitting" );
|
||||
}
|
||||
@@ -296,25 +298,27 @@ public final class UserConnection implements ProxiedPlayer
|
||||
@Override
|
||||
public void sendMessage(String message)
|
||||
{
|
||||
sendMessage(TextComponent.fromLegacyText(message));
|
||||
sendMessage( TextComponent.fromLegacyText( message ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessages(String... messages)
|
||||
{
|
||||
for ( String message : messages )
|
||||
for (String message : messages)
|
||||
{
|
||||
sendMessage( message );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent[] message) {
|
||||
public void sendMessage(BaseComponent[] message)
|
||||
{
|
||||
unsafe().sendPacket( new Chat( ComponentSerializer.toString( message ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent message) {
|
||||
public void sendMessage(BaseComponent message)
|
||||
{
|
||||
unsafe().sendPacket( new Chat( ComponentSerializer.toString( message ) ) );
|
||||
}
|
||||
|
||||
|
@@ -10,86 +10,109 @@ import net.md_5.bungee.api.chat.HoverEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class BaseComponentSerializer {
|
||||
public class BaseComponentSerializer
|
||||
{
|
||||
|
||||
protected void deserialize(JsonObject object, BaseComponent component, JsonDeserializationContext context) {
|
||||
if (object.has("color")) {
|
||||
component.setColor(ChatColor.valueOf(object.get("color").getAsString().toUpperCase()));
|
||||
protected void deserialize(JsonObject object, BaseComponent component, JsonDeserializationContext context)
|
||||
{
|
||||
if (object.has( "color" ))
|
||||
{
|
||||
component.setColor( ChatColor.valueOf( object.get( "color" ).getAsString().toUpperCase() ) );
|
||||
}
|
||||
if (object.has("bold")) {
|
||||
component.setBold(object.get("bold").getAsBoolean());
|
||||
if (object.has( "bold" ))
|
||||
{
|
||||
component.setBold( object.get( "bold" ).getAsBoolean() );
|
||||
}
|
||||
if (object.has("italic")) {
|
||||
component.setItalic(object.get("italic").getAsBoolean());
|
||||
if (object.has( "italic" ))
|
||||
{
|
||||
component.setItalic( object.get( "italic" ).getAsBoolean() );
|
||||
}
|
||||
if (object.has("underlined")) {
|
||||
component.setUnderlined(object.get("underlined").getAsBoolean());
|
||||
if (object.has( "underlined" ))
|
||||
{
|
||||
component.setUnderlined( object.get( "underlined" ).getAsBoolean() );
|
||||
}
|
||||
if (object.has("strikethrough")) {
|
||||
component.setUnderlined(object.get("strikethrough").getAsBoolean());
|
||||
if (object.has( "strikethrough" ))
|
||||
{
|
||||
component.setUnderlined( object.get( "strikethrough" ).getAsBoolean() );
|
||||
}
|
||||
if (object.has("obfuscated")) {
|
||||
component.setUnderlined(object.get("obfuscated").getAsBoolean());
|
||||
if (object.has( "obfuscated" ))
|
||||
{
|
||||
component.setUnderlined( object.get( "obfuscated" ).getAsBoolean() );
|
||||
}
|
||||
if (object.has("extra")) {
|
||||
component.setExtra(Arrays.asList((BaseComponent[])context.deserialize(object.get("extra"), BaseComponent[].class)));
|
||||
if (object.has( "extra" ))
|
||||
{
|
||||
component.setExtra( Arrays.asList( (BaseComponent[]) context.deserialize( object.get( "extra" ), BaseComponent[].class ) ) );
|
||||
}
|
||||
|
||||
//Events
|
||||
if (object.has("clickEvent")) {
|
||||
JsonObject event = object.getAsJsonObject("clickEvent");
|
||||
component.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.valueOf(event.get("action").getAsString().toUpperCase()),
|
||||
event.get("value").getAsString()));
|
||||
if (object.has( "clickEvent" ))
|
||||
{
|
||||
JsonObject event = object.getAsJsonObject( "clickEvent" );
|
||||
component.setClickEvent( new ClickEvent(
|
||||
ClickEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase() ),
|
||||
event.get( "value" ).getAsString() ) );
|
||||
}
|
||||
if (object.has("hoverEvent")) {
|
||||
JsonObject event = object.getAsJsonObject("hoverEvent");
|
||||
if (object.has( "hoverEvent" ))
|
||||
{
|
||||
JsonObject event = object.getAsJsonObject( "hoverEvent" );
|
||||
HoverEvent hoverEvent = new HoverEvent();
|
||||
hoverEvent.setAction(HoverEvent.Action.valueOf(event.get("action").getAsString().toUpperCase()));
|
||||
Object res = context.deserialize(event.get("value"), BaseComponent.class);
|
||||
if (res instanceof String) {
|
||||
hoverEvent.setValue((String) res);
|
||||
} else {
|
||||
hoverEvent.setValue((BaseComponent) res);
|
||||
hoverEvent.setAction( HoverEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase() ) );
|
||||
Object res = context.deserialize( event.get( "value" ), BaseComponent.class );
|
||||
if (res instanceof String)
|
||||
{
|
||||
hoverEvent.setValue( (String) res );
|
||||
} else
|
||||
{
|
||||
hoverEvent.setValue( (BaseComponent) res );
|
||||
}
|
||||
component.setHoverEvent(hoverEvent);
|
||||
component.setHoverEvent( hoverEvent );
|
||||
}
|
||||
}
|
||||
|
||||
protected void serialize(JsonObject object, BaseComponent component, JsonSerializationContext context) {
|
||||
if (component.getColorRaw() != null) {
|
||||
object.addProperty("color", component.getColorRaw().getName());
|
||||
protected void serialize(JsonObject object, BaseComponent component, JsonSerializationContext context)
|
||||
{
|
||||
if (component.getColorRaw() != null)
|
||||
{
|
||||
object.addProperty( "color", component.getColorRaw().getName() );
|
||||
}
|
||||
if (component.isBoldRaw() != null) {
|
||||
object.addProperty("bold", component.isBoldRaw());
|
||||
if (component.isBoldRaw() != null)
|
||||
{
|
||||
object.addProperty( "bold", component.isBoldRaw() );
|
||||
}
|
||||
if (component.isItalicRaw() != null) {
|
||||
object.addProperty("italic", component.isItalicRaw());
|
||||
if (component.isItalicRaw() != null)
|
||||
{
|
||||
object.addProperty( "italic", component.isItalicRaw() );
|
||||
}
|
||||
if (component.isUnderlinedRaw() != null) {
|
||||
object.addProperty("underlined", component.isUnderlinedRaw());
|
||||
if (component.isUnderlinedRaw() != null)
|
||||
{
|
||||
object.addProperty( "underlined", component.isUnderlinedRaw() );
|
||||
}
|
||||
if (component.isStrikethroughRaw() != null) {
|
||||
object.addProperty("strikethrough", component.isStrikethroughRaw());
|
||||
if (component.isStrikethroughRaw() != null)
|
||||
{
|
||||
object.addProperty( "strikethrough", component.isStrikethroughRaw() );
|
||||
}
|
||||
if (component.isObfuscatedRaw() != null) {
|
||||
object.addProperty("obfuscated", component.isObfuscatedRaw());
|
||||
if (component.isObfuscatedRaw() != null)
|
||||
{
|
||||
object.addProperty( "obfuscated", component.isObfuscatedRaw() );
|
||||
}
|
||||
|
||||
if (component.getExtra() != null) {
|
||||
object.add("extra", context.serialize(component.getExtra()));
|
||||
if (component.getExtra() != null)
|
||||
{
|
||||
object.add( "extra", context.serialize( component.getExtra() ) );
|
||||
}
|
||||
|
||||
//Events
|
||||
if (component.getClickEvent() != null) {
|
||||
if (component.getClickEvent() != null)
|
||||
{
|
||||
JsonObject clickEvent = new JsonObject();
|
||||
clickEvent.addProperty("action", component.getClickEvent().getAction().toString().toLowerCase());
|
||||
clickEvent.addProperty("value", component.getClickEvent().getValue());
|
||||
clickEvent.addProperty( "action", component.getClickEvent().getAction().toString().toLowerCase() );
|
||||
clickEvent.addProperty( "value", component.getClickEvent().getValue() );
|
||||
}
|
||||
if (component.getHoverEvent() != null) {
|
||||
if (component.getHoverEvent() != null)
|
||||
{
|
||||
JsonObject clickEvent = new JsonObject();
|
||||
clickEvent.addProperty("action", component.getHoverEvent().getAction().toString().toLowerCase());
|
||||
clickEvent.add("value", context.serialize(component.getHoverEvent().getValue()));
|
||||
clickEvent.addProperty( "action", component.getHoverEvent().getAction().toString().toLowerCase() );
|
||||
clickEvent.add( "value", context.serialize( component.getHoverEvent().getValue() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,59 +1,66 @@
|
||||
package net.md_5.bungee.chat;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
|
||||
import javax.xml.soap.Text;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ComponentSerializer implements JsonSerializer<BaseComponent>, JsonDeserializer<BaseComponent> {
|
||||
public class ComponentSerializer implements JsonSerializer<BaseComponent>, JsonDeserializer<BaseComponent>
|
||||
{
|
||||
|
||||
private final static Gson gson = new GsonBuilder().
|
||||
registerTypeAdapter(BaseComponent.class, new ComponentSerializer()).
|
||||
registerTypeAdapter(TextComponent.class, new TextComponentSerializer()).
|
||||
registerTypeAdapter(TranslatableComponent.class, new TranslatableComponentSerializer()).
|
||||
registerTypeAdapter( BaseComponent.class, new ComponentSerializer() ).
|
||||
registerTypeAdapter( TextComponent.class, new TextComponentSerializer() ).
|
||||
registerTypeAdapter( TranslatableComponent.class, new TranslatableComponentSerializer() ).
|
||||
create();
|
||||
|
||||
public static BaseComponent[] parse(String json) {
|
||||
if (json.startsWith("[")) { //Array
|
||||
return gson.fromJson(json, BaseComponent[].class);
|
||||
public static BaseComponent[] parse(String json)
|
||||
{
|
||||
if (json.startsWith( "[" ))
|
||||
{ //Array
|
||||
return gson.fromJson( json, BaseComponent[].class );
|
||||
}
|
||||
return new BaseComponent[]{gson.fromJson(json, BaseComponent.class)};
|
||||
return new BaseComponent[]{gson.fromJson( json, BaseComponent.class )};
|
||||
}
|
||||
|
||||
public static String toString(BaseComponent component) {
|
||||
return gson.toJson(component);
|
||||
public static String toString(BaseComponent component)
|
||||
{
|
||||
return gson.toJson( component );
|
||||
}
|
||||
|
||||
public static String toString(BaseComponent[] components) {
|
||||
return gson.toJson(components);
|
||||
public static String toString(BaseComponent[] components)
|
||||
{
|
||||
return gson.toJson( components );
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
if (json.isJsonPrimitive()) {
|
||||
return new TextComponent(json.getAsString());
|
||||
public BaseComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
if (json.isJsonPrimitive())
|
||||
{
|
||||
return new TextComponent( json.getAsString() );
|
||||
}
|
||||
JsonObject object = json.getAsJsonObject();
|
||||
if (object.has("translate")) {
|
||||
return context.deserialize(json, TranslatableComponent.class);
|
||||
if (object.has( "translate" ))
|
||||
{
|
||||
return context.deserialize( json, TranslatableComponent.class );
|
||||
}
|
||||
return context.deserialize(json, TextComponent.class);
|
||||
return context.deserialize( json, TextComponent.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(BaseComponent src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return context.serialize(src, src.getClass());
|
||||
public JsonElement serialize(BaseComponent src, Type typeOfSrc, JsonSerializationContext context)
|
||||
{
|
||||
return context.serialize( src, src.getClass() );
|
||||
}
|
||||
}
|
||||
|
@@ -1,28 +1,39 @@
|
||||
package net.md_5.bungee.chat;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class TextComponentSerializer extends BaseComponentSerializer implements JsonSerializer<TextComponent> , JsonDeserializer<TextComponent>{
|
||||
public class TextComponentSerializer extends BaseComponentSerializer implements JsonSerializer<TextComponent>, JsonDeserializer<TextComponent>
|
||||
{
|
||||
@Override
|
||||
public TextComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
public TextComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
TextComponent component = new TextComponent();
|
||||
JsonObject object = json.getAsJsonObject();
|
||||
deserialize(object, component, context);
|
||||
component.setText(object.get("text").getAsString());
|
||||
deserialize( object, component, context );
|
||||
component.setText( object.get( "text" ).getAsString() );
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
if (!src.hasFormatting()) {
|
||||
return new JsonPrimitive(src.getText());
|
||||
public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context)
|
||||
{
|
||||
if (!src.hasFormatting())
|
||||
{
|
||||
return new JsonPrimitive( src.getText() );
|
||||
}
|
||||
JsonObject object = new JsonObject();
|
||||
serialize(object, src, context);
|
||||
object.addProperty("text", src.getText());
|
||||
serialize( object, src, context );
|
||||
object.addProperty( "text", src.getText() );
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
@@ -1,34 +1,43 @@
|
||||
package net.md_5.bungee.chat;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TranslatableComponentSerializer extends BaseComponentSerializer implements JsonSerializer<TranslatableComponent> , JsonDeserializer<TranslatableComponent>{
|
||||
public class TranslatableComponentSerializer extends BaseComponentSerializer implements JsonSerializer<TranslatableComponent>, JsonDeserializer<TranslatableComponent>
|
||||
{
|
||||
@Override
|
||||
public TranslatableComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
public TranslatableComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
TranslatableComponent component = new TranslatableComponent();
|
||||
JsonObject object = json.getAsJsonObject();
|
||||
deserialize(object, component, context);
|
||||
component.setTranslate(object.get("translate").getAsString());
|
||||
if (object.has("with")) {
|
||||
component.setWith(Arrays.asList((BaseComponent[])context.deserialize(object.get("with"), BaseComponent[].class)));
|
||||
deserialize( object, component, context );
|
||||
component.setTranslate( object.get( "translate" ).getAsString() );
|
||||
if (object.has( "with" ))
|
||||
{
|
||||
component.setWith( Arrays.asList( (BaseComponent[]) context.deserialize( object.get( "with" ), BaseComponent[].class ) ) );
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(TranslatableComponent src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
public JsonElement serialize(TranslatableComponent src, Type typeOfSrc, JsonSerializationContext context)
|
||||
{
|
||||
JsonObject object = new JsonObject();
|
||||
serialize(object, src, context);
|
||||
object.addProperty("translate", src.getTranslate());
|
||||
if (src.getWith() != null) {
|
||||
object.add("with", context.serialize(src.getWith()));
|
||||
serialize( object, src, context );
|
||||
object.addProperty( "translate", src.getTranslate() );
|
||||
if (src.getWith() != null)
|
||||
{
|
||||
object.add( "with", context.serialize( src.getWith() ) );
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
@@ -29,19 +29,21 @@ public class ConsoleCommandSender implements CommandSender
|
||||
@Override
|
||||
public void sendMessages(String... messages)
|
||||
{
|
||||
for ( String message : messages )
|
||||
for (String message : messages)
|
||||
{
|
||||
sendMessage( message );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent[] message) {
|
||||
sendMessage(BaseComponent.toLegacyText(message));
|
||||
public void sendMessage(BaseComponent[] message)
|
||||
{
|
||||
sendMessage( BaseComponent.toLegacyText( message ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent message) {
|
||||
public void sendMessage(BaseComponent message)
|
||||
{
|
||||
sendMessage( message.toLegacyText() );
|
||||
}
|
||||
|
||||
|
@@ -398,25 +398,27 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@Override
|
||||
public synchronized void disconnect(String reason)
|
||||
{
|
||||
if ( !ch.isClosed() )
|
||||
if (!ch.isClosed())
|
||||
{
|
||||
unsafe().sendPacket( new Kick( ComponentSerializer.toString(TextComponent.fromLegacyText(reason)) ) );
|
||||
unsafe().sendPacket( new Kick( ComponentSerializer.toString( TextComponent.fromLegacyText( reason ) ) ) );
|
||||
ch.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(BaseComponent[] reason) {
|
||||
if ( !ch.isClosed() )
|
||||
public void disconnect(BaseComponent[] reason)
|
||||
{
|
||||
if (!ch.isClosed())
|
||||
{
|
||||
unsafe().sendPacket( new Kick( ComponentSerializer.toString(reason) ) );
|
||||
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
|
||||
ch.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(BaseComponent reason) {
|
||||
disconnect(new BaseComponent[]{reason});
|
||||
public void disconnect(BaseComponent reason)
|
||||
{
|
||||
disconnect( new BaseComponent[]{reason} );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user