[FEAT/BUG] Adventure parser backport and added Compat API for Advanced Chat
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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() {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
--- a/Fabric/build.gradle
|
||||
+++ b/Fabric/build.gradle
|
||||
@@ -11,7 +11,6 @@
|
||||
@@ -11,11 +11,9 @@
|
||||
|
||||
stupidRemapArch("dev.ftb.mods:ftb-essentials:${ftb_essentials}")
|
||||
stupidRemapArch("dev.ftb.mods:ftb-ranks:${ftb_ranks}")
|
||||
@@ -8,7 +8,11 @@
|
||||
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config}")
|
||||
modImplementation "maven.modrinth:fabrictailor:${fabrictailor}"
|
||||
modImplementation "maven.modrinth:vanish:${vanish}"
|
||||
@@ -117,8 +116,8 @@
|
||||
- modImplementation("unimaven.modrinth:advanced-chat:${advanced_chat}")
|
||||
|
||||
// Do not edit or remove
|
||||
implementation project(":Common")
|
||||
@@ -118,8 +116,8 @@
|
||||
setVersionType("release")
|
||||
setChangelog(rootProject.file("changelog.md"))
|
||||
setProjectVersion("${minecraft_version}-${project.version}")
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -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;
|
||||
|
@@ -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();
|
||||
- }
|
||||
-}
|
||||
|
@@ -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();
|
||||
- }
|
||||
-}
|
||||
|
@@ -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=5491953
|
||||
+creative_core=5491926
|
||||
+ftb_ranks=1902.1.16-build.114
|
||||
|
Reference in New Issue
Block a user