Properly display blocks using the packet monitoring system.

This commit is contained in:
Kristian S. Stangeland 2014-02-15 12:47:30 +01:00
parent a8378d4e6f
commit 6443de6257
2 changed files with 19 additions and 3 deletions

View File

@ -349,7 +349,7 @@ class CommandPacket extends CommandBase {
@Override
public boolean print(StringBuilder output, Object value) {
if (value != null) {
EquivalentConverter<Object> converter = BukkitConverters.getConvertersForGeneric().get(value.getClass());
EquivalentConverter<Object> converter = findConverter(value.getClass());
if (converter != null) {
output.append(converter.getSpecific(value));
@ -369,6 +369,20 @@ class CommandPacket extends CommandBase {
}
}
private EquivalentConverter<Object> findConverter(Class<?> clazz) {
Map<Class<?>, EquivalentConverter<Object>> converters = BukkitConverters.getConvertersForGeneric();
while (clazz != null) {
EquivalentConverter<Object> result = converters.get(clazz);
if (result != null)
return result;
else
clazz = clazz.getSuperclass();
}
return null;
}
@Override
public ListeningWhitelist getSendingWhitelist() {
return serverList;

View File

@ -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());