style: clean up a bit
All checks were successful
ci/woodpecker/push/jfmod Pipeline was successful

This commit is contained in:
Johannes Frohnmeyer 2024-07-15 19:41:27 +02:00
parent db307c7223
commit 725fb15031
Signed by: Johannes
GPG Key ID: E76429612C2929F4
2 changed files with 6 additions and 1 deletions

View File

@ -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;

View File

@ -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;
}
}