diff --git a/build.gradle b/build.gradle index f4a1304..8c025ef 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } maven { url 'https://maven.nucleoid.xyz' } - maven { url 'https://maven.gegy.dev' } + //maven { url 'https://maven.gegy.dev' } maven { url "https://api.modrinth.com/maven" } //mavenLocal() } @@ -43,13 +43,13 @@ dependencies { modCompileOnly fabricApi.module("fabric-message-api-v1", project.fabric_version) - modImplementation include("eu.pb4:predicate-api:0.1.0+1.19.2") - modImplementation include("eu.pb4:placeholder-api:2.0.0-pre.1+1.19.2") + modImplementation include("eu.pb4:predicate-api:0.1.0+1.19.3") + modImplementation include("eu.pb4:placeholder-api:2.0.0-pre.2+1.19.3") modImplementation include("me.lucko:fabric-permissions-api:0.2-SNAPSHOT") - modImplementation include("eu.pb4:player-data-api:0.2.2+1.19.2") + modImplementation include("eu.pb4:player-data-api:0.2.2+1.19.3") - modCompileOnly("fr.catcore:server-translations-api:1.4.17+1.19.2") + modCompileOnly("fr.catcore:server-translations-api:1.4.18+1.19.2") modCompileOnly("maven.modrinth:vanish:1.1.0") //modLocalRuntime("fr.catcore:server-translations-api:1.4.17+1.19.2") @@ -129,7 +129,7 @@ curseforge { releaseType = "release" changelog = System.getenv("CHANGELOG") changelogType = "markdown" - addGameVersion ((String) project.minecraft_version) + addGameVersion ((String) project.minecraft_version.split("-")[0]) addGameVersion "Fabric" addGameVersion "Quilt" mainArtifact(remapJar) diff --git a/gradle.properties b/gradle.properties index 7e37e8b..76bd172 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=22w45a -yarn_mappings=22w45a+build.9 -loader_version=0.14.10 +minecraft_version=1.19.3-rc1 +yarn_mappings=1.19.3-rc1+build.1 +loader_version=0.14.11 #Fabric api -fabric_version=0.66.1+1.19.3 +fabric_version=0.68.1+1.19.3 # Mod Properties - mod_version = 2.1.0-development+1.19.3 + mod_version = 2.1.0+1.19.3 maven_group = eu.pb4 archives_base_name = styled-chat diff --git a/src/main/java/eu/pb4/styledchat/StyledChatMod.java b/src/main/java/eu/pb4/styledchat/StyledChatMod.java index fbb3d7a..64e3d1e 100644 --- a/src/main/java/eu/pb4/styledchat/StyledChatMod.java +++ b/src/main/java/eu/pb4/styledchat/StyledChatMod.java @@ -7,13 +7,11 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.network.message.MessageType; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.server.MinecraftServer; -import net.minecraft.text.Decoration; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registries; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.util.registry.RegistryKeys; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -25,10 +23,10 @@ public class StyledChatMod implements ModInitializer { public static boolean USE_FABRIC_API = true; - public static RegistryKey MESSAGE_TYPE_ID = RegistryKey.of(RegistryKeys.CHAT_TYPE, new Identifier("styled_chat", "generic_hack")); + public static RegistryKey MESSAGE_TYPE_ID = RegistryKey.of(RegistryKeys.MESSAGE_TYPE, new Identifier("styled_chat", "generic_hack")); public static MessageType getMessageType() { - return server.getRegistryManager().get(RegistryKeys.CHAT_TYPE).getOrThrow(MESSAGE_TYPE_ID); + return server.getRegistryManager().get(RegistryKeys.MESSAGE_TYPE).getOrThrow(MESSAGE_TYPE_ID); } @Override diff --git a/src/main/java/eu/pb4/styledchat/StyledChatUtils.java b/src/main/java/eu/pb4/styledchat/StyledChatUtils.java index 0d08148..0cb561f 100644 --- a/src/main/java/eu/pb4/styledchat/StyledChatUtils.java +++ b/src/main/java/eu/pb4/styledchat/StyledChatUtils.java @@ -7,9 +7,6 @@ import eu.pb4.placeholders.api.node.EmptyNode; import eu.pb4.placeholders.api.node.LiteralNode; import eu.pb4.placeholders.api.node.TextNode; -import eu.pb4.placeholders.api.node.parent.ClickActionNode; -import eu.pb4.placeholders.api.node.parent.ParentNode; -import eu.pb4.placeholders.api.node.parent.ParentTextNode; import eu.pb4.placeholders.api.parsers.LegacyFormattingParser; import eu.pb4.placeholders.api.parsers.MarkdownLiteParserV1; import eu.pb4.placeholders.api.parsers.NodeParser; @@ -30,20 +27,18 @@ import net.minecraft.command.EntitySelector; import net.minecraft.network.message.*; import net.minecraft.network.packet.s2c.play.ChatSuggestionsS2CPacket; +import net.minecraft.registry.RegistryKey; import net.minecraft.scoreboard.Team; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.ClickEvent; import net.minecraft.text.Text; import net.minecraft.text.TextContent; import net.minecraft.util.Formatting; -import net.minecraft.util.registry.RegistryKey; import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.function.BiFunction; -import java.util.regex.Matcher; import java.util.regex.Pattern; public final class StyledChatUtils { @@ -404,10 +399,6 @@ public static Text formatMessage(SignedMessage message, ServerCommandSource sour } public static Text maybeFormatFor(ServerCommandSource source, String original, Text originalContent) { - if (source.isExecutedByPlayer() && ConfigManager.getConfig().configData.chatPreview.requireForFormatting) { - return originalContent; - } - return formatFor(source, original); } @@ -425,9 +416,6 @@ public static SignedMessage toEventMessage(SignedMessage message, PlaceholderCon var baseInput = ext.styledChat_getArg("base_input"); var input = baseInput != null && baseInput.getContent() != TextContent.EMPTY ? baseInput : formatFor(context, ext.styledChat_getOriginal()); - //MessageMetadata messageMetadata = message.createMetadata(); - //MessageBody messageBody = new MessageBody(new DecoratedContents(ext.styledChat_getOriginal(), input), messageMetadata.timestamp(), messageMetadata.salt(), LastSeenMessageList.EMPTY); - //MessageHeader messageHeader = new MessageHeader(null, messageMetadata.sender()); return new SignedMessage(message.link(), null, MessageBody.ofUnsigned(message.getSignedContent()), input, null); } diff --git a/src/main/java/eu/pb4/styledchat/config/data/ConfigData.java b/src/main/java/eu/pb4/styledchat/config/data/ConfigData.java index f17df56..3ce07e9 100644 --- a/src/main/java/eu/pb4/styledchat/config/data/ConfigData.java +++ b/src/main/java/eu/pb4/styledchat/config/data/ConfigData.java @@ -21,24 +21,13 @@ public static class Formatting { @SerializedName("parse_links") public boolean parseLinksInChat = true; @SerializedName("parse_mentions") - public boolean parseMentionsInChat = true; + public boolean parseMentionsInChat = false; @SerializedName("markdown") public boolean markdown = true; @SerializedName("formatting_from_other_mods") public boolean allowModdedDecorators = false; } - - @SerializedName("chat_preview") - public ChatPreview chatPreview = new ChatPreview(); - - public static class ChatPreview { - @SerializedName("send_full_message") - public boolean sendFullMessage = false; - @SerializedName("require_for_formatting") - public boolean requireForFormatting = false; - } - @SerializedName("auto_completion") public AutoCompletion autoCompletion = new AutoCompletion(); diff --git a/src/main/java/eu/pb4/styledchat/config/data/old/ConfigDataV2.java b/src/main/java/eu/pb4/styledchat/config/data/old/ConfigDataV2.java index c1341e5..bf33302 100644 --- a/src/main/java/eu/pb4/styledchat/config/data/old/ConfigDataV2.java +++ b/src/main/java/eu/pb4/styledchat/config/data/old/ConfigDataV2.java @@ -51,9 +51,6 @@ public ConfigData update() { data.autoCompletion.tags = this.sendAutoCompletionForTags; data.autoCompletion.emoticons = this.sendAutoCompletionForEmotes; - data.chatPreview.sendFullMessage = this.sendFullMessageInChatPreview; - data.chatPreview.requireForFormatting = this.requireChatPreviewForFormatting; - data.formatting.markdown = this.enableMarkdown; data.formatting.legacyChatFormatting = this.legacyChatFormatting; data.formatting.allowModdedDecorators = this.allowModdedDecorators; diff --git a/src/main/java/eu/pb4/styledchat/mixin/RegistryLoaderMixin.java b/src/main/java/eu/pb4/styledchat/mixin/RegistryLoaderMixin.java index 20c327f..db2948c 100644 --- a/src/main/java/eu/pb4/styledchat/mixin/RegistryLoaderMixin.java +++ b/src/main/java/eu/pb4/styledchat/mixin/RegistryLoaderMixin.java @@ -3,10 +3,9 @@ import com.mojang.datafixers.util.Pair; import eu.pb4.styledchat.StyledChatMod; import net.minecraft.network.message.MessageType; +import net.minecraft.registry.*; import net.minecraft.resource.ResourceManager; import net.minecraft.text.Decoration; -import net.minecraft.util.dynamic.RegistryOps; -import net.minecraft.util.registry.*; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -18,13 +17,13 @@ @Mixin(RegistryLoader.class) public class RegistryLoaderMixin { - @Inject(method = "load(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/util/registry/DynamicRegistryManager$Immutable;", at = @At(value = "INVOKE", target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V", ordinal = 0, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILEXCEPTION) + @Inject(method = "load(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/DynamicRegistryManager;Ljava/util/List;)Lnet/minecraft/registry/DynamicRegistryManager$Immutable;", at = @At(value = "INVOKE", target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V", ordinal = 0, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILEXCEPTION) private static void styledChat$injectMessageTypes(ResourceManager resourceManager, DynamicRegistryManager baseRegistryManager, List> entries, CallbackInfoReturnable cir, Map _unused, List, Object>> list) { for (var pair : list) { var reg = pair.getFirst(); - if (reg.getKey().equals(RegistryKeys.CHAT_TYPE)) { + if (reg.getKey().equals(RegistryKeys.MESSAGE_TYPE)) { Registry.register((Registry) reg, StyledChatMod.MESSAGE_TYPE_ID, new MessageType(Decoration.ofChat("%s"), Decoration.ofChat("%s"))); } } diff --git a/src/main/java/eu/pb4/styledchat/mixin/ServerPlayNetworkManagerMixin.java b/src/main/java/eu/pb4/styledchat/mixin/ServerPlayNetworkManagerMixin.java index 85baf85..beba055 100644 --- a/src/main/java/eu/pb4/styledchat/mixin/ServerPlayNetworkManagerMixin.java +++ b/src/main/java/eu/pb4/styledchat/mixin/ServerPlayNetworkManagerMixin.java @@ -1,14 +1,10 @@ package eu.pb4.styledchat.mixin; -import eu.pb4.styledchat.StyledChatMod; import eu.pb4.styledchat.StyledChatStyles; import eu.pb4.styledchat.config.ChatStyle; -import eu.pb4.styledchat.config.data.ChatStyleData; import eu.pb4.styledchat.ducks.ExtPlayNetworkHandler; import eu.pb4.styledchat.StyledChatUtils; import eu.pb4.styledchat.config.ConfigManager; -import eu.pb4.styledchat.ducks.ExtSignedMessage; -import eu.pb4.styledchat.other.ServerTranslationUtils; import net.minecraft.network.message.MessageDecorator; import net.minecraft.network.message.MessageType; import net.minecraft.network.message.SignedMessage; @@ -16,26 +12,19 @@ import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.*; -import net.minecraft.util.registry.DynamicRegistryManager; -import net.minecraft.util.registry.Registry; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.concurrent.CompletableFuture; @Mixin(ServerPlayNetworkHandler.class) public abstract class ServerPlayNetworkManagerMixin implements ExtPlayNetworkHandler { @Shadow public ServerPlayerEntity player; - //@Unique - //Text styledChat_lastCached = null; + @Unique private ChatStyle styledChat$style; @@ -46,32 +35,14 @@ private Text styledChat_replaceDisconnectMessage(Text text) { @Redirect(method = "method_44900", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getMessageDecorator()Lnet/minecraft/network/message/MessageDecorator;")) private MessageDecorator styledChat_replaceDecorator2(MinecraftServer instance) { - var config = ConfigManager.getConfig().configData; - return config.chatPreview.sendFullMessage && !config.chatPreview.requireForFormatting ? StyledChatUtils.getChatDecorator() : StyledChatUtils.getRawDecorator(); + return StyledChatUtils.getRawDecorator(); } - /*@Inject(method = "sendChatPreviewPacket", at = @At("HEAD")) - private void styledChat_store(int queryId, Text preview, CallbackInfo ci) { - this.styledChat_lastCached = ServerTranslationUtils.translateIfBreaks(this.player, preview); - }*/ - @Inject(method = "handleDecoratedMessage", at = @At("HEAD")) private void styledChat_setFormattedMessage(SignedMessage signedMessage, CallbackInfo ci) { StyledChatUtils.modifyForSending(signedMessage, this.player.getCommandSource(), MessageType.CHAT); } - /*@Redirect(method = "method_45065", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getMessageDecorator()Lnet/minecraft/network/message/MessageDecorator;")) - private MessageDecorator styledChat_replaceDecorator(MinecraftServer instance) { - return (player, message) -> CompletableFuture.completedFuture(this.styledChat_lastCached != null ? this.styledChat_lastCached : message); - } - - @Inject(method = "method_45065", at = @At("HEAD")) - private void styledChat_removeCachedIfNotPreviewed(SignedMessage signedMessage, CallbackInfoReturnable cir) { - if (!signedMessage.getSignedContent().isDecorated()) { - this.styledChat_lastCached = null; - } - }*/ - @Override public ChatStyle styledChat$getStyle() { if (this.styledChat$style == null) { @@ -84,10 +55,4 @@ private void styledChat_removeCachedIfNotPreviewed(SignedMessage signedMessage, public void styledChat$setStyle(ChatStyle style) { this.styledChat$style = style; } - - - /*@Override - public @Nullable Text styledChat_getLastCached() { - return this.styledChat_lastCached; - }*/ }