This commit is contained in:
parent
db307c7223
commit
725fb15031
@ -21,6 +21,8 @@ public abstract class MessageHandlerMixin {
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
@Shadow protected abstract void narrate(MessageType.Parameters params, Text message);
|
||||
|
||||
//TODO somehow modify applyChatDecoration, since that is the only method that knows the real text
|
||||
|
||||
@Unique CompletableFuture<Void> googlechat$currentFuture = CompletableFuture.completedFuture(null);
|
||||
@Unique ThreadLocal<GameProfile> sender = new ThreadLocal<>();
|
||||
|
||||
@ -78,10 +80,12 @@ public abstract class MessageHandlerMixin {
|
||||
this.sender.remove();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private Text googlechat$s2c(Text message) {
|
||||
return GoogleChat.translateIfNeeded(message, TranslationDirection.S2C, true);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void googlechat$schedule(Runnable runnable) {
|
||||
if (!GoogleChatConfig.Advanced.async) runnable.run();
|
||||
else googlechat$currentFuture.whenCompleteAsync((_1, _2) -> runnable.run()).exceptionally(throwable -> {
|
||||
@ -90,6 +94,7 @@ public abstract class MessageHandlerMixin {
|
||||
});
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean googlechat$shouldTranslate() {
|
||||
if (!GoogleChatConfig.General.enabled) return false;
|
||||
if (client == null || client.player == null) return false;
|
||||
|
@ -26,7 +26,7 @@ public sealed interface TranslatableContainer<T, S extends TranslatableContainer
|
||||
|
||||
static Text translateAndLog(final Text source, final TranslationDirection direction) {
|
||||
var translated = GoogleChat.translateIfNeeded(source, direction, true);
|
||||
if (GoogleChatConfig.Advanced.debugLogs) LOGGER.info("Applied C2S translation from " + source + " to " + translated);
|
||||
if (GoogleChatConfig.Advanced.debugLogs) LOGGER.info("Applied C2S translation from {0} to {1}", source, translated);
|
||||
return translated;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user