From 7170bfcadc70995b290712c87d936acfa1c4a432 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Fri, 26 Jul 2013 18:42:06 +0200 Subject: [PATCH] Only add the WorldType converter if it exists in that Minecraft version --- .../protocol/wrappers/BukkitConverters.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java index a29a03eb..622092ff 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java @@ -432,14 +432,18 @@ public class BukkitConverters { public static Map, EquivalentConverter> getSpecificConverters() { if (specificConverters == null) { // Generics doesn't work, as usual - specificConverters = ImmutableMap., EquivalentConverter>builder(). + ImmutableMap.Builder, EquivalentConverter> builder = + ImmutableMap., EquivalentConverter>builder(). put(WrappedDataWatcher.class, (EquivalentConverter) getDataWatcherConverter()). put(ItemStack.class, (EquivalentConverter) getItemStackConverter()). put(NbtBase.class, (EquivalentConverter) getNbtConverter()). put(NbtCompound.class, (EquivalentConverter) getNbtConverter()). - put(WrappedWatchableObject.class, (EquivalentConverter) getWatchableObjectConverter()). - put(WorldType.class, (EquivalentConverter) getWorldTypeConverter()). - build(); + put(WrappedWatchableObject.class, (EquivalentConverter) getWatchableObjectConverter()); + + if (hasWorldType) { + builder.put(WorldType.class, (EquivalentConverter) getWorldTypeConverter()); + } + specificConverters = builder.build(); } return specificConverters; } @@ -452,14 +456,18 @@ public class BukkitConverters { public static Map, EquivalentConverter> getGenericConverters() { if (genericConverters == null) { // Generics doesn't work, as usual - genericConverters = ImmutableMap., EquivalentConverter>builder(). + ImmutableMap.Builder, EquivalentConverter> builder = + ImmutableMap., EquivalentConverter>builder(). put(MinecraftReflection.getDataWatcherClass(), (EquivalentConverter) getDataWatcherConverter()). put(MinecraftReflection.getItemStackClass(), (EquivalentConverter) getItemStackConverter()). put(MinecraftReflection.getNBTBaseClass(), (EquivalentConverter) getNbtConverter()). put(MinecraftReflection.getNBTCompoundClass(), (EquivalentConverter) getNbtConverter()). - put(MinecraftReflection.getWatchableObjectClass(), (EquivalentConverter) getWatchableObjectConverter()). - put(MinecraftReflection.getWorldTypeClass(), (EquivalentConverter) getWorldTypeConverter()). - build(); + put(MinecraftReflection.getWatchableObjectClass(), (EquivalentConverter) getWatchableObjectConverter()); + + if (hasWorldType) { + builder.put(MinecraftReflection.getWorldTypeClass(), (EquivalentConverter) getWorldTypeConverter()); + } + genericConverters = builder.build(); } return genericConverters; }