From 6443de6257644b060579055b0c3dc5450d3e6a3f Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Sat, 15 Feb 2014 12:47:30 +0100 Subject: [PATCH] Properly display blocks using the packet monitoring system. --- .../com/comphenix/protocol/CommandPacket.java | 16 +++++++++++++++- .../protocol/wrappers/BukkitConverters.java | 6 ++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandPacket.java b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandPacket.java index 1669bdd2..96ab0a05 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandPacket.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandPacket.java @@ -349,7 +349,7 @@ class CommandPacket extends CommandBase { @Override public boolean print(StringBuilder output, Object value) { if (value != null) { - EquivalentConverter converter = BukkitConverters.getConvertersForGeneric().get(value.getClass()); + EquivalentConverter converter = findConverter(value.getClass()); if (converter != null) { output.append(converter.getSpecific(value)); @@ -369,6 +369,20 @@ class CommandPacket extends CommandBase { } } + private EquivalentConverter findConverter(Class clazz) { + Map, EquivalentConverter> converters = BukkitConverters.getConvertersForGeneric(); + + while (clazz != null) { + EquivalentConverter result = converters.get(clazz); + + if (result != null) + return result; + else + clazz = clazz.getSuperclass(); + } + return null; + } + @Override public ListeningWhitelist getSendingWhitelist() { return serverList; 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 3ffdd03c..626b0422 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java @@ -827,7 +827,8 @@ public class BukkitConverters { put(NbtBase.class, (EquivalentConverter) getNbtConverter()). put(NbtCompound.class, (EquivalentConverter) getNbtConverter()). put(WrappedWatchableObject.class, (EquivalentConverter) getWatchableObjectConverter()). - put(PotionEffect.class, (EquivalentConverter) getPotionEffectConverter()); + put(PotionEffect.class, (EquivalentConverter) getPotionEffectConverter()). + put(Material.class, (EquivalentConverter) getBlockConverter()); // Types added in 1.7.2 if (MinecraftReflection.isUsingNetty()) { @@ -865,7 +866,8 @@ public class BukkitConverters { put(MinecraftReflection.getNBTBaseClass(), (EquivalentConverter) getNbtConverter()). put(MinecraftReflection.getNBTCompoundClass(), (EquivalentConverter) getNbtConverter()). put(MinecraftReflection.getWatchableObjectClass(), (EquivalentConverter) getWatchableObjectConverter()). - put(MinecraftReflection.getMobEffectClass(), (EquivalentConverter) getPotionEffectConverter()); + put(MinecraftReflection.getMobEffectClass(), (EquivalentConverter) getPotionEffectConverter()). + put(MinecraftReflection.getBlockClass(), (EquivalentConverter) getBlockConverter()); if (hasWorldType) builder.put(MinecraftReflection.getWorldTypeClass(), (EquivalentConverter) getWorldTypeConverter());