Adjust server message decorator event phase
This commit is contained in:
parent
9a9944160e
commit
476539c584
|
@ -2,6 +2,7 @@ package io.gitlab.jfronny.googlechat.server;
|
||||||
|
|
||||||
import io.gitlab.jfronny.googlechat.*;
|
import io.gitlab.jfronny.googlechat.*;
|
||||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.event.Event;
|
||||||
import net.fabricmc.fabric.api.message.v1.ServerMessageDecoratorEvent;
|
import net.fabricmc.fabric.api.message.v1.ServerMessageDecoratorEvent;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
@ -13,7 +14,10 @@ import static io.gitlab.jfronny.libjf.LibJf.LOGGER;
|
||||||
public class GoogleChatServer implements DedicatedServerModInitializer {
|
public class GoogleChatServer implements DedicatedServerModInitializer {
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeServer() {
|
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;
|
Text original;
|
||||||
if (sender != null && hasTarget(GoogleChat.Direction.C2S)) {
|
if (sender != null && hasTarget(GoogleChat.Direction.C2S)) {
|
||||||
if (hasTarget(GoogleChat.Direction.S2C)) return CompletableFuture.completedFuture(message); // Do not translate back and forth
|
if (hasTarget(GoogleChat.Direction.S2C)) return CompletableFuture.completedFuture(message); // Do not translate back and forth
|
||||||
|
|
Loading…
Reference in New Issue
Block a user