diff --git a/build.gradle b/build.gradle index 124973a..17fde4a 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ repositories { maven { url 'https://maven.nucleoid.xyz' } maven { url 'https://maven.gegy.dev' } - //mavenLocal() + mavenLocal() } dependencies { @@ -37,7 +37,7 @@ dependencies { modCompileOnly("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}") modLocalRuntime("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}") - modImplementation include("eu.pb4:placeholder-api:2.0.0-beta.3+1.19") + modImplementation include("eu.pb4:placeholder-api:2.0.0-beta.5+1.19") modImplementation include("me.lucko:fabric-permissions-api:0.1-SNAPSHOT") //modRuntime "supercoder79:databreaker:0.2.7" diff --git a/gradle.properties b/gradle.properties index 830f2b2..1e91817 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ loader_version=0.14.6 fabric_version=0.55.1+1.19 # Mod Properties - mod_version = 1.3.1+1.19 + mod_version = 1.3.2+1.19 maven_group = eu.pb4 archives_base_name = styled-chat diff --git a/src/main/java/eu/pb4/styledchat/config/ChatStyle.java b/src/main/java/eu/pb4/styledchat/config/ChatStyle.java index 930a9ff..3e1fa9e 100644 --- a/src/main/java/eu/pb4/styledchat/config/ChatStyle.java +++ b/src/main/java/eu/pb4/styledchat/config/ChatStyle.java @@ -297,7 +297,7 @@ public Text getPrivateMessageSent(Text sender, Text receiver, Text message, Obje ); } - public Text getPrivateMessageReceived(Text sender, Text receiver, Text message, Object placeholderContext) { + public Text getPrivateMessageReceived(Text sender, Text receiver, Text message, PlaceholderContext context) { if (this.privateMessageReceived == null) { return null; } else if (this.privateMessageReceived == StyledChatUtils.IGNORED_TEXT) { @@ -306,8 +306,7 @@ public Text getPrivateMessageReceived(Text sender, Text receiver, Text message, return Placeholders.parseText( this.privateMessageReceived, - placeholderContext instanceof ServerPlayerEntity player ? PlaceholderContext.of(player) : PlaceholderContext.of((MinecraftServer) placeholderContext), - + context, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, Map.of("sender", sender, "receiver", receiver, diff --git a/src/main/java/eu/pb4/styledchat/config/Config.java b/src/main/java/eu/pb4/styledchat/config/Config.java index 8dff0f0..fb9975d 100644 --- a/src/main/java/eu/pb4/styledchat/config/Config.java +++ b/src/main/java/eu/pb4/styledchat/config/Config.java @@ -245,13 +245,7 @@ public Text getPrivateMessageSent(Text sender, Text receiver, Text message, Serv } public Text getPrivateMessageReceived(Text sender, Text receiver, Text message, ServerCommandSource context) { - Object placeholderContext; - - try { - placeholderContext = context.getPlayer(); - } catch (Exception e) { - placeholderContext = context.getServer(); - } + var placeholderContext = PlaceholderContext.of(context); for (PermissionStyle entry : this.permissionStyle) { if (Permissions.check(context, entry.permission, entry.opLevel)) { diff --git a/src/main/java/eu/pb4/styledchat/mixin/MessageArgumentTypeSignedMessageMixin.java b/src/main/java/eu/pb4/styledchat/mixin/MessageArgumentTypeSignedMessageMixin.java index 0b9192c..1c5deca 100644 --- a/src/main/java/eu/pb4/styledchat/mixin/MessageArgumentTypeSignedMessageMixin.java +++ b/src/main/java/eu/pb4/styledchat/mixin/MessageArgumentTypeSignedMessageMixin.java @@ -16,8 +16,11 @@ public class MessageArgumentTypeSignedMessageMixin { @Redirect(method = "method_44266", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getMessageDecorator()Lnet/minecraft/network/message/MessageDecorator;")) private MessageDecorator styledChat_returnCached(MinecraftServer instance) { return (player, message) -> { - var cached = ((ExtPlayNetworkHandler) player.networkHandler).styledChat_getLastCached(); - return CompletableFuture.completedFuture(cached != null ? cached : message); + if (player != null) { + var cached = ((ExtPlayNetworkHandler) player.networkHandler).styledChat_getLastCached(); + return CompletableFuture.completedFuture(cached != null ? cached : message); + } + return CompletableFuture.completedFuture(message); }; } }