mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-03-02 11:31:17 +01:00
Use the correct Gson class in 1.7.10
This commit is contained in:
parent
11ca1bf51e
commit
615a4e6e37
@ -219,6 +219,13 @@
|
||||
</developers>
|
||||
|
||||
<dependencies>
|
||||
<!-- Included with Minecraft
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.0.23.Final</version>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
|
@ -1652,22 +1652,18 @@ public class MinecraftReflection {
|
||||
return getMinecraftClass("TileEntity");
|
||||
}
|
||||
|
||||
private static Class<?> gsonClass = null;
|
||||
|
||||
/**
|
||||
* Retrieve the Gson class used by Minecraft.
|
||||
* @return The Gson class.
|
||||
*/
|
||||
public static Class<?> getMinecraftGsonClass() {
|
||||
if (gsonClass == null) {
|
||||
try {
|
||||
return gsonClass = getClass("org.bukkit.craftbukkit.libs.com.google.gson.Gson");
|
||||
} catch (RuntimeException e) {
|
||||
return gsonClass = getClass("com.google.gson.Gson");
|
||||
}
|
||||
try {
|
||||
return getMinecraftLibraryClass("com.google.gson.Gson");
|
||||
} catch (RuntimeException e) {
|
||||
Class<?> match = FuzzyReflection.fromClass(PacketType.Status.Server.OUT_SERVER_INFO.getPacketClass(), true)
|
||||
.getFieldByType("(.*)(google.gson.Gson)").getType();
|
||||
return setMinecraftLibraryClass("com.google.gson.Gson", match);
|
||||
}
|
||||
|
||||
return gsonClass;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1998,6 +1994,31 @@ public class MinecraftReflection {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the class object of a specific Minecraft library class.
|
||||
* @param className - the specific library Minecraft class.
|
||||
* @return Class object.
|
||||
* @throws RuntimeException If we are unable to find the given class.
|
||||
*/
|
||||
public static Class<?> getMinecraftLibraryClass(String className) {
|
||||
if (libraryPackage == null)
|
||||
libraryPackage = new CachedPackage("", getClassSource());
|
||||
return libraryPackage.getPackageClass(className);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the class object for the specific library class.
|
||||
* @param className - name of the Minecraft library class.
|
||||
* @param clazz - the new class object.
|
||||
* @return The provided clazz object.
|
||||
*/
|
||||
private static Class<?> setMinecraftLibraryClass(String className, Class<?> clazz) {
|
||||
if (libraryPackage == null)
|
||||
libraryPackage = new CachedPackage("", getClassSource());
|
||||
libraryPackage.setPackageClass(className, clazz);
|
||||
return clazz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically retrieve the NetworkManager name.
|
||||
* @return Name of the NetworkManager class.
|
||||
|
@ -16,14 +16,13 @@ public class NbtConfigurationSerializerTest {
|
||||
public static void initializeBukkit() {
|
||||
BukkitInitialization.initializePackage();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@Test
|
||||
public void testSerialization() {
|
||||
NbtCompound compound = NbtFactory.ofCompound("hello");
|
||||
compound.put("age", (short) 30);
|
||||
compound.put("name", "test");
|
||||
compound.put("values", new int[] { 1, 2, 3});
|
||||
compound.put("values", new int[] { 1, 2, 3 });
|
||||
compound.put(NbtFactory.ofList("telephone", "12345678", "81549300"));
|
||||
|
||||
compound.put(NbtFactory.ofList("lists", NbtFactory.ofList("", "a", "a", "b", "c")));
|
||||
|
@ -7,6 +7,10 @@
|
||||
<name>TinyProtocol</name>
|
||||
<description>Intercept packets without ProtocolLib.</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib-Parent</artifactId>
|
||||
@ -38,8 +42,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@ -77,12 +81,12 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.8.7-R0.1-SNAPSHOT</version>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.8.7-R0.1-SNAPSHOT</version>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
Loading…
Reference in New Issue
Block a user