From 890fac27c5f64cabefbc186e7174404c8e0eccbe Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Fri, 6 Dec 2013 21:53:11 +0000 Subject: [PATCH] More formatting fixes --- .../md_5/bungee/api/chat/BaseComponent.java | 30 +++++++-------- .../md_5/bungee/api/chat/TextComponent.java | 30 +++++++-------- .../api/chat/TranslatableComponent.java | 6 +-- .../net/md_5/bungee/ServerConnection.java | 2 +- .../java/net/md_5/bungee/UserConnection.java | 6 +-- .../bungee/chat/BaseComponentSerializer.java | 38 +++++++++---------- .../md_5/bungee/chat/ComponentSerializer.java | 6 +-- .../bungee/chat/TextComponentSerializer.java | 2 +- .../chat/TranslatableComponentSerializer.java | 4 +- .../bungee/command/ConsoleCommandSender.java | 2 +- .../bungee/connection/InitialHandler.java | 2 +- 11 files changed, 64 insertions(+), 64 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java b/api/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java index 53eae97d..4162267d 100644 --- a/api/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java +++ b/api/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java @@ -53,7 +53,7 @@ public abstract class BaseComponent public static String toLegacyText(BaseComponent[] components) { StringBuilder builder = new StringBuilder(); - for (BaseComponent msg : components) + for ( BaseComponent msg : components ) { builder.append( msg.toLegacyText() ); } @@ -63,7 +63,7 @@ public abstract class BaseComponent public static String toPlainText(BaseComponent[] components) { StringBuilder builder = new StringBuilder(); - for (BaseComponent msg : components) + for ( BaseComponent msg : components ) { builder.append( msg.toPlainText() ); } @@ -80,9 +80,9 @@ public abstract class BaseComponent */ public ChatColor getColor() { - if (color == null) + if ( color == null ) { - if (parent == null) + if ( parent == null ) { return ChatColor.WHITE; } @@ -111,7 +111,7 @@ public abstract class BaseComponent */ public boolean isBold() { - if (bold == null) + if ( bold == null ) { return parent != null && parent.isBold(); } @@ -138,7 +138,7 @@ public abstract class BaseComponent */ public boolean isItalic() { - if (italic == null) + if ( italic == null ) { return parent != null && parent.isItalic(); } @@ -165,7 +165,7 @@ public abstract class BaseComponent */ public boolean isUnderlined() { - if (underlined == null) + if ( underlined == null ) { return parent != null && parent.isUnderlined(); } @@ -192,7 +192,7 @@ public abstract class BaseComponent */ public boolean isStrikethrough() { - if (strikethrough == null) + if ( strikethrough == null ) { return parent != null && parent.isStrikethrough(); } @@ -219,7 +219,7 @@ public abstract class BaseComponent */ public boolean isObfuscated() { - if (obfuscated == null) + if ( obfuscated == null ) { return parent != null && parent.isObfuscated(); } @@ -239,7 +239,7 @@ public abstract class BaseComponent public void setExtra(List components) { - for (BaseComponent component : components) + for ( BaseComponent component : components ) { component.parent = this; } @@ -265,7 +265,7 @@ public abstract class BaseComponent */ public void addExtra(BaseComponent component) { - if (extra == null) + if ( extra == null ) { extra = new ArrayList<>(); } @@ -289,9 +289,9 @@ public abstract class BaseComponent protected void toPlainText(StringBuilder builder) { - if (extra != null) + if ( extra != null ) { - for (BaseComponent e : extra) + for ( BaseComponent e : extra ) { e.toPlainText( builder ); } @@ -307,9 +307,9 @@ public abstract class BaseComponent protected void toLegacyText(StringBuilder builder) { - if (extra != null) + if ( extra != null ) { - for (BaseComponent e : extra) + for ( BaseComponent e : extra ) { e.toLegacyText( builder ); } diff --git a/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java b/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java index 723183f2..d4e79706 100644 --- a/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java +++ b/api/src/main/java/net/md_5/bungee/api/chat/TextComponent.java @@ -26,18 +26,18 @@ public class TextComponent extends BaseComponent TextComponent component = new TextComponent(); 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 ); - if (c == ChatColor.COLOR_CHAR) + if ( c == ChatColor.COLOR_CHAR ) { i++; c = message.charAt( i ); - if (c >= 'A' && c <= 'Z') + if ( c >= 'A' && c <= 'Z' ) { c += 32; } - if (builder.length() > 0) + if ( builder.length() > 0 ) { TextComponent old = component; component = new TextComponent( old ); @@ -46,7 +46,7 @@ public class TextComponent extends BaseComponent components.add( old ); } ChatColor format = ChatColor.getByChar( c ); - switch (format) + switch ( format ) { case BOLD: component.setBold( true ); @@ -73,11 +73,11 @@ public class TextComponent extends BaseComponent continue; } int pos = message.indexOf( ' ', i ); - if (pos == -1) pos = message.length(); - if (matcher.region( i, pos ).find()) + if ( pos == -1 ) pos = message.length(); + if ( matcher.region( i, pos ).find() ) { //Web link handling - if (builder.length() > 0) + if ( builder.length() > 0 ) { TextComponent old = component; component = new TextComponent( old ); @@ -91,7 +91,7 @@ public class TextComponent extends BaseComponent ClickEvent clickEvent = new ClickEvent(); clickEvent.setAction( ClickEvent.Action.OPEN_URL ); String urlString = message.substring( i, pos ); - if (urlString.startsWith( "http" )) + if ( urlString.startsWith( "http" ) ) { component.setText( urlString ); clickEvent.setValue( urlString ); @@ -108,7 +108,7 @@ public class TextComponent extends BaseComponent } builder.append( c ); } - if (builder.length() > 0) + if ( builder.length() > 0 ) { component.setText( builder.toString() ); components.add( component ); @@ -135,11 +135,11 @@ public class TextComponent extends BaseComponent protected void toLegacyText(StringBuilder builder) { builder.append( getColor() ); - if (isBold()) builder.append( ChatColor.BOLD ); - if (isItalic()) builder.append( ChatColor.ITALIC ); - if (isUnderlined()) builder.append( ChatColor.UNDERLINE ); - if (isStrikethrough()) builder.append( ChatColor.STRIKETHROUGH ); - if (isObfuscated()) builder.append( ChatColor.MAGIC ); + if ( isBold() ) builder.append( ChatColor.BOLD ); + if ( isItalic() ) builder.append( ChatColor.ITALIC ); + if ( isUnderlined() ) builder.append( ChatColor.UNDERLINE ); + if ( isStrikethrough() ) builder.append( ChatColor.STRIKETHROUGH ); + if ( isObfuscated() ) builder.append( ChatColor.MAGIC ); builder.append( text ); super.toLegacyText( builder ); } diff --git a/api/src/main/java/net/md_5/bungee/api/chat/TranslatableComponent.java b/api/src/main/java/net/md_5/bungee/api/chat/TranslatableComponent.java index 51695adb..5cfdce3b 100644 --- a/api/src/main/java/net/md_5/bungee/api/chat/TranslatableComponent.java +++ b/api/src/main/java/net/md_5/bungee/api/chat/TranslatableComponent.java @@ -20,9 +20,9 @@ public class TranslatableComponent extends BaseComponent { setTranslate( translate ); 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 ) ); } else @@ -34,7 +34,7 @@ public class TranslatableComponent extends BaseComponent public void setWith(List components) { - for (BaseComponent component : components) + for ( BaseComponent component : components ) { component.parent = this; } diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java index 75f6ca40..e86240bd 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java @@ -49,7 +49,7 @@ public class ServerConnection implements Server @Override public void disconnect(BaseComponent[] reason) { - if (!ch.isClosed()) + if ( !ch.isClosed() ) { // TODO: Can we just use a future here? unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) ); diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index f7f0e5fa..6045b21f 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -276,12 +276,12 @@ public final class UserConnection implements ProxiedPlayer 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 ) ) ); ch.close(); - if (server != null) + if ( server != null ) { server.disconnect( "Quitting" ); } @@ -304,7 +304,7 @@ public final class UserConnection implements ProxiedPlayer @Override public void sendMessages(String... messages) { - for (String message : messages) + for ( String message : messages ) { sendMessage( message ); } diff --git a/proxy/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java b/proxy/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java index ffcfc2fa..65c3e6a4 100644 --- a/proxy/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java +++ b/proxy/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java @@ -15,50 +15,50 @@ public class BaseComponentSerializer 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() ) ); } - if (object.has( "bold" )) + if ( object.has( "bold" ) ) { component.setBold( object.get( "bold" ).getAsBoolean() ); } - if (object.has( "italic" )) + if ( object.has( "italic" ) ) { component.setItalic( object.get( "italic" ).getAsBoolean() ); } - if (object.has( "underlined" )) + if ( object.has( "underlined" ) ) { component.setUnderlined( object.get( "underlined" ).getAsBoolean() ); } - if (object.has( "strikethrough" )) + if ( object.has( "strikethrough" ) ) { component.setUnderlined( object.get( "strikethrough" ).getAsBoolean() ); } - if (object.has( "obfuscated" )) + if ( object.has( "obfuscated" ) ) { 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 ) ) ); } //Events - if (object.has( "clickEvent" )) + 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" )) + 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) + if ( res instanceof String ) { hoverEvent.setValue( (String) res ); } else @@ -71,44 +71,44 @@ public class BaseComponentSerializer protected void serialize(JsonObject object, BaseComponent component, JsonSerializationContext context) { - if (component.getColorRaw() != null) + if ( component.getColorRaw() != null ) { object.addProperty( "color", component.getColorRaw().getName() ); } - if (component.isBoldRaw() != null) + if ( component.isBoldRaw() != null ) { object.addProperty( "bold", component.isBoldRaw() ); } - if (component.isItalicRaw() != null) + if ( component.isItalicRaw() != null ) { object.addProperty( "italic", component.isItalicRaw() ); } - if (component.isUnderlinedRaw() != null) + if ( component.isUnderlinedRaw() != null ) { object.addProperty( "underlined", component.isUnderlinedRaw() ); } - if (component.isStrikethroughRaw() != null) + if ( component.isStrikethroughRaw() != null ) { object.addProperty( "strikethrough", component.isStrikethroughRaw() ); } - if (component.isObfuscatedRaw() != null) + if ( component.isObfuscatedRaw() != null ) { object.addProperty( "obfuscated", component.isObfuscatedRaw() ); } - if (component.getExtra() != null) + 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() ); } - if (component.getHoverEvent() != null) + if ( component.getHoverEvent() != null ) { JsonObject clickEvent = new JsonObject(); clickEvent.addProperty( "action", component.getHoverEvent().getAction().toString().toLowerCase() ); diff --git a/proxy/src/main/java/net/md_5/bungee/chat/ComponentSerializer.java b/proxy/src/main/java/net/md_5/bungee/chat/ComponentSerializer.java index e853d270..58dbc3f1 100644 --- a/proxy/src/main/java/net/md_5/bungee/chat/ComponentSerializer.java +++ b/proxy/src/main/java/net/md_5/bungee/chat/ComponentSerializer.java @@ -26,7 +26,7 @@ public class ComponentSerializer implements JsonSerializer, JsonD public static BaseComponent[] parse(String json) { - if (json.startsWith( "[" )) + if ( json.startsWith( "[" ) ) { //Array return gson.fromJson( json, BaseComponent[].class ); } @@ -46,12 +46,12 @@ public class ComponentSerializer implements JsonSerializer, JsonD @Override public BaseComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - if (json.isJsonPrimitive()) + if ( json.isJsonPrimitive() ) { return new TextComponent( json.getAsString() ); } JsonObject object = json.getAsJsonObject(); - if (object.has( "translate" )) + if ( object.has( "translate" ) ) { return context.deserialize( json, TranslatableComponent.class ); } diff --git a/proxy/src/main/java/net/md_5/bungee/chat/TextComponentSerializer.java b/proxy/src/main/java/net/md_5/bungee/chat/TextComponentSerializer.java index 246b47b8..031590d6 100644 --- a/proxy/src/main/java/net/md_5/bungee/chat/TextComponentSerializer.java +++ b/proxy/src/main/java/net/md_5/bungee/chat/TextComponentSerializer.java @@ -27,7 +27,7 @@ public class TextComponentSerializer extends BaseComponentSerializer implements @Override public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context) { - if (!src.hasFormatting()) + if ( !src.hasFormatting() ) { return new JsonPrimitive( src.getText() ); } diff --git a/proxy/src/main/java/net/md_5/bungee/chat/TranslatableComponentSerializer.java b/proxy/src/main/java/net/md_5/bungee/chat/TranslatableComponentSerializer.java index 97e1a02c..f48954a1 100644 --- a/proxy/src/main/java/net/md_5/bungee/chat/TranslatableComponentSerializer.java +++ b/proxy/src/main/java/net/md_5/bungee/chat/TranslatableComponentSerializer.java @@ -22,7 +22,7 @@ public class TranslatableComponentSerializer extends BaseComponentSerializer imp JsonObject object = json.getAsJsonObject(); deserialize( object, component, context ); 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 ) ) ); } @@ -35,7 +35,7 @@ public class TranslatableComponentSerializer extends BaseComponentSerializer imp JsonObject object = new JsonObject(); serialize( object, src, context ); object.addProperty( "translate", src.getTranslate() ); - if (src.getWith() != null) + if ( src.getWith() != null ) { object.add( "with", context.serialize( src.getWith() ) ); } diff --git a/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java b/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java index 3e29efbb..ba159474 100644 --- a/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java +++ b/proxy/src/main/java/net/md_5/bungee/command/ConsoleCommandSender.java @@ -29,7 +29,7 @@ public class ConsoleCommandSender implements CommandSender @Override public void sendMessages(String... messages) { - for (String message : messages) + for ( String message : messages ) { sendMessage( message ); } diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 04ba907d..4a326c24 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -408,7 +408,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection @Override public void disconnect(BaseComponent[] reason) { - if (!ch.isClosed()) + if ( !ch.isClosed() ) { unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) ); ch.close();