diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FuzzyReflection.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FuzzyReflection.java index 639feb25..e0f4463e 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FuzzyReflection.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FuzzyReflection.java @@ -604,7 +604,6 @@ public class FuzzyReflection { // Prevent duplicate fields // @SafeVarargs - @SuppressWarnings("unchecked") private static Set setUnion(T[]... array) { Set result = new LinkedHashSet(); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/Util.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/Util.java index 9cf19c10..6b353011 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/Util.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/Util.java @@ -67,7 +67,6 @@ public class Util { * @return The list */ // @SafeVarargs - @SuppressWarnings("unchecked") public static List asList(E... elements) { List list = new ArrayList(elements.length); for (E element : elements) { diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedGameProfile.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedGameProfile.java index f5090faf..2f2960fb 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedGameProfile.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedGameProfile.java @@ -250,6 +250,7 @@ public class WrappedGameProfile extends AbstractWrapper { * * @return Property map. */ + // In the protocol hack and 1.8 it is a ForwardingMultimap @SuppressWarnings({ "unchecked", "rawtypes" }) public Multimap getProperties() { Multimap result = propertyMap; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtFactory.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtFactory.java index 7ad74037..6ae83f82 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtFactory.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtFactory.java @@ -450,7 +450,6 @@ public class NbtFactory { * @return The new filled NBT list. */ // @SafeVarargs - @SuppressWarnings("unchecked") public static NbtList ofList(String name, T... elements) { return WrappedList.fromArray(name, elements); } diff --git a/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedGameProfileTest.java b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedGameProfileTest.java index 317b5815..76ec9ea0 100644 --- a/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedGameProfileTest.java +++ b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedGameProfileTest.java @@ -9,6 +9,10 @@ import org.junit.Test; import com.comphenix.protocol.BukkitInitialization; import com.google.common.base.Charsets; +import com.google.common.collect.Multimap; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; public class WrappedGameProfileTest { @@ -16,9 +20,18 @@ public class WrappedGameProfileTest { public static void initializeBukkit() { BukkitInitialization.initializePackage(); } - - @SuppressWarnings("deprecation") + @Test + public void testWrapper() { + GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes("ProtocolLib".getBytes(Charsets.UTF_8)), "ProtocolLib"); + WrappedGameProfile wrapper = WrappedGameProfile.fromHandle(profile); + + assertEquals(profile.getId(), wrapper.getUUID()); + assertEquals(profile.getName(), wrapper.getName()); + } + + @Test + @SuppressWarnings("deprecation") public void testSkinUpdate() { final UUID uuid = UUID.nameUUIDFromBytes("123".getBytes(Charsets.UTF_8)); @@ -31,4 +44,41 @@ public class WrappedGameProfileTest { public void testNullFailure() { new WrappedGameProfile((String)null, null); } -} + + @Test + public void testGetProperties() { + GameProfile profile = new GameProfile(UUID.nameUUIDFromBytes("ProtocolLib".getBytes(Charsets.UTF_8)), "ProtocolLib"); + + String name = "test"; + String value = "test"; + String signature = null; + + profile.getProperties().put(name, new Property(name, value, signature)); + + WrappedGameProfile wrapper = WrappedGameProfile.fromHandle(profile); + Multimap properties = wrapper.getProperties(); + WrappedSignedProperty property = properties.get(name).iterator().next(); + + assertEquals(property.getName(), name); + assertEquals(property.getValue(), value); + assertEquals(property.getSignature(), signature); + } + + @Test + public void testAddProperties() { + String name = "test"; + String value = "test"; + String signature = null; + + WrappedGameProfile wrapper = new WrappedGameProfile(UUID.nameUUIDFromBytes("ProtocolLib".getBytes(Charsets.UTF_8)), "ProtocolLib"); + wrapper.getProperties().put(name, new WrappedSignedProperty(name, value, signature)); + + GameProfile profile = (GameProfile) wrapper.getHandle(); + PropertyMap properties = profile.getProperties(); + Property property = properties.get(name).iterator().next(); + + assertEquals(property.getName(), name); + assertEquals(property.getValue(), value); + assertEquals(property.getSignature(), signature); + } +} \ No newline at end of file