From 99dea686a90699415d0c436a8fc1888ca5e750bf Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Fri, 22 May 2015 14:35:58 -0400 Subject: [PATCH] Update tests for 1.8.5 --- ProtocolLib/pom.xml | 4 +-- .../protocol/utility/CachedPackage.java | 2 +- .../comphenix/protocol/utility/Constants.java | 2 +- .../protocol/utility/MinecraftReflection.java | 4 +-- .../protocol/BukkitInitialization.java | 2 +- .../protocol/events/PacketContainerTest.java | 2 +- .../utility/MinecraftReflectionTest.java | 30 ++++++++++--------- .../utility/StreamSerializerTest.java | 2 +- .../wrappers/ChunkCoordIntPairTest.java | 8 ++--- .../protocol/wrappers/EnumWrappersTest.java | 12 ++++---- .../wrappers/ItemFactoryDelegate.java | 2 +- .../wrappers/WrappedAttributeTest.java | 6 ++-- 12 files changed, 39 insertions(+), 37 deletions(-) diff --git a/ProtocolLib/pom.xml b/ProtocolLib/pom.xml index 6ced2ca4..48d56214 100644 --- a/ProtocolLib/pom.xml +++ b/ProtocolLib/pom.xml @@ -314,13 +314,13 @@ org.spigotmc spigot-api - 1.8.3-R0.1-SNAPSHOT + 1.8.5-R0.1-SNAPSHOT provided org.spigotmc spigot - 1.8.3-R0.1-SNAPSHOT + 1.8.5-R0.1-SNAPSHOT provided diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/CachedPackage.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/CachedPackage.java index 8daf3bac..7d5cefbb 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/CachedPackage.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/CachedPackage.java @@ -75,7 +75,7 @@ class CachedPackage { return result; } catch (ClassNotFoundException e) { - throw new RuntimeException("Cannot find class " + className, e); + throw new RuntimeException("Cannot find class " + combine(packageName, className), e); } } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/Constants.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/Constants.java index 84acf252..4f79b973 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/Constants.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/Constants.java @@ -21,7 +21,7 @@ package com.comphenix.protocol.utility; */ public final class Constants { - public static final String PACKAGE_VERSION = "v1_8_R2"; + public static final String PACKAGE_VERSION = "v1_8_R3"; public static final String NMS = "net.minecraft.server." + PACKAGE_VERSION; public static final String OBC = "org.bukkit.craftbukkit." + PACKAGE_VERSION; } \ No newline at end of file diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java index 26880d6e..ab05faa8 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java @@ -1281,7 +1281,7 @@ public class MinecraftReflection { */ public static Class getWatchableObjectClass() { try { - return getMinecraftClass("WatchableObject"); + return getMinecraftClass("DataWatcher$WatchableObject", "WatchableObject"); } catch (RuntimeException e) { Method selected = FuzzyReflection.fromClass(getDataWatcherClass(), true). getMethod(FuzzyMethodContract.newBuilder(). @@ -2035,7 +2035,7 @@ public class MinecraftReflection { success = getMinecraftClass(alias); break; } catch (RuntimeException e1) { - // Just swallow it... + e1.printStackTrace(); // TODO DEBUG } } diff --git a/ProtocolLib/src/test/java/com/comphenix/protocol/BukkitInitialization.java b/ProtocolLib/src/test/java/com/comphenix/protocol/BukkitInitialization.java index 0464c7e5..6afc4699 100644 --- a/ProtocolLib/src/test/java/com/comphenix/protocol/BukkitInitialization.java +++ b/ProtocolLib/src/test/java/com/comphenix/protocol/BukkitInitialization.java @@ -2,7 +2,7 @@ package com.comphenix.protocol; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import net.minecraft.server.v1_8_R2.DispenserRegistry; +import net.minecraft.server.v1_8_R3.DispenserRegistry; import org.bukkit.Bukkit; import org.bukkit.Server; diff --git a/ProtocolLib/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java b/ProtocolLib/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java index f74132a6..454e6a60 100644 --- a/ProtocolLib/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java +++ b/ProtocolLib/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java @@ -27,7 +27,7 @@ import java.lang.reflect.Array; import java.util.List; import java.util.UUID; -import net.minecraft.server.v1_8_R2.MobEffect; +import net.minecraft.server.v1_8_R3.MobEffect; import org.apache.commons.lang.SerializationUtils; import org.bukkit.ChatColor; diff --git a/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java b/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java index 1b16dbae..c9210fb7 100644 --- a/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java +++ b/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java @@ -4,12 +4,15 @@ import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import net.minecraft.server.v1_8_R2.ChatComponentText; -import net.minecraft.server.v1_8_R2.ChunkCoordIntPair; -import net.minecraft.server.v1_8_R2.IChatBaseComponent; -import net.minecraft.server.v1_8_R2.ServerPing; -import net.minecraft.server.v1_8_R2.ServerPing.ServerData; -import net.minecraft.server.v1_8_R2.ServerPing.ServerPingPlayerSample; +import net.minecraft.server.v1_8_R3.ChatComponentText; +import net.minecraft.server.v1_8_R3.ChunkCoordIntPair; +import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; +import net.minecraft.server.v1_8_R3.IChatBaseComponent; +import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer; +import net.minecraft.server.v1_8_R3.NBTCompressedStreamTools; +import net.minecraft.server.v1_8_R3.ServerPing; +import net.minecraft.server.v1_8_R3.ServerPing.ServerData; +import net.minecraft.server.v1_8_R3.ServerPing.ServerPingPlayerSample; import org.bukkit.block.Block; import org.bukkit.entity.Entity; @@ -18,7 +21,6 @@ import org.junit.BeforeClass; import org.junit.Test; import com.comphenix.protocol.BukkitInitialization; -import com.google.common.collect.Maps; public class MinecraftReflectionTest { // Mocking objects @@ -37,7 +39,7 @@ public class MinecraftReflectionTest { // Set up a package with no class loader knowledge MinecraftReflection.minecraftPackage = new CachedPackage( MinecraftReflection.getMinecraftPackage(), - ClassSource.fromMap(Maps.>newHashMap()) + ClassSource.fromClassLoader() ); } @@ -64,10 +66,10 @@ public class MinecraftReflectionTest { MinecraftReflection.getBukkitEntity("Hello"); } - /* @Test + @Test public void testNbtStreamTools() { assertEquals(NBTCompressedStreamTools.class, MinecraftReflection.getNbtCompressedStreamToolsClass()); - } */ + } @Test public void testChatComponent() { @@ -79,10 +81,10 @@ public class MinecraftReflectionTest { assertEquals(ChatComponentText.class, MinecraftReflection.getChatComponentTextClass()); } - /* @Test + @Test public void testChatSerializer() { assertEquals(ChatSerializer.class, MinecraftReflection.getChatSerializerClass()); - } */ + } @Test public void testServerPing() { @@ -104,8 +106,8 @@ public class MinecraftReflectionTest { assertEquals(ChunkCoordIntPair.class, MinecraftReflection.getChunkCoordIntPair()); } - /* @Test + @Test public void testWatchableObject() { assertEquals(WatchableObject.class, MinecraftReflection.getWatchableObjectClass()); - } */ + } } diff --git a/ProtocolLib/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java b/ProtocolLib/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java index 4696a900..c2cb7c5e 100644 --- a/ProtocolLib/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java +++ b/ProtocolLib/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java @@ -8,7 +8,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import net.minecraft.server.v1_8_R2.IntHashMap; +import net.minecraft.server.v1_8_R3.IntHashMap; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; diff --git a/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java index 7e7d175b..5776924b 100644 --- a/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java +++ b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java @@ -15,15 +15,15 @@ public class ChunkCoordIntPairTest { @Test public void test() { - net.minecraft.server.v1_8_R2.ChunkCoordIntPair pair = new net.minecraft.server.v1_8_R2.ChunkCoordIntPair(1, 2); + net.minecraft.server.v1_8_R3.ChunkCoordIntPair pair = new net.minecraft.server.v1_8_R3.ChunkCoordIntPair(1, 2); ChunkCoordIntPair specific = ChunkCoordIntPair.getConverter().getSpecific(pair); assertEquals(1, specific.getChunkX()); assertEquals(2, specific.getChunkZ()); - net.minecraft.server.v1_8_R2.ChunkCoordIntPair roundtrip = - (net.minecraft.server.v1_8_R2.ChunkCoordIntPair) ChunkCoordIntPair.getConverter(). - getGeneric(net.minecraft.server.v1_8_R2.ChunkCoordIntPair.class, specific); + net.minecraft.server.v1_8_R3.ChunkCoordIntPair roundtrip = + (net.minecraft.server.v1_8_R3.ChunkCoordIntPair) ChunkCoordIntPair.getConverter(). + getGeneric(net.minecraft.server.v1_8_R3.ChunkCoordIntPair.class, specific); assertEquals(1, roundtrip.x); assertEquals(2, roundtrip.z); diff --git a/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/EnumWrappersTest.java b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/EnumWrappersTest.java index 55e07a8f..a272bbd5 100644 --- a/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/EnumWrappersTest.java +++ b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/EnumWrappersTest.java @@ -1,12 +1,12 @@ package com.comphenix.protocol.wrappers; import static org.junit.Assert.assertEquals; -import net.minecraft.server.v1_8_R2.EntityHuman.EnumChatVisibility; -import net.minecraft.server.v1_8_R2.EnumDifficulty; -import net.minecraft.server.v1_8_R2.EnumProtocol; -import net.minecraft.server.v1_8_R2.PacketPlayInClientCommand.EnumClientCommand; -import net.minecraft.server.v1_8_R2.PacketPlayInUseEntity.EnumEntityUseAction; -import net.minecraft.server.v1_8_R2.WorldSettings.EnumGamemode; +import net.minecraft.server.v1_8_R3.EntityHuman.EnumChatVisibility; +import net.minecraft.server.v1_8_R3.EnumDifficulty; +import net.minecraft.server.v1_8_R3.EnumProtocol; +import net.minecraft.server.v1_8_R3.PacketPlayInClientCommand.EnumClientCommand; +import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction; +import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode; import org.junit.BeforeClass; import org.junit.Test; diff --git a/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ItemFactoryDelegate.java b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ItemFactoryDelegate.java index c72db506..1636e1dd 100644 --- a/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ItemFactoryDelegate.java +++ b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ItemFactoryDelegate.java @@ -18,7 +18,7 @@ package com.comphenix.protocol.wrappers; import org.bukkit.Color; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemFactory; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemFactory; import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; diff --git a/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java index 8fc67a4f..181bbbf2 100644 --- a/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java +++ b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java @@ -7,9 +7,9 @@ import static org.junit.Assert.assertTrue; import java.util.Collection; import java.util.List; -import net.minecraft.server.v1_8_R2.AttributeModifier; -import net.minecraft.server.v1_8_R2.PacketPlayOutUpdateAttributes; -import net.minecraft.server.v1_8_R2.PacketPlayOutUpdateAttributes.AttributeSnapshot; +import net.minecraft.server.v1_8_R3.AttributeModifier; +import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes; +import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes.AttributeSnapshot; import org.junit.Before; import org.junit.BeforeClass;