Archiviert
13
0

Use the correct Gson class in 1.7.10

Dieser Commit ist enthalten in:
Dan Mulloy 2016-02-27 22:48:11 -05:00
Ursprung 11ca1bf51e
Commit 615a4e6e37
5 geänderte Dateien mit 52 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -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>

Datei anzeigen

@ -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.

Datei anzeigen

@ -17,7 +17,6 @@ public class NbtConfigurationSerializerTest {
BukkitInitialization.initializePackage();
}
@SuppressWarnings("unchecked")
@Test
public void testSerialization() {
NbtCompound compound = NbtFactory.ofCompound("hello");

Datei anzeigen

@ -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>

Datei anzeigen

@ -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>