[FEAT/BUG] Adventure parser backport and added Compat API for Advanced Chat

This commit is contained in:
2025-04-28 15:10:18 +02:00
parent 799a0fecc7
commit 7abf86dced
182 changed files with 1716 additions and 905 deletions

View File

@@ -1,11 +1,11 @@
--- a/Common/src/main/java/com/hypherionmc/craterlib/nojang/commands/BridgedCommandSourceStack.java
+++ b/Common/src/main/java/com/hypherionmc/craterlib/nojang/commands/BridgedCommandSourceStack.java
@@ -14,7 +14,7 @@
private final CommandSourceStack internal;
public void sendSuccess(Supplier<Component> supplier, boolean bl) {
- internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl);
+ internal.sendSuccess(ChatUtils.adventureToMojang(supplier.get()), bl);
@@ -19,7 +19,7 @@
if (!internal.getServer().getGameRules().getBoolean(RULE_SENDCOMMANDFEEDBACK)) {
internal.sendSystemMessage(ChatUtils.adventureToMojang(supplier.get()));
} else {
- internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl);
+ internal.sendSuccess(ChatUtils.adventureToMojang(supplier.get()), bl);
}
}
public void sendFailure(Component text) {

View File

@@ -20,7 +20,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
@@ -25,31 +18,19 @@
@@ -25,35 +18,23 @@
@Getter
private static final GsonComponentSerializer adventureSerializer = GsonComponentSerializer.builder().options(
@@ -37,9 +37,13 @@
}
public static net.kyori.adventure.text.Component mojangToAdventure(Component inComponent) {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
try {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
+ final String serialised = Component.Serializer.toJson(inComponent);
return adventureSerializer.deserialize(serialised);
return adventureSerializer.deserialize(serialised);
} catch (Exception e) {
return net.kyori.adventure.text.Component.text(inComponent.getString());
}
- }
-
- private static HolderLookup.Provider getRegistryLookup() {