mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix NPE and API contract breakage for Component deserialization
This commit is contained in:
parent
8e774ea314
commit
c6c2ff99c3
1 changed files with 7 additions and 3 deletions
|
@ -31,7 +31,6 @@ import com.google.gson.JsonElement;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
|
@ -62,9 +61,14 @@ public record GsonComponentSerializerWrapper(GsonComponentSerializer source) imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Component deserialize(@NotNull String input) {
|
public @NotNull Component deserialize(@NotNull String input) {
|
||||||
// See https://github.com/KyoriPowered/adventure/issues/447
|
// See https://github.com/KyoriPowered/adventure/issues/447
|
||||||
return this.serializer().fromJson(input, Component.class);
|
Component component = this.serializer().fromJson(input, Component.class);
|
||||||
|
if (component == null) {
|
||||||
|
return Component.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue