Use the correct Gson class in 1.7.10
Dieser Commit ist enthalten in:
Ursprung
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,24 +1652,20 @@ 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");
|
||||
return getMinecraftLibraryClass("com.google.gson.Gson");
|
||||
} catch (RuntimeException e) {
|
||||
return gsonClass = getClass("com.google.gson.Gson");
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the ItemStack[] class.
|
||||
* @return The ItemStack[] class.
|
||||
@ -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.
|
||||
|
@ -17,13 +17,12 @@ public class NbtConfigurationSerializerTest {
|
||||
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>
|
||||
|
4
pom.xml
4
pom.xml
@ -6,6 +6,10 @@
|
||||
<version>v3-SNAPSHOT</version>
|
||||
<name>ProtocolLib-Parent</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>ProtocolLib</module>
|
||||
<module>modules/v1_7_R4</module>
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren