Adjust server message decorator event phase
ci/woodpecker/push/jfmod Pipeline failed Details
ci/woodpecker/tag/jfmod Pipeline was successful Details

This commit is contained in:
Johannes Frohnmeyer 2023-03-22 19:12:14 +01:00
parent 9a9944160e
commit 476539c584
Signed by: Johannes
GPG Key ID: E76429612C2929F4
1 changed files with 5 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package io.gitlab.jfronny.googlechat.server;
import io.gitlab.jfronny.googlechat.*;
import net.fabricmc.api.DedicatedServerModInitializer;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.message.v1.ServerMessageDecoratorEvent;
import net.minecraft.text.Text;
@ -13,7 +14,10 @@ import static io.gitlab.jfronny.libjf.LibJf.LOGGER;
public class GoogleChatServer implements DedicatedServerModInitializer {
@Override
public void onInitializeServer() {
ServerMessageDecoratorEvent.EVENT.register(ServerMessageDecoratorEvent.CONTENT_PHASE, (sender, message) -> {
// Default phase is executed between CONTENT and STYLING
// Perform translation there instead of during CONTENT to better support other mods (such as chat-transform)
// If this causes an incompatibility, I'll add my own phase
ServerMessageDecoratorEvent.EVENT.register(Event.DEFAULT_PHASE, (sender, message) -> {
Text original;
if (sender != null && hasTarget(GoogleChat.Direction.C2S)) {
if (hasTarget(GoogleChat.Direction.S2C)) return CompletableFuture.completedFuture(message); // Do not translate back and forth