From 57a07dc2e284888bdc630cca06b2ef9feb641a85 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 25 Sep 2014 11:04:35 +1000 Subject: [PATCH] Update Depend Versions: Guava 17.0 -> 18.0 Lombok 1.12.6 -> 1.14.8 Gson 2.2.4 -> 2.3 SnakeYaml 1.13 -> 1.14 --- .../bungee/chat/BaseComponentSerializer.java | 141 ------------------ .../md_5/bungee/chat/ComponentSerializer.java | 64 -------- .../bungee/chat/TextComponentSerializer.java | 43 ------ .../chat/TranslatableComponentSerializer.java | 45 ------ chat/pom.xml | 2 +- config/pom.xml | 2 +- pom.xml | 4 +- proxy/pom.xml | 12 +- .../bungee/module/JenkinsModuleSource.java | 2 +- 9 files changed, 8 insertions(+), 307 deletions(-) delete mode 100644 api/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java delete mode 100644 api/src/main/java/net/md_5/bungee/chat/ComponentSerializer.java delete mode 100644 api/src/main/java/net/md_5/bungee/chat/TextComponentSerializer.java delete mode 100644 api/src/main/java/net/md_5/bungee/chat/TranslatableComponentSerializer.java diff --git a/api/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java b/api/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java deleted file mode 100644 index bf17391f6..000000000 --- a/api/src/main/java/net/md_5/bungee/chat/BaseComponentSerializer.java +++ /dev/null @@ -1,141 +0,0 @@ -package net.md_5.bungee.chat; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonObject; -import com.google.gson.JsonSerializationContext; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.HoverEvent; - -import java.util.Arrays; -import java.util.HashSet; - -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() ) ); - } - if ( object.has( "bold" ) ) - { - component.setBold( object.get( "bold" ).getAsBoolean() ); - } - if ( object.has( "italic" ) ) - { - component.setItalic( object.get( "italic" ).getAsBoolean() ); - } - if ( object.has( "underlined" ) ) - { - component.setUnderlined( object.get( "underlined" ).getAsBoolean() ); - } - if ( object.has( "strikethrough" ) ) - { - component.setUnderlined( object.get( "strikethrough" ).getAsBoolean() ); - } - if ( object.has( "obfuscated" ) ) - { - component.setUnderlined( object.get( "obfuscated" ).getAsBoolean() ); - } - if ( object.has( "extra" ) ) - { - component.setExtra( Arrays.asList( 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( "hoverEvent" ) ) - { - JsonObject event = object.getAsJsonObject( "hoverEvent" ); - BaseComponent[] res; - if ( event.get( "value" ).isJsonArray() ) - { - res = context.deserialize( event.get( "value" ), BaseComponent[].class ); - } else - { - res = new BaseComponent[] - { - context.deserialize( event.get( "value" ), BaseComponent.class ) - }; - } - component.setHoverEvent( new HoverEvent( HoverEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase() ), res ) ); - } - } - - protected void serialize(JsonObject object, BaseComponent component, JsonSerializationContext context) - { - boolean first = false; - if ( ComponentSerializer.serializedComponents.get() == null ) - { - first = true; - ComponentSerializer.serializedComponents.set( new HashSet() ); - } - try - { - Preconditions.checkArgument( !ComponentSerializer.serializedComponents.get().contains( component ), "Component loop" ); - ComponentSerializer.serializedComponents.get().add( component ); - if ( component.getColorRaw() != null ) - { - object.addProperty( "color", component.getColorRaw().getName() ); - } - if ( component.isBoldRaw() != null ) - { - object.addProperty( "bold", component.isBoldRaw() ); - } - if ( component.isItalicRaw() != null ) - { - object.addProperty( "italic", component.isItalicRaw() ); - } - if ( component.isUnderlinedRaw() != null ) - { - object.addProperty( "underlined", component.isUnderlinedRaw() ); - } - if ( component.isStrikethroughRaw() != null ) - { - object.addProperty( "strikethrough", component.isStrikethroughRaw() ); - } - if ( component.isObfuscatedRaw() != null ) - { - object.addProperty( "obfuscated", component.isObfuscatedRaw() ); - } - - if ( component.getExtra() != null ) - { - object.add( "extra", context.serialize( component.getExtra() ) ); - } - - //Events - if ( component.getClickEvent() != null ) - { - JsonObject clickEvent = new JsonObject(); - clickEvent.addProperty( "action", component.getClickEvent().getAction().toString().toLowerCase() ); - clickEvent.addProperty( "value", component.getClickEvent().getValue() ); - object.add( "clickEvent", clickEvent ); - } - if ( component.getHoverEvent() != null ) - { - JsonObject hoverEvent = new JsonObject(); - hoverEvent.addProperty( "action", component.getHoverEvent().getAction().toString().toLowerCase() ); - hoverEvent.add( "value", context.serialize( component.getHoverEvent().getValue() ) ); - object.add( "hoverEvent", hoverEvent ); - } - } finally - { - ComponentSerializer.serializedComponents.get().remove( component ); - if ( first ) - { - ComponentSerializer.serializedComponents.set( null ); - } - } - } -} diff --git a/api/src/main/java/net/md_5/bungee/chat/ComponentSerializer.java b/api/src/main/java/net/md_5/bungee/chat/ComponentSerializer.java deleted file mode 100644 index b001ef858..000000000 --- a/api/src/main/java/net/md_5/bungee/chat/ComponentSerializer.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.md_5.bungee.chat; - -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 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.HashSet; - -public class ComponentSerializer implements JsonDeserializer -{ - - private final static Gson gson = new GsonBuilder(). - registerTypeAdapter( BaseComponent.class, new ComponentSerializer() ). - registerTypeAdapter( TextComponent.class, new TextComponentSerializer() ). - registerTypeAdapter( TranslatableComponent.class, new TranslatableComponentSerializer() ). - create(); - - public final static ThreadLocal> serializedComponents = new ThreadLocal<>(); - - public static BaseComponent[] parse(String json) - { - if ( json.startsWith( "[" ) ) - { //Array - return 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... components) - { - return gson.toJson( new TextComponent( components ) ); - } - - @Override - 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 ); - } - return context.deserialize( json, TextComponent.class ); - } -} diff --git a/api/src/main/java/net/md_5/bungee/chat/TextComponentSerializer.java b/api/src/main/java/net/md_5/bungee/chat/TextComponentSerializer.java deleted file mode 100644 index 37c6e86da..000000000 --- a/api/src/main/java/net/md_5/bungee/chat/TextComponentSerializer.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.md_5.bungee.chat; - -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.BaseComponent; -import net.md_5.bungee.api.chat.TextComponent; - -import java.lang.reflect.Type; -import java.util.List; - -public class TextComponentSerializer extends BaseComponentSerializer implements JsonSerializer, JsonDeserializer -{ - - @Override - 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() ); - return component; - } - - @Override - public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context) - { - List extra = src.getExtra(); - if ( !src.hasFormatting() && ( extra == null || extra.isEmpty() ) ) - { - return new JsonPrimitive( src.getText() ); - } - JsonObject object = new JsonObject(); - serialize( object, src, context ); - object.addProperty( "text", src.getText() ); - return object; - } -} diff --git a/api/src/main/java/net/md_5/bungee/chat/TranslatableComponentSerializer.java b/api/src/main/java/net/md_5/bungee/chat/TranslatableComponentSerializer.java deleted file mode 100644 index c01af2686..000000000 --- a/api/src/main/java/net/md_5/bungee/chat/TranslatableComponentSerializer.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.md_5.bungee.chat; - -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.TranslatableComponent; - -import java.lang.reflect.Type; -import java.util.Arrays; - -public class TranslatableComponentSerializer extends BaseComponentSerializer implements JsonSerializer, JsonDeserializer -{ - - @Override - 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 ) ) ); - } - return component; - } - - @Override - 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() ) ); - } - return object; - } -} diff --git a/chat/pom.xml b/chat/pom.xml index 4d5c2f6d6..cbb4a4321 100644 --- a/chat/pom.xml +++ b/chat/pom.xml @@ -22,7 +22,7 @@ com.google.code.gson gson - 2.2.4 + 2.3 compile diff --git a/config/pom.xml b/config/pom.xml index 1496fa4c3..c28a59834 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -22,7 +22,7 @@ org.yaml snakeyaml - 1.13 + 1.14 compile diff --git a/pom.xml b/pom.xml index 4833a0925..a4d05fb2e 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ com.google.guava guava - 17.0 + 18.0 compile @@ -91,7 +91,7 @@ org.projectlombok lombok - 1.12.6 + 1.14.8 provided diff --git a/proxy/pom.xml b/proxy/pom.xml index 4ba9d7b65..b4de8ebe7 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -29,12 +29,6 @@ ${netty.version} compile - - io.netty - netty-transport-native-epoll - ${netty.version} - compile - io.netty netty-transport-native-epoll @@ -75,19 +69,19 @@ mysql mysql-connector-java - 5.1.30 + 5.1.32 runtime org.javassist javassist - 3.18.1-GA + 3.18.2-GA runtime org.fusesource.jansi jansi - 1.8 + 1.11 compile diff --git a/proxy/src/main/java/net/md_5/bungee/module/JenkinsModuleSource.java b/proxy/src/main/java/net/md_5/bungee/module/JenkinsModuleSource.java index 42453eaad..9bd2dc937 100644 --- a/proxy/src/main/java/net/md_5/bungee/module/JenkinsModuleSource.java +++ b/proxy/src/main/java/net/md_5/bungee/module/JenkinsModuleSource.java @@ -24,7 +24,7 @@ public class JenkinsModuleSource implements ModuleSource con.setConnectTimeout( 15000 ); con.setReadTimeout( 15000 ); - Files.copy( ByteStreams.newInputStreamSupplier( ByteStreams.toByteArray( con.getInputStream() ) ), module.getFile() ); + Files.write( ByteStreams.toByteArray( con.getInputStream() ), module.getFile() ); System.out.println( "Download complete" ); } catch ( IOException ex ) {