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> </developers>
<dependencies> <dependencies>
<!-- Included with Minecraft
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.23.Final</version>
</dependency>
-->
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>

Datei anzeigen

@ -1652,24 +1652,20 @@ public class MinecraftReflection {
return getMinecraftClass("TileEntity"); return getMinecraftClass("TileEntity");
} }
private static Class<?> gsonClass = null;
/** /**
* Retrieve the Gson class used by Minecraft. * Retrieve the Gson class used by Minecraft.
* @return The Gson class. * @return The Gson class.
*/ */
public static Class<?> getMinecraftGsonClass() { public static Class<?> getMinecraftGsonClass() {
if (gsonClass == null) {
try { try {
return gsonClass = getClass("org.bukkit.craftbukkit.libs.com.google.gson.Gson"); return getMinecraftLibraryClass("com.google.gson.Gson");
} catch (RuntimeException e) { } 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. * Retrieve the ItemStack[] class.
* @return 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. * Dynamically retrieve the NetworkManager name.
* @return Name of the NetworkManager class. * @return Name of the NetworkManager class.

Datei anzeigen

@ -17,13 +17,12 @@ public class NbtConfigurationSerializerTest {
BukkitInitialization.initializePackage(); BukkitInitialization.initializePackage();
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testSerialization() { public void testSerialization() {
NbtCompound compound = NbtFactory.ofCompound("hello"); NbtCompound compound = NbtFactory.ofCompound("hello");
compound.put("age", (short) 30); compound.put("age", (short) 30);
compound.put("name", "test"); 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("telephone", "12345678", "81549300"));
compound.put(NbtFactory.ofList("lists", NbtFactory.ofList("", "a", "a", "b", "c"))); compound.put(NbtFactory.ofList("lists", NbtFactory.ofList("", "a", "a", "b", "c")));

Datei anzeigen

@ -7,6 +7,10 @@
<name>TinyProtocol</name> <name>TinyProtocol</name>
<description>Intercept packets without ProtocolLib.</description> <description>Intercept packets without ProtocolLib.</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent> <parent>
<groupId>com.comphenix.protocol</groupId> <groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib-Parent</artifactId> <artifactId>ProtocolLib-Parent</artifactId>
@ -38,8 +42,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version> <version>3.0</version>
<configuration> <configuration>
<source>1.6</source> <source>1.7</source>
<target>1.6</target> <target>1.7</target>
</configuration> </configuration>
</plugin> </plugin>
@ -77,12 +81,12 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.8.7-R0.1-SNAPSHOT</version> <version>1.8.8-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.8.7-R0.1-SNAPSHOT</version> <version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

Datei anzeigen

@ -6,6 +6,10 @@
<version>v3-SNAPSHOT</version> <version>v3-SNAPSHOT</version>
<name>ProtocolLib-Parent</name> <name>ProtocolLib-Parent</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules> <modules>
<module>ProtocolLib</module> <module>ProtocolLib</module>
<module>modules/v1_7_R4</module> <module>modules/v1_7_R4</module>