[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

@@ -7,16 +7,29 @@
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import com.hypherionmc.craterlib.utils.ChatUtils;
import lombok.RequiredArgsConstructor;
@@ -14,7 +15,7 @@
private final CommandSourceStack internal;
@@ -17,14 +18,18 @@
public void sendSuccess(Supplier<Component> supplier, boolean bl) {
- internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl);
+ internal.sendSuccess(ChatUtils.adventureToMojang(supplier.get()), bl);
if (!internal.getServer().getGameRules().getBoolean(RULE_SENDCOMMANDFEEDBACK)) {
- internal.sendSystemMessage(ChatUtils.adventureToMojang(supplier.get()));
+ try {
+ internal.getPlayerOrException().displayClientMessage(ChatUtils.adventureToMojang(supplier.get()), false);
+ } catch (Exception ignored) {}
} else {
- internal.sendSuccess(() -> ChatUtils.adventureToMojang(supplier.get()), bl);
+ internal.sendSuccess(ChatUtils.adventureToMojang(supplier.get()), bl);
}
}
public void sendMessage(Component text) {
- internal.sendSystemMessage(ChatUtils.adventureToMojang(text));
+ try {
+ internal.getPlayerOrException().displayClientMessage(ChatUtils.adventureToMojang(text), false);
+ } catch (Exception ignored) {}
}
public void sendFailure(Component text) {
@@ -22,11 +23,22 @@
@@ -32,11 +37,22 @@
}
public boolean isPlayer() {

View File

@@ -8,7 +8,7 @@
import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
import lombok.Getter;
import me.hypherionmc.mcdiscordformatter.discord.DiscordSerializer;
@@ -13,51 +11,36 @@
@@ -13,55 +11,40 @@
import net.minecraft.ChatFormatting;
import net.minecraft.SharedConstants;
import net.minecraft.Util;
@@ -39,9 +39,13 @@
}
public static net.kyori.adventure.text.Component mojangToAdventure(Component inComponent) {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
+ final String serialised = Component.Serializer.toJson(inComponent);
return adventureSerializer.deserialize(serialised);
try {
- final String serialised = Component.Serializer.toJson(inComponent, getRegistryLookup());
+ final String serialised = Component.Serializer.toJson(inComponent);
return adventureSerializer.deserialize(serialised);
} catch (Exception e) {
return net.kyori.adventure.text.Component.text(inComponent.getString());
}
}
- private static HolderLookup.Provider getRegistryLookup() {
@@ -66,7 +70,7 @@
}
public static String strip(String inString, String... toStrip) {
@@ -86,7 +69,7 @@
@@ -90,7 +73,7 @@
}
public static net.kyori.adventure.text.Component resolve(String component, boolean formatted) {
@@ -75,7 +79,7 @@
if (formatted) {
returnVal = MinecraftSerializer.INSTANCE.serialize(component);
}
@@ -114,7 +97,7 @@
@@ -118,7 +101,7 @@
if (identifier == null)
return net.kyori.adventure.text.Component.text("Unknown");

View File

@@ -1,6 +1,6 @@
--- a/Fabric/build.gradle
+++ b/Fabric/build.gradle
@@ -9,9 +9,6 @@
@@ -9,13 +9,9 @@
exclude(group: "net.fabricmc.fabric-api")
}
@@ -10,7 +10,11 @@
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config}")
modImplementation "maven.modrinth:fabrictailor:${fabrictailor}"
modImplementation "maven.modrinth:vanish:${vanish}"
@@ -117,8 +114,8 @@
- modImplementation("unimaven.modrinth:advanced-chat:${advanced_chat}")
// Do not edit or remove
implementation project(":Common")
@@ -118,8 +114,8 @@
setVersionType("release")
setChangelog(rootProject.file("changelog.md"))
setProjectVersion("${minecraft_version}-${project.version}")

View File

@@ -0,0 +1,25 @@
--- a/Fabric/src/main/java/com/hypherionmc/craterlib/common/FabricCompatHelper.java
+++ b/Fabric/src/main/java/com/hypherionmc/craterlib/common/FabricCompatHelper.java
@@ -5,7 +5,6 @@
import com.hypherionmc.craterlib.core.platform.CompatUtils;
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
-import me.wesley1808.advancedchat.api.AdvancedChatAPI;
import net.kyori.adventure.text.Component;
public class FabricCompatHelper implements CompatUtils {
@@ -40,12 +39,11 @@
@Override
public boolean isPrivateMessage(BridgedPlayer player) {
- return !AdvancedChatAPI.isPublicChat(player.toMojangServerPlayer());
+ return false;
}
@Override
public Component getChannelPrefix(BridgedPlayer player) {
- net.minecraft.network.chat.Component c = AdvancedChatAPI.getChannelPrefix(player.toMojangServerPlayer());
- return c.getString().isBlank() ? Component.empty() : Component.text(c.getString());
+ return Component.empty();
}
}

View File

@@ -1,11 +1,12 @@
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
+++ b/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeCompatHelper.java
@@ -1,15 +1,20 @@
@@ -1,15 +1,21 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.core.platform.CompatUtils;
+import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
+import net.kyori.adventure.text.Component;
import team.creative.playerrevive.api.IBleeding;
import team.creative.playerrevive.server.PlayerReviveServer;
+import redstonedubstep.mods.vanishmod.VanishUtil;

View File

@@ -1,6 +1,6 @@
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeCompatHelper.java
+++ /dev/null
@@ -1,50 +1,0 @@
@@ -1,60 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -50,4 +50,14 @@
- IBleeding bleeding = PlayerReviveServer.getBleeding(player.toMojangServerPlayer());
- return bleeding != null && bleeding.revived();
- }
-
- @Override
- public boolean isPrivateMessage(BridgedPlayer player) {
- return false;
- }
-
- @Override
- public Component getChannelPrefix(BridgedPlayer player) {
- return Component.empty();
- }
-}

View File

@@ -1,6 +1,6 @@
--- a/Paper/src/main/java/com/hypherionmc/craterlib/common/PaperCompatHelper.java
+++ /dev/null
@@ -1,92 +1,0 @@
@@ -1,102 +1,0 @@
-package com.hypherionmc.craterlib.common;
-
-import com.hypherionmc.craterlib.core.platform.CompatUtils;
@@ -92,4 +92,14 @@
- public boolean playerRevived(BridgedPlayer player) {
- return false;
- }
-
- @Override
- public boolean isPrivateMessage(BridgedPlayer player) {
- return false;
- }
-
- @Override
- public Component getChannelPrefix(BridgedPlayer player) {
- return Component.empty();
- }
-}

View File

@@ -23,7 +23,7 @@
# Dependencies
moon_config=1.0.12
@@ -29,23 +26,22 @@
@@ -29,24 +26,23 @@
adventure=4.17.0
rpc_sdk=1.0
discord_formatter=2.0.0
@@ -40,6 +40,7 @@
-ftb_ranks=2101.1.1
-player_revive=6119534
-creative_core=6113754
advanced_chat=SNA4dye5
+player_revive=5335413
+creative_core=5335387
+ftb_ranks=1802.1.11-build.71