From c7dab69cba2c7a0b42c34ece3247f083a2771bc5 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Mon, 6 Jul 2015 21:08:14 -0400 Subject: [PATCH] Specifically write Spigot's chat components as null --- .../protocol/reflect/StructureModifier.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java index c5180a48..0210729e 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java @@ -422,25 +422,25 @@ public class StructureModifier { * @throws FieldAccessException If we're unable to write to the fields due to a security limitation. */ public StructureModifier writeDefaults() throws FieldAccessException { - + DefaultInstances generator = DefaultInstances.DEFAULT; - + // Write a default instance to every field for (Field field : defaultFields.keySet()) { - if (field.getType().getCanonicalName().equals("net.md_5.bungee.api.chat.BaseComponent[]")) { - // Special case for Spigot's custom chat components - // Generating this will cause messages to be blank - continue; - } - try { - FieldUtils.writeField(field, target, - generator.getDefault(field.getType()), true); + if (field.getType().getCanonicalName().equals("net.md_5.bungee.api.chat.BaseComponent[]")) { + // Special case for Spigot's custom chat components + // They must be null or messages will be blank + FieldUtils.writeField(field, target, null, true); + continue; + } + + FieldUtils.writeField(field, target, generator.getDefault(field.getType()), true); } catch (IllegalAccessException e) { throw new FieldAccessException("Cannot write to field due to a security limitation.", e); } } - + return this; }