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 0210729e..d50ebd68 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java @@ -422,15 +422,14 @@ 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()) { try { + // Special case for Spigot's custom chat components + // They must be null or messages will be blank 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; } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/CompiledStructureModifier.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/CompiledStructureModifier.java index 0698892c..dfd3710d 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/CompiledStructureModifier.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/CompiledStructureModifier.java @@ -65,17 +65,23 @@ public abstract class CompiledStructureModifier extends StructureModifier writeDefaults() throws FieldAccessException { - DefaultInstances generator = DefaultInstances.DEFAULT; - + // Write a default instance to every field - for (Map.Entry entry : defaultFields.entrySet()) { + for (Map.Entry entry : defaultFields.entrySet()) { Integer index = entry.getValue(); Field field = entry.getKey(); - + + // Special case for Spigot's custom chat components + // They must be null or messages will be blank + if (field.getType().getCanonicalName().equals("net.md_5.bungee.api.chat.BaseComponent[]")) { + write(index, null); + continue; + } + write(index, (Object) generator.getDefault(field.getType())); } - + return this; }