Skip to content

Commit

Permalink
Backport to 1.19.2
Browse files Browse the repository at this point in the history
Signed-off-by: unilock <[email protected]>
  • Loading branch information
unilock committed Jun 4, 2024
1 parent ff10d8c commit 52d5ecc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.parallel=true

# Fabric Properties
# Check these on https://fabricmc.net/develop
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
loader_version=0.15.11

# Mod Properties
Expand All @@ -14,7 +14,7 @@ maven_group=cc.unilock.nilcord
archives_base_name=nilcord

# Dependencies
fabric_version=0.92.1+1.20.1
fabric_version=0.77.0+1.19.2
jda_version=5.0.0-beta.24
kaleido_version=0.3.1+1.3.1
papi_version=2.1.3+1.20.1
papi_version=2.0.0-pre.1+1.19.2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class PlayerAdvancementTrackerMixin {
@Shadow
private ServerPlayerEntity owner;

@Inject(method = "grantCriterion", at = @At(value = "INVOKE", target = "Lnet/minecraft/advancement/PlayerAdvancementTracker;onStatusUpdate(Lnet/minecraft/advancement/Advancement;)V"))
@Inject(method = "grantCriterion", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;broadcast(Lnet/minecraft/text/Text;Z)V"))
private void onStatusUpdate(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> cir) {
NilcordPremain.listener.playerAdvancement(this.owner, advancement);
}
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/cc/unilock/nilcord/util/TextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import eu.pb4.placeholders.api.PlaceholderContext;
import eu.pb4.placeholders.api.Placeholders;
import eu.pb4.placeholders.api.TextParserUtils;
import eu.pb4.placeholders.api.node.TextNode;
import eu.pb4.placeholders.api.parsers.MarkdownLiteParserV1;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
Expand All @@ -23,6 +24,10 @@ private static Text parse(String str) {
return TextParserUtils.formatText(str);
}

private static Text parseMarkdown(String str) {
return TextNode.asSingle(MarkdownLiteParserV1.ALL.parseNodes(TextNode.of(str))).toText(ParserContext.of(), true);
}

public static Text parseDiscordMessage(String template, String attachmentChunk, Text replyChunk, String usernameChunk, User author, Member member, Message message) {
template = template
.replace("<attachment_format>", attachmentChunk)
Expand All @@ -34,7 +39,7 @@ public static Text parseDiscordMessage(String template, String attachmentChunk,
"reply_format", replyChunk,
"username", Text.literal(author.getName()),
"nickname", Text.literal(member.getEffectiveName()),
"message", MarkdownLiteParserV1.ALL.parseText(message.getContentDisplay(), ParserContext.of())
"message", parseMarkdown(message.getContentDisplay())
);

return Placeholders.parseText(parse(template), ANGLE_BRACKETS, placeholders);
Expand All @@ -51,7 +56,7 @@ public static Text parseDiscordReply(String template, Message refMessage) {
Map<String, Text> placeholders = Map.of(
"reply_username", Text.literal(refAuthor.getName()),
"reply_nickname", Text.literal(refMember == null ? refAuthor.getEffectiveName() : refMember.getEffectiveName()),
"reply_message", MarkdownLiteParserV1.ALL.parseText(refMessage.getContentDisplay(), ParserContext.of())
"reply_message", parseMarkdown(refMessage.getContentDisplay())
);

return Placeholders.parseText(parse(template), ANGLE_BRACKETS, placeholders);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"depends": {
"fabricloader": "*",
"minecraft": ">=1.20",
"minecraft": ">=1.19",
"fabric-api": "*"
}
}

0 comments on commit 52d5ecc

Please sign in to comment.