Skip to content
Permalink
Browse files

Only add the WorldType converter if it exists in that Minecraft version

  • Loading branch information
aadnk committed Jul 26, 2013
1 parent 5c2fc86 commit 7170bfcadc70995b290712c87d936acfa1c4a432
Showing with 16 additions and 8 deletions.
  1. +16 −8 ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java
@@ -432,14 +432,18 @@ public TType getSpecificValue(Object generic) {
public static Map<Class<?>, EquivalentConverter<Object>> getSpecificConverters() {
if (specificConverters == null) {
// Generics doesn't work, as usual
specificConverters = ImmutableMap.<Class<?>, EquivalentConverter<Object>>builder().
ImmutableMap.Builder<Class<?>, EquivalentConverter<Object>> builder =
ImmutableMap.<Class<?>, EquivalentConverter<Object>>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 TType getSpecificValue(Object generic) {
public static Map<Class<?>, EquivalentConverter<Object>> getGenericConverters() {
if (genericConverters == null) {
// Generics doesn't work, as usual
genericConverters = ImmutableMap.<Class<?>, EquivalentConverter<Object>>builder().
ImmutableMap.Builder<Class<?>, EquivalentConverter<Object>> builder =
ImmutableMap.<Class<?>, EquivalentConverter<Object>>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;
}

0 comments on commit 7170bfc

Please sign in to comment.
You can’t perform that action at this time.