Skip to content

Commit

Permalink
Update to 1.19.3-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Dec 4, 2022
1 parent 387b730 commit 3df6be2
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 87 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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")

Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 5 additions & 7 deletions src/main/java/eu/pb4/styledchat/StyledChatMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -25,10 +23,10 @@ public class StyledChatMod implements ModInitializer {

public static boolean USE_FABRIC_API = true;

public static RegistryKey<MessageType> MESSAGE_TYPE_ID = RegistryKey.of(RegistryKeys.CHAT_TYPE, new Identifier("styled_chat", "generic_hack"));
public static RegistryKey<MessageType> 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
Expand Down
14 changes: 1 addition & 13 deletions src/main/java/eu/pb4/styledchat/StyledChatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
13 changes: 1 addition & 12 deletions src/main/java/eu/pb4/styledchat/config/data/ConfigData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<RegistryLoader.Entry<?>> entries,
CallbackInfoReturnable<DynamicRegistryManager.Immutable> cir, Map _unused, List<Pair<MutableRegistry<?>, 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<MessageType>) reg, StyledChatMod.MESSAGE_TYPE_ID, new MessageType(Decoration.ofChat("%s"), Decoration.ofChat("%s")));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
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;
import net.minecraft.server.MinecraftServer;
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;

Expand All @@ -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<CompletableFuture> cir) {
if (!signedMessage.getSignedContent().isDecorated()) {
this.styledChat_lastCached = null;
}
}*/

@Override
public ChatStyle styledChat$getStyle() {
if (this.styledChat$style == null) {
Expand All @@ -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;
}*/
}

0 comments on commit 3df6be2

Please sign in to comment.