From a7c8ac0ef21d94c8382bcc90e5183ee0669f6939 Mon Sep 17 00:00:00 2001 From: Patbox <39821509+Patbox@users.noreply.github.com> Date: Sat, 3 Jun 2023 17:23:40 +0200 Subject: [PATCH] Update to 1.20 --- build.gradle | 6 ++-- gradle.properties | 10 +++--- .../eu/pb4/styledchat/CardboardWarning.java | 31 +++++++++++++++++++ .../eu/pb4/styledchat/StyledChatUtils.java | 6 ++-- .../eu/pb4/styledchat/command/Commands.java | 14 ++++----- .../mixin/commands/TeamMsgCommandMixin.java | 2 +- .../other/StyledChatSentMessage.java | 4 +-- src/main/resources/fabric.mod.json | 5 ++- 8 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 src/main/java/eu/pb4/styledchat/CardboardWarning.java diff --git a/build.gradle b/build.gradle index 1d1e674..e676721 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.+' + id 'fabric-loom' version '1.0.+' id 'maven-publish' id "com.modrinth.minotaur" version "2.+" id 'com.matthewprenger.cursegradle' version '1.4.0' @@ -43,8 +43,8 @@ dependencies { modCompileOnly fabricApi.module("fabric-message-api-v1", project.fabric_version) - modImplementation include("eu.pb4:predicate-api:0.1.0+1.19.3") - modImplementation include("eu.pb4:placeholder-api:2.1.0+1.19.4") + modImplementation include("eu.pb4:predicate-api:0.1.2+1.20") + modImplementation include("eu.pb4:placeholder-api:2.1.1+1.20") modImplementation include("me.lucko:fabric-permissions-api:0.2-SNAPSHOT") modImplementation include("eu.pb4:player-data-api:0.2.2+1.19.3") diff --git a/gradle.properties b/gradle.properties index c7aaa78..7ad3441 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=1.19.4 -yarn_mappings=1.19.4+build.1 -loader_version=0.14.14 +minecraft_version=1.20-rc1 +yarn_mappings=1.20-rc1+build.2 +loader_version=0.14.21 #Fabric api -fabric_version=0.75.1+1.19.4 +fabric_version=0.83.0+1.20 # Mod Properties - mod_version = 2.1.6+1.19.4 + mod_version = 2.2.0+1.20 maven_group = eu.pb4 archives_base_name = styled-chat diff --git a/src/main/java/eu/pb4/styledchat/CardboardWarning.java b/src/main/java/eu/pb4/styledchat/CardboardWarning.java new file mode 100644 index 0000000..c746208 --- /dev/null +++ b/src/main/java/eu/pb4/styledchat/CardboardWarning.java @@ -0,0 +1,31 @@ +package eu.pb4.styledchat; + +import com.mojang.logging.LogUtils; +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; +import org.slf4j.Logger; + +public class CardboardWarning implements PreLaunchEntrypoint { + public static final Logger LOGGER = LogUtils.getLogger(); + public static final boolean LOADED = FabricLoader.getInstance().isModLoaded("cardboard") || FabricLoader.getInstance().isModLoaded("banner"); + + @Override + public void onPreLaunch() { + checkAndAnnounce(); + } + + public static void checkAndAnnounce() { + if (LOADED) { + LOGGER.error("=============================================="); + for (var i = 0; i < 4; i++) { + LOGGER.error(""); + LOGGER.error("Cardboard/Banner detected! This mod doesn't work with it!"); + LOGGER.error("You won't get any support as long as it's present!"); + LOGGER.error(""); + LOGGER.error("Read more at: https://gist.github.com/Patbox/e44844294c358b614d347d369b0fc3bf"); + LOGGER.error(""); + LOGGER.error("=============================================="); + } + } + } +} diff --git a/src/main/java/eu/pb4/styledchat/StyledChatUtils.java b/src/main/java/eu/pb4/styledchat/StyledChatUtils.java index 9887848..b73fd97 100644 --- a/src/main/java/eu/pb4/styledchat/StyledChatUtils.java +++ b/src/main/java/eu/pb4/styledchat/StyledChatUtils.java @@ -342,7 +342,7 @@ public static Text formatMessage(SignedMessage message, ServerCommandSource sour ? baseInput : maybeFormatFor(source, ext.styledChat_getOriginal(), message.getContent()); - if (baseInput == null) { + if (baseInput == StyledChatUtils.EMPTY_TEXT) { ext.styledChat_setArg("base_input", input); } @@ -418,8 +418,8 @@ public static SignedMessage toEventMessage(SignedMessage message, PlaceholderCon var ext = (ExtSignedMessage) (Object) message; var baseInput = ext.styledChat_getArg("base_input"); - var input = baseInput != null && baseInput.getContent() != TextContent.EMPTY ? baseInput : formatFor(context, ext.styledChat_getOriginal()); - if (baseInput == null) { + var input = baseInput != StyledChatUtils.EMPTY_TEXT && baseInput.getContent() != TextContent.EMPTY ? baseInput : formatFor(context, ext.styledChat_getOriginal()); + if (baseInput == StyledChatUtils.EMPTY_TEXT) { ext.styledChat_setArg("base_input", input); } diff --git a/src/main/java/eu/pb4/styledchat/command/Commands.java b/src/main/java/eu/pb4/styledchat/command/Commands.java index d0a694c..bcc1b92 100644 --- a/src/main/java/eu/pb4/styledchat/command/Commands.java +++ b/src/main/java/eu/pb4/styledchat/command/Commands.java @@ -104,17 +104,17 @@ private static int getProperty(CommandContext context, Chat var data = StyledChatUtils.getPersonalData(player); if (data == null) { - context.getSource().sendFeedback(Text.literal("").formatted(Formatting.ITALIC), false); + context.getSource().sendFeedback(() -> Text.literal("").formatted(Formatting.ITALIC), false); return 0; } else { var val = propertyGetSet.get(data); if (val == null) { - context.getSource().sendFeedback(Text.literal("").formatted(Formatting.ITALIC), false); + context.getSource().sendFeedback(() -> Text.literal("").formatted(Formatting.ITALIC), false); return 0; } - context.getSource().sendFeedback(Text.literal(val), false); + context.getSource().sendFeedback(() -> Text.literal(val), false); return 1; } } @@ -126,7 +126,7 @@ private static int setProperty(CommandContext context, Chat propertySet.set(StyledChatUtils.getOrCreatePersonalData(player), val); StyledChatUtils.updateStyle(player); } - context.getSource().sendFeedback(Text.literal("Changed style of " + players.size() + " player(s)"), false); + context.getSource().sendFeedback(() -> Text.literal("Changed style of " + players.size() + " player(s)"), false); return players.size(); } @@ -140,7 +140,7 @@ private static int clearProperty(CommandContext context, Ch } StyledChatUtils.updateStyle(player); } - context.getSource().sendFeedback(Text.literal("Cleared style for " + players.size() + " player(s)"), false); + context.getSource().sendFeedback(() -> Text.literal("Cleared style for " + players.size() + " player(s)"), false); return players.size(); } @@ -172,7 +172,7 @@ private static int clearProperty(CommandContext context, Ch private static int reloadConfig(CommandContext context) { if (ConfigManager.loadConfig()) { - context.getSource().sendFeedback(Text.literal("Reloaded config!"), false); + context.getSource().sendFeedback(() -> Text.literal("Reloaded config!"), false); for (var player : context.getSource().getServer().getPlayerManager().getPlayerList()) { StyledChatUtils.sendAutocompliton(player); @@ -185,7 +185,7 @@ private static int reloadConfig(CommandContext context) { private static int about(CommandContext context) { for (var text : context.getSource().getEntity() instanceof ServerPlayerEntity ? GenericModInfo.getAboutFull() : GenericModInfo.getAboutConsole()) { - context.getSource().sendFeedback(text, false); + context.getSource().sendFeedback(() -> text, false); } diff --git a/src/main/java/eu/pb4/styledchat/mixin/commands/TeamMsgCommandMixin.java b/src/main/java/eu/pb4/styledchat/mixin/commands/TeamMsgCommandMixin.java index 84d11e8..8200aa7 100644 --- a/src/main/java/eu/pb4/styledchat/mixin/commands/TeamMsgCommandMixin.java +++ b/src/main/java/eu/pb4/styledchat/mixin/commands/TeamMsgCommandMixin.java @@ -28,7 +28,7 @@ public class TeamMsgCommandMixin { private static void styledChat_formatOgText(ServerCommandSource serverCommandSource, Entity entity, Team team, List list, SignedMessage signedMessage, CallbackInfo ci) { var input = ExtSignedMessage.getArg(signedMessage, "base_input"); - if (input == null) { + if (input == StyledChatUtils.EMPTY_TEXT) { input = StyledChatUtils.formatFor(serverCommandSource, ((ExtSignedMessage) (Object) signedMessage).styledChat_getOriginal()); ExtSignedMessage.setArg(signedMessage,"base_input", input); } diff --git a/src/main/java/eu/pb4/styledchat/other/StyledChatSentMessage.java b/src/main/java/eu/pb4/styledchat/other/StyledChatSentMessage.java index 54709e9..fd28706 100644 --- a/src/main/java/eu/pb4/styledchat/other/StyledChatSentMessage.java +++ b/src/main/java/eu/pb4/styledchat/other/StyledChatSentMessage.java @@ -42,7 +42,7 @@ public void send(ServerPlayerEntity receiver, boolean filterMaskEnabled, Message var baseInput = ExtSignedMessage.getArg(signedMessage, "base_input"); var source = ExtSignedMessage.of(signedMessage).styledChat_getSource(); - var input = baseInput != null && baseInput.getContent() != TextContent.EMPTY + var input = baseInput != StyledChatUtils.EMPTY_TEXT && baseInput.getContent() != TextContent.EMPTY ? baseInput : signedMessage.getContent(); @@ -73,7 +73,7 @@ public void send(ServerPlayerEntity receiver, boolean filterMaskEnabled, Message var baseInput = ExtSignedMessage.getArg(message, "base_input"); var source = ExtSignedMessage.of(message).styledChat_getSource(); - var input = baseInput != null && baseInput.getContent() != TextContent.EMPTY + var input = baseInput != StyledChatUtils.EMPTY_TEXT && baseInput.getContent() != TextContent.EMPTY ? baseInput : message.getContent(); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 35d35e4..9728159 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -19,6 +19,9 @@ "entrypoints": { "main": [ "eu.pb4.styledchat.StyledChatMod" + ], + "preLaunch": [ + "eu.pb4.styledchat.CardboardWarning" ] }, "mixins": [ @@ -26,7 +29,7 @@ ], "depends": { - "minecraft": ">=1.19.1-beta.2" + "minecraft": ">=1.20-" }, "custom": { "modmenu": {