mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-24 03:05:49 +01:00
More formatting fixes
This commit is contained in:
parent
35c1b26a20
commit
890fac27c5
@ -53,7 +53,7 @@ public abstract class BaseComponent
|
|||||||
public static String toLegacyText(BaseComponent[] components)
|
public static String toLegacyText(BaseComponent[] components)
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (BaseComponent msg : components)
|
for ( BaseComponent msg : components )
|
||||||
{
|
{
|
||||||
builder.append( msg.toLegacyText() );
|
builder.append( msg.toLegacyText() );
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public abstract class BaseComponent
|
|||||||
public static String toPlainText(BaseComponent[] components)
|
public static String toPlainText(BaseComponent[] components)
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (BaseComponent msg : components)
|
for ( BaseComponent msg : components )
|
||||||
{
|
{
|
||||||
builder.append( msg.toPlainText() );
|
builder.append( msg.toPlainText() );
|
||||||
}
|
}
|
||||||
@ -80,9 +80,9 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public ChatColor getColor()
|
public ChatColor getColor()
|
||||||
{
|
{
|
||||||
if (color == null)
|
if ( color == null )
|
||||||
{
|
{
|
||||||
if (parent == null)
|
if ( parent == null )
|
||||||
{
|
{
|
||||||
return ChatColor.WHITE;
|
return ChatColor.WHITE;
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public boolean isBold()
|
public boolean isBold()
|
||||||
{
|
{
|
||||||
if (bold == null)
|
if ( bold == null )
|
||||||
{
|
{
|
||||||
return parent != null && parent.isBold();
|
return parent != null && parent.isBold();
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public boolean isItalic()
|
public boolean isItalic()
|
||||||
{
|
{
|
||||||
if (italic == null)
|
if ( italic == null )
|
||||||
{
|
{
|
||||||
return parent != null && parent.isItalic();
|
return parent != null && parent.isItalic();
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public boolean isUnderlined()
|
public boolean isUnderlined()
|
||||||
{
|
{
|
||||||
if (underlined == null)
|
if ( underlined == null )
|
||||||
{
|
{
|
||||||
return parent != null && parent.isUnderlined();
|
return parent != null && parent.isUnderlined();
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public boolean isStrikethrough()
|
public boolean isStrikethrough()
|
||||||
{
|
{
|
||||||
if (strikethrough == null)
|
if ( strikethrough == null )
|
||||||
{
|
{
|
||||||
return parent != null && parent.isStrikethrough();
|
return parent != null && parent.isStrikethrough();
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public boolean isObfuscated()
|
public boolean isObfuscated()
|
||||||
{
|
{
|
||||||
if (obfuscated == null)
|
if ( obfuscated == null )
|
||||||
{
|
{
|
||||||
return parent != null && parent.isObfuscated();
|
return parent != null && parent.isObfuscated();
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ public abstract class BaseComponent
|
|||||||
|
|
||||||
public void setExtra(List<BaseComponent> components)
|
public void setExtra(List<BaseComponent> components)
|
||||||
{
|
{
|
||||||
for (BaseComponent component : components)
|
for ( BaseComponent component : components )
|
||||||
{
|
{
|
||||||
component.parent = this;
|
component.parent = this;
|
||||||
}
|
}
|
||||||
@ -265,7 +265,7 @@ public abstract class BaseComponent
|
|||||||
*/
|
*/
|
||||||
public void addExtra(BaseComponent component)
|
public void addExtra(BaseComponent component)
|
||||||
{
|
{
|
||||||
if (extra == null)
|
if ( extra == null )
|
||||||
{
|
{
|
||||||
extra = new ArrayList<>();
|
extra = new ArrayList<>();
|
||||||
}
|
}
|
||||||
@ -289,9 +289,9 @@ public abstract class BaseComponent
|
|||||||
|
|
||||||
protected void toPlainText(StringBuilder builder)
|
protected void toPlainText(StringBuilder builder)
|
||||||
{
|
{
|
||||||
if (extra != null)
|
if ( extra != null )
|
||||||
{
|
{
|
||||||
for (BaseComponent e : extra)
|
for ( BaseComponent e : extra )
|
||||||
{
|
{
|
||||||
e.toPlainText( builder );
|
e.toPlainText( builder );
|
||||||
}
|
}
|
||||||
@ -307,9 +307,9 @@ public abstract class BaseComponent
|
|||||||
|
|
||||||
protected void toLegacyText(StringBuilder builder)
|
protected void toLegacyText(StringBuilder builder)
|
||||||
{
|
{
|
||||||
if (extra != null)
|
if ( extra != null )
|
||||||
{
|
{
|
||||||
for (BaseComponent e : extra)
|
for ( BaseComponent e : extra )
|
||||||
{
|
{
|
||||||
e.toLegacyText( builder );
|
e.toLegacyText( builder );
|
||||||
}
|
}
|
||||||
|
@ -26,18 +26,18 @@ public class TextComponent extends BaseComponent
|
|||||||
TextComponent component = new TextComponent();
|
TextComponent component = new TextComponent();
|
||||||
Matcher matcher = url.matcher( message );
|
Matcher matcher = url.matcher( message );
|
||||||
|
|
||||||
for (int i = 0; i < message.length(); i++)
|
for ( int i = 0; i < message.length(); i++ )
|
||||||
{
|
{
|
||||||
char c = message.charAt( i );
|
char c = message.charAt( i );
|
||||||
if (c == ChatColor.COLOR_CHAR)
|
if ( c == ChatColor.COLOR_CHAR )
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
c = message.charAt( i );
|
c = message.charAt( i );
|
||||||
if (c >= 'A' && c <= 'Z')
|
if ( c >= 'A' && c <= 'Z' )
|
||||||
{
|
{
|
||||||
c += 32;
|
c += 32;
|
||||||
}
|
}
|
||||||
if (builder.length() > 0)
|
if ( builder.length() > 0 )
|
||||||
{
|
{
|
||||||
TextComponent old = component;
|
TextComponent old = component;
|
||||||
component = new TextComponent( old );
|
component = new TextComponent( old );
|
||||||
@ -46,7 +46,7 @@ public class TextComponent extends BaseComponent
|
|||||||
components.add( old );
|
components.add( old );
|
||||||
}
|
}
|
||||||
ChatColor format = ChatColor.getByChar( c );
|
ChatColor format = ChatColor.getByChar( c );
|
||||||
switch (format)
|
switch ( format )
|
||||||
{
|
{
|
||||||
case BOLD:
|
case BOLD:
|
||||||
component.setBold( true );
|
component.setBold( true );
|
||||||
@ -73,11 +73,11 @@ public class TextComponent extends BaseComponent
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int pos = message.indexOf( ' ', i );
|
int pos = message.indexOf( ' ', i );
|
||||||
if (pos == -1) pos = message.length();
|
if ( pos == -1 ) pos = message.length();
|
||||||
if (matcher.region( i, pos ).find())
|
if ( matcher.region( i, pos ).find() )
|
||||||
{ //Web link handling
|
{ //Web link handling
|
||||||
|
|
||||||
if (builder.length() > 0)
|
if ( builder.length() > 0 )
|
||||||
{
|
{
|
||||||
TextComponent old = component;
|
TextComponent old = component;
|
||||||
component = new TextComponent( old );
|
component = new TextComponent( old );
|
||||||
@ -91,7 +91,7 @@ public class TextComponent extends BaseComponent
|
|||||||
ClickEvent clickEvent = new ClickEvent();
|
ClickEvent clickEvent = new ClickEvent();
|
||||||
clickEvent.setAction( ClickEvent.Action.OPEN_URL );
|
clickEvent.setAction( ClickEvent.Action.OPEN_URL );
|
||||||
String urlString = message.substring( i, pos );
|
String urlString = message.substring( i, pos );
|
||||||
if (urlString.startsWith( "http" ))
|
if ( urlString.startsWith( "http" ) )
|
||||||
{
|
{
|
||||||
component.setText( urlString );
|
component.setText( urlString );
|
||||||
clickEvent.setValue( urlString );
|
clickEvent.setValue( urlString );
|
||||||
@ -108,7 +108,7 @@ public class TextComponent extends BaseComponent
|
|||||||
}
|
}
|
||||||
builder.append( c );
|
builder.append( c );
|
||||||
}
|
}
|
||||||
if (builder.length() > 0)
|
if ( builder.length() > 0 )
|
||||||
{
|
{
|
||||||
component.setText( builder.toString() );
|
component.setText( builder.toString() );
|
||||||
components.add( component );
|
components.add( component );
|
||||||
@ -135,11 +135,11 @@ public class TextComponent extends BaseComponent
|
|||||||
protected void toLegacyText(StringBuilder builder)
|
protected void toLegacyText(StringBuilder builder)
|
||||||
{
|
{
|
||||||
builder.append( getColor() );
|
builder.append( getColor() );
|
||||||
if (isBold()) builder.append( ChatColor.BOLD );
|
if ( isBold() ) builder.append( ChatColor.BOLD );
|
||||||
if (isItalic()) builder.append( ChatColor.ITALIC );
|
if ( isItalic() ) builder.append( ChatColor.ITALIC );
|
||||||
if (isUnderlined()) builder.append( ChatColor.UNDERLINE );
|
if ( isUnderlined() ) builder.append( ChatColor.UNDERLINE );
|
||||||
if (isStrikethrough()) builder.append( ChatColor.STRIKETHROUGH );
|
if ( isStrikethrough() ) builder.append( ChatColor.STRIKETHROUGH );
|
||||||
if (isObfuscated()) builder.append( ChatColor.MAGIC );
|
if ( isObfuscated() ) builder.append( ChatColor.MAGIC );
|
||||||
builder.append( text );
|
builder.append( text );
|
||||||
super.toLegacyText( builder );
|
super.toLegacyText( builder );
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@ public class TranslatableComponent extends BaseComponent
|
|||||||
{
|
{
|
||||||
setTranslate( translate );
|
setTranslate( translate );
|
||||||
this.with = new ArrayList<>();
|
this.with = new ArrayList<>();
|
||||||
for (Object w : with)
|
for ( Object w : with )
|
||||||
{
|
{
|
||||||
if (w instanceof String)
|
if ( w instanceof String )
|
||||||
{
|
{
|
||||||
this.with.add( new TextComponent( (String) w ) );
|
this.with.add( new TextComponent( (String) w ) );
|
||||||
} else
|
} else
|
||||||
@ -34,7 +34,7 @@ public class TranslatableComponent extends BaseComponent
|
|||||||
|
|
||||||
public void setWith(List<BaseComponent> components)
|
public void setWith(List<BaseComponent> components)
|
||||||
{
|
{
|
||||||
for (BaseComponent component : components)
|
for ( BaseComponent component : components )
|
||||||
{
|
{
|
||||||
component.parent = this;
|
component.parent = this;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class ServerConnection implements Server
|
|||||||
@Override
|
@Override
|
||||||
public void disconnect(BaseComponent[] reason)
|
public void disconnect(BaseComponent[] reason)
|
||||||
{
|
{
|
||||||
if (!ch.isClosed())
|
if ( !ch.isClosed() )
|
||||||
{
|
{
|
||||||
// TODO: Can we just use a future here?
|
// TODO: Can we just use a future here?
|
||||||
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
|
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
|
||||||
|
@ -276,12 +276,12 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
|
|
||||||
public synchronized void disconnect0(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 ) );
|
bungee.getLogger().log( Level.INFO, "[" + getName() + "] disconnected with: " + BaseComponent.toLegacyText( reason ) );
|
||||||
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
|
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
|
||||||
ch.close();
|
ch.close();
|
||||||
if (server != null)
|
if ( server != null )
|
||||||
{
|
{
|
||||||
server.disconnect( "Quitting" );
|
server.disconnect( "Quitting" );
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
@Override
|
@Override
|
||||||
public void sendMessages(String... messages)
|
public void sendMessages(String... messages)
|
||||||
{
|
{
|
||||||
for (String message : messages)
|
for ( String message : messages )
|
||||||
{
|
{
|
||||||
sendMessage( message );
|
sendMessage( message );
|
||||||
}
|
}
|
||||||
|
@ -15,50 +15,50 @@ public class BaseComponentSerializer
|
|||||||
|
|
||||||
protected void deserialize(JsonObject object, BaseComponent component, JsonDeserializationContext context)
|
protected void deserialize(JsonObject object, BaseComponent component, JsonDeserializationContext context)
|
||||||
{
|
{
|
||||||
if (object.has( "color" ))
|
if ( object.has( "color" ) )
|
||||||
{
|
{
|
||||||
component.setColor( ChatColor.valueOf( object.get( "color" ).getAsString().toUpperCase() ) );
|
component.setColor( ChatColor.valueOf( object.get( "color" ).getAsString().toUpperCase() ) );
|
||||||
}
|
}
|
||||||
if (object.has( "bold" ))
|
if ( object.has( "bold" ) )
|
||||||
{
|
{
|
||||||
component.setBold( object.get( "bold" ).getAsBoolean() );
|
component.setBold( object.get( "bold" ).getAsBoolean() );
|
||||||
}
|
}
|
||||||
if (object.has( "italic" ))
|
if ( object.has( "italic" ) )
|
||||||
{
|
{
|
||||||
component.setItalic( object.get( "italic" ).getAsBoolean() );
|
component.setItalic( object.get( "italic" ).getAsBoolean() );
|
||||||
}
|
}
|
||||||
if (object.has( "underlined" ))
|
if ( object.has( "underlined" ) )
|
||||||
{
|
{
|
||||||
component.setUnderlined( object.get( "underlined" ).getAsBoolean() );
|
component.setUnderlined( object.get( "underlined" ).getAsBoolean() );
|
||||||
}
|
}
|
||||||
if (object.has( "strikethrough" ))
|
if ( object.has( "strikethrough" ) )
|
||||||
{
|
{
|
||||||
component.setUnderlined( object.get( "strikethrough" ).getAsBoolean() );
|
component.setUnderlined( object.get( "strikethrough" ).getAsBoolean() );
|
||||||
}
|
}
|
||||||
if (object.has( "obfuscated" ))
|
if ( object.has( "obfuscated" ) )
|
||||||
{
|
{
|
||||||
component.setUnderlined( object.get( "obfuscated" ).getAsBoolean() );
|
component.setUnderlined( object.get( "obfuscated" ).getAsBoolean() );
|
||||||
}
|
}
|
||||||
if (object.has( "extra" ))
|
if ( object.has( "extra" ) )
|
||||||
{
|
{
|
||||||
component.setExtra( Arrays.asList( (BaseComponent[]) context.deserialize( object.get( "extra" ), BaseComponent[].class ) ) );
|
component.setExtra( Arrays.asList( (BaseComponent[]) context.deserialize( object.get( "extra" ), BaseComponent[].class ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//Events
|
//Events
|
||||||
if (object.has( "clickEvent" ))
|
if ( object.has( "clickEvent" ) )
|
||||||
{
|
{
|
||||||
JsonObject event = object.getAsJsonObject( "clickEvent" );
|
JsonObject event = object.getAsJsonObject( "clickEvent" );
|
||||||
component.setClickEvent( new ClickEvent(
|
component.setClickEvent( new ClickEvent(
|
||||||
ClickEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase() ),
|
ClickEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase() ),
|
||||||
event.get( "value" ).getAsString() ) );
|
event.get( "value" ).getAsString() ) );
|
||||||
}
|
}
|
||||||
if (object.has( "hoverEvent" ))
|
if ( object.has( "hoverEvent" ) )
|
||||||
{
|
{
|
||||||
JsonObject event = object.getAsJsonObject( "hoverEvent" );
|
JsonObject event = object.getAsJsonObject( "hoverEvent" );
|
||||||
HoverEvent hoverEvent = new HoverEvent();
|
HoverEvent hoverEvent = new HoverEvent();
|
||||||
hoverEvent.setAction( HoverEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase() ) );
|
hoverEvent.setAction( HoverEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase() ) );
|
||||||
Object res = context.deserialize( event.get( "value" ), BaseComponent.class );
|
Object res = context.deserialize( event.get( "value" ), BaseComponent.class );
|
||||||
if (res instanceof String)
|
if ( res instanceof String )
|
||||||
{
|
{
|
||||||
hoverEvent.setValue( (String) res );
|
hoverEvent.setValue( (String) res );
|
||||||
} else
|
} else
|
||||||
@ -71,44 +71,44 @@ public class BaseComponentSerializer
|
|||||||
|
|
||||||
protected void serialize(JsonObject object, BaseComponent component, JsonSerializationContext context)
|
protected void serialize(JsonObject object, BaseComponent component, JsonSerializationContext context)
|
||||||
{
|
{
|
||||||
if (component.getColorRaw() != null)
|
if ( component.getColorRaw() != null )
|
||||||
{
|
{
|
||||||
object.addProperty( "color", component.getColorRaw().getName() );
|
object.addProperty( "color", component.getColorRaw().getName() );
|
||||||
}
|
}
|
||||||
if (component.isBoldRaw() != null)
|
if ( component.isBoldRaw() != null )
|
||||||
{
|
{
|
||||||
object.addProperty( "bold", component.isBoldRaw() );
|
object.addProperty( "bold", component.isBoldRaw() );
|
||||||
}
|
}
|
||||||
if (component.isItalicRaw() != null)
|
if ( component.isItalicRaw() != null )
|
||||||
{
|
{
|
||||||
object.addProperty( "italic", component.isItalicRaw() );
|
object.addProperty( "italic", component.isItalicRaw() );
|
||||||
}
|
}
|
||||||
if (component.isUnderlinedRaw() != null)
|
if ( component.isUnderlinedRaw() != null )
|
||||||
{
|
{
|
||||||
object.addProperty( "underlined", component.isUnderlinedRaw() );
|
object.addProperty( "underlined", component.isUnderlinedRaw() );
|
||||||
}
|
}
|
||||||
if (component.isStrikethroughRaw() != null)
|
if ( component.isStrikethroughRaw() != null )
|
||||||
{
|
{
|
||||||
object.addProperty( "strikethrough", component.isStrikethroughRaw() );
|
object.addProperty( "strikethrough", component.isStrikethroughRaw() );
|
||||||
}
|
}
|
||||||
if (component.isObfuscatedRaw() != null)
|
if ( component.isObfuscatedRaw() != null )
|
||||||
{
|
{
|
||||||
object.addProperty( "obfuscated", component.isObfuscatedRaw() );
|
object.addProperty( "obfuscated", component.isObfuscatedRaw() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component.getExtra() != null)
|
if ( component.getExtra() != null )
|
||||||
{
|
{
|
||||||
object.add( "extra", context.serialize( component.getExtra() ) );
|
object.add( "extra", context.serialize( component.getExtra() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//Events
|
//Events
|
||||||
if (component.getClickEvent() != null)
|
if ( component.getClickEvent() != null )
|
||||||
{
|
{
|
||||||
JsonObject clickEvent = new JsonObject();
|
JsonObject clickEvent = new JsonObject();
|
||||||
clickEvent.addProperty( "action", component.getClickEvent().getAction().toString().toLowerCase() );
|
clickEvent.addProperty( "action", component.getClickEvent().getAction().toString().toLowerCase() );
|
||||||
clickEvent.addProperty( "value", component.getClickEvent().getValue() );
|
clickEvent.addProperty( "value", component.getClickEvent().getValue() );
|
||||||
}
|
}
|
||||||
if (component.getHoverEvent() != null)
|
if ( component.getHoverEvent() != null )
|
||||||
{
|
{
|
||||||
JsonObject clickEvent = new JsonObject();
|
JsonObject clickEvent = new JsonObject();
|
||||||
clickEvent.addProperty( "action", component.getHoverEvent().getAction().toString().toLowerCase() );
|
clickEvent.addProperty( "action", component.getHoverEvent().getAction().toString().toLowerCase() );
|
||||||
|
@ -26,7 +26,7 @@ public class ComponentSerializer implements JsonSerializer<BaseComponent>, JsonD
|
|||||||
|
|
||||||
public static BaseComponent[] parse(String json)
|
public static BaseComponent[] parse(String json)
|
||||||
{
|
{
|
||||||
if (json.startsWith( "[" ))
|
if ( json.startsWith( "[" ) )
|
||||||
{ //Array
|
{ //Array
|
||||||
return gson.fromJson( json, BaseComponent[].class );
|
return gson.fromJson( json, BaseComponent[].class );
|
||||||
}
|
}
|
||||||
@ -46,12 +46,12 @@ public class ComponentSerializer implements JsonSerializer<BaseComponent>, JsonD
|
|||||||
@Override
|
@Override
|
||||||
public BaseComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
public BaseComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||||
{
|
{
|
||||||
if (json.isJsonPrimitive())
|
if ( json.isJsonPrimitive() )
|
||||||
{
|
{
|
||||||
return new TextComponent( json.getAsString() );
|
return new TextComponent( json.getAsString() );
|
||||||
}
|
}
|
||||||
JsonObject object = json.getAsJsonObject();
|
JsonObject object = json.getAsJsonObject();
|
||||||
if (object.has( "translate" ))
|
if ( object.has( "translate" ) )
|
||||||
{
|
{
|
||||||
return context.deserialize( json, TranslatableComponent.class );
|
return context.deserialize( json, TranslatableComponent.class );
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class TextComponentSerializer extends BaseComponentSerializer implements
|
|||||||
@Override
|
@Override
|
||||||
public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context)
|
public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context)
|
||||||
{
|
{
|
||||||
if (!src.hasFormatting())
|
if ( !src.hasFormatting() )
|
||||||
{
|
{
|
||||||
return new JsonPrimitive( src.getText() );
|
return new JsonPrimitive( src.getText() );
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class TranslatableComponentSerializer extends BaseComponentSerializer imp
|
|||||||
JsonObject object = json.getAsJsonObject();
|
JsonObject object = json.getAsJsonObject();
|
||||||
deserialize( object, component, context );
|
deserialize( object, component, context );
|
||||||
component.setTranslate( object.get( "translate" ).getAsString() );
|
component.setTranslate( object.get( "translate" ).getAsString() );
|
||||||
if (object.has( "with" ))
|
if ( object.has( "with" ) )
|
||||||
{
|
{
|
||||||
component.setWith( Arrays.asList( (BaseComponent[]) context.deserialize( object.get( "with" ), BaseComponent[].class ) ) );
|
component.setWith( Arrays.asList( (BaseComponent[]) context.deserialize( object.get( "with" ), BaseComponent[].class ) ) );
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ public class TranslatableComponentSerializer extends BaseComponentSerializer imp
|
|||||||
JsonObject object = new JsonObject();
|
JsonObject object = new JsonObject();
|
||||||
serialize( object, src, context );
|
serialize( object, src, context );
|
||||||
object.addProperty( "translate", src.getTranslate() );
|
object.addProperty( "translate", src.getTranslate() );
|
||||||
if (src.getWith() != null)
|
if ( src.getWith() != null )
|
||||||
{
|
{
|
||||||
object.add( "with", context.serialize( src.getWith() ) );
|
object.add( "with", context.serialize( src.getWith() ) );
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class ConsoleCommandSender implements CommandSender
|
|||||||
@Override
|
@Override
|
||||||
public void sendMessages(String... messages)
|
public void sendMessages(String... messages)
|
||||||
{
|
{
|
||||||
for (String message : messages)
|
for ( String message : messages )
|
||||||
{
|
{
|
||||||
sendMessage( message );
|
sendMessage( message );
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
@Override
|
@Override
|
||||||
public void disconnect(BaseComponent[] reason)
|
public void disconnect(BaseComponent[] reason)
|
||||||
{
|
{
|
||||||
if (!ch.isClosed())
|
if ( !ch.isClosed() )
|
||||||
{
|
{
|
||||||
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
|
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
|
||||||
ch.close();
|
ch.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user