mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-02-09 00:51:59 +01:00
Write Spigot's chat components as null in compiled modifiers too
Fixes #95
This commit is contained in:
parent
c7dab69cba
commit
5e703d91db
@ -422,15 +422,14 @@ public class StructureModifier<TField> {
|
||||
* @throws FieldAccessException If we're unable to write to the fields due to a security limitation.
|
||||
*/
|
||||
public StructureModifier<TField> 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;
|
||||
}
|
||||
|
@ -65,17 +65,23 @@ public abstract class CompiledStructureModifier extends StructureModifier<Object
|
||||
// Speed up the default writer
|
||||
@Override
|
||||
public StructureModifier<Object> writeDefaults() throws FieldAccessException {
|
||||
|
||||
DefaultInstances generator = DefaultInstances.DEFAULT;
|
||||
|
||||
|
||||
// Write a default instance to every field
|
||||
for (Map.Entry<Field, Integer> entry : defaultFields.entrySet()) {
|
||||
for (Map.Entry<Field, Integer> 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user