diff --git a/pom.xml b/pom.xml index bdc51ec..963a48f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ mkremins fanciful - 0.2.0-SNAPSHOT + 0.2.1-SNAPSHOT jar @@ -27,10 +27,9 @@ provided - org.bukkit - craftbukkit - 1.7.9-R0.1 - provided + com.google.code.gson + gson + 2.1 @@ -68,6 +67,35 @@ + + + + org.apache.maven.plugins + maven-shade-plugin + 2.2 + + false + + + com.google.code.gson:gson + + + + + com.google.gson + mkremins.fanciful.shaded.gson + + + + + + package + + shade + + + + diff --git a/src/main/java/mkremins/fanciful/FancyMessage.java b/src/main/java/mkremins/fanciful/FancyMessage.java index 779ac80..8d85585 100644 --- a/src/main/java/mkremins/fanciful/FancyMessage.java +++ b/src/main/java/mkremins/fanciful/FancyMessage.java @@ -14,6 +14,12 @@ import java.util.Map; import java.util.logging.Level; import static mkremins.fanciful.TextualComponent.rawText; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.stream.JsonWriter; import net.amoebaman.util.ArrayWrapper; import net.amoebaman.util.Reflection; import org.bukkit.Achievement; @@ -25,11 +31,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerialization; -import org.bukkit.craftbukkit.libs.com.google.gson.JsonArray; -import org.bukkit.craftbukkit.libs.com.google.gson.JsonElement; -import org.bukkit.craftbukkit.libs.com.google.gson.JsonObject; -import org.bukkit.craftbukkit.libs.com.google.gson.JsonParser; -import org.bukkit.craftbukkit.libs.com.google.gson.stream.JsonWriter; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -495,6 +496,7 @@ public FancyMessage then() { return this; } + @Override public void writeJson(JsonWriter writer) throws IOException{ if (messageParts.size() == 1) { latest().writeJson(writer); @@ -559,16 +561,16 @@ private void send(CommandSender sender, String jsonString){ } // The ChatSerializer's instance of Gson - private static net.minecraft.util.com.google.gson.Gson nmsChatSerializerGsonInstance; + private static com.google.gson.Gson nmsChatSerializerGsonInstance; private Object createChatPacket(String json) throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException{ if(nmsChatSerializerGsonInstance == null){ // Find the field and its value, completely bypassing obfuscation for(Field declaredField : Reflection.getNMSClass("ChatSerializer").getDeclaredFields()){ - if(Modifier.isFinal(declaredField.getModifiers()) && Modifier.isStatic(declaredField.getModifiers()) && declaredField.getType() == net.minecraft.util.com.google.gson.Gson.class){ + if(Modifier.isFinal(declaredField.getModifiers()) && Modifier.isStatic(declaredField.getModifiers()) && declaredField.getType() == com.google.gson.Gson.class){ // We've found our field declaredField.setAccessible(true); - nmsChatSerializerGsonInstance = (net.minecraft.util.com.google.gson.Gson)declaredField.get(null); + nmsChatSerializerGsonInstance = (com.google.gson.Gson)declaredField.get(null); break; } } diff --git a/src/main/java/mkremins/fanciful/JsonRepresentedObject.java b/src/main/java/mkremins/fanciful/JsonRepresentedObject.java index d7c0eb5..7264111 100644 --- a/src/main/java/mkremins/fanciful/JsonRepresentedObject.java +++ b/src/main/java/mkremins/fanciful/JsonRepresentedObject.java @@ -1,8 +1,8 @@ package mkremins.fanciful; -import java.io.IOException; +import com.google.gson.stream.JsonWriter; -import org.bukkit.craftbukkit.libs.com.google.gson.stream.JsonWriter; +import java.io.IOException; /** * Represents an object that can be serialized to a JSON writer instance. diff --git a/src/main/java/mkremins/fanciful/JsonString.java b/src/main/java/mkremins/fanciful/JsonString.java index 155106e..2354881 100644 --- a/src/main/java/mkremins/fanciful/JsonString.java +++ b/src/main/java/mkremins/fanciful/JsonString.java @@ -6,8 +6,8 @@ import javax.annotation.concurrent.Immutable; +import com.google.gson.stream.JsonWriter; import org.bukkit.configuration.serialization.ConfigurationSerializable; -import org.bukkit.craftbukkit.libs.com.google.gson.stream.JsonWriter; /** * Represents a JSON string value. @@ -22,7 +22,8 @@ final class JsonString implements JsonRepresentedObject, ConfigurationSerializab public JsonString(String value){ _value = value; } - + + @Override public void writeJson(JsonWriter writer) throws IOException { writer.value(getValue()); } diff --git a/src/main/java/mkremins/fanciful/MessagePart.java b/src/main/java/mkremins/fanciful/MessagePart.java index 2e7cdd8..e837364 100644 --- a/src/main/java/mkremins/fanciful/MessagePart.java +++ b/src/main/java/mkremins/fanciful/MessagePart.java @@ -4,10 +4,10 @@ import java.util.HashMap; import java.util.Map; +import com.google.gson.stream.JsonWriter; import org.bukkit.ChatColor; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerialization; -import org.bukkit.craftbukkit.libs.com.google.gson.stream.JsonWriter; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; diff --git a/src/main/java/mkremins/fanciful/TextualComponent.java b/src/main/java/mkremins/fanciful/TextualComponent.java index c56b7da..daf45bc 100644 --- a/src/main/java/mkremins/fanciful/TextualComponent.java +++ b/src/main/java/mkremins/fanciful/TextualComponent.java @@ -4,9 +4,9 @@ import java.util.HashMap; import java.util.Map; +import com.google.gson.stream.JsonWriter; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerialization; -import org.bukkit.craftbukkit.libs.com.google.gson.stream.JsonWriter; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap;