Archiviert
13
0

Write Spigot's chat components as null in compiled modifiers too

Fixes #95
Dieser Commit ist enthalten in:
Dan Mulloy 2015-07-07 13:55:31 -04:00
Ursprung c7dab69cba
Commit 5e703d91db
2 geänderte Dateien mit 13 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -422,15 +422,14 @@ public class StructureModifier<TField> {
* @throws FieldAccessException If we're unable to write to the fields due to a security limitation. * @throws FieldAccessException If we're unable to write to the fields due to a security limitation.
*/ */
public StructureModifier<TField> writeDefaults() throws FieldAccessException { public StructureModifier<TField> writeDefaults() throws FieldAccessException {
DefaultInstances generator = DefaultInstances.DEFAULT; DefaultInstances generator = DefaultInstances.DEFAULT;
// Write a default instance to every field // Write a default instance to every field
for (Field field : defaultFields.keySet()) { for (Field field : defaultFields.keySet()) {
try { try {
if (field.getType().getCanonicalName().equals("net.md_5.bungee.api.chat.BaseComponent[]")) {
// Special case for Spigot's custom chat components // Special case for Spigot's custom chat components
// They must be null or messages will be blank // They must be null or messages will be blank
if (field.getType().getCanonicalName().equals("net.md_5.bungee.api.chat.BaseComponent[]")) {
FieldUtils.writeField(field, target, null, true); FieldUtils.writeField(field, target, null, true);
continue; continue;
} }

Datei anzeigen

@ -65,7 +65,6 @@ public abstract class CompiledStructureModifier extends StructureModifier<Object
// Speed up the default writer // Speed up the default writer
@Override @Override
public StructureModifier<Object> writeDefaults() throws FieldAccessException { public StructureModifier<Object> writeDefaults() throws FieldAccessException {
DefaultInstances generator = DefaultInstances.DEFAULT; DefaultInstances generator = DefaultInstances.DEFAULT;
// Write a default instance to every field // Write a default instance to every field
@ -73,6 +72,13 @@ public abstract class CompiledStructureModifier extends StructureModifier<Object
Integer index = entry.getValue(); Integer index = entry.getValue();
Field field = entry.getKey(); 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())); write(index, (Object) generator.getDefault(field.getType()));
} }