aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-11-12 21:38:31 +0100
committerLinnea Gräf <nea@nea.moe>2024-11-12 21:38:31 +0100
commitfc88e54a2e88c87bcfd5e7dbd6866764faa3e503 (patch)
treec5ec7980b67c47ce0d89175cb6ac9a180a94c3f3 /src/main/java/moe/nea
parentb774daef5bd961f955d365ce07bd5aa4acb161f4 (diff)
downloadFirmament-fc88e54a2e88c87bcfd5e7dbd6866764faa3e503.tar.gz
Firmament-fc88e54a2e88c87bcfd5e7dbd6866764faa3e503.tar.bz2
Firmament-fc88e54a2e88c87bcfd5e7dbd6866764faa3e503.zip
feat: Add descriptions for config options
Diffstat (limited to 'src/main/java/moe/nea')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/devenv/EarlyInstantiateTranslations.java19
-rw-r--r--src/main/java/moe/nea/firmament/mixins/devenv/WarnOnMissingTranslations.java38
2 files changed, 57 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/devenv/EarlyInstantiateTranslations.java b/src/main/java/moe/nea/firmament/mixins/devenv/EarlyInstantiateTranslations.java
new file mode 100644
index 0000000..ef8c9eb
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/devenv/EarlyInstantiateTranslations.java
@@ -0,0 +1,19 @@
+package moe.nea.firmament.mixins.devenv;
+
+import net.minecraft.text.TranslatableTextContent;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Mixin(TranslatableTextContent.class)
+public abstract class EarlyInstantiateTranslations {
+ @Shadow
+ protected abstract void updateTranslations();
+
+ @Inject(method = "<init>", at = @At("TAIL"))
+ private void onInit(String key, String fallback, Object[] args, CallbackInfo ci) {
+ updateTranslations();
+ }
+}
diff --git a/src/main/java/moe/nea/firmament/mixins/devenv/WarnOnMissingTranslations.java b/src/main/java/moe/nea/firmament/mixins/devenv/WarnOnMissingTranslations.java
new file mode 100644
index 0000000..33840c1
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/devenv/WarnOnMissingTranslations.java
@@ -0,0 +1,38 @@
+package moe.nea.firmament.mixins.devenv;
+
+import moe.nea.firmament.features.debug.DeveloperFeatures;
+import moe.nea.firmament.util.MC;
+import net.minecraft.client.resource.language.TranslationStorage;
+import net.minecraft.text.Text;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.Unique;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+import java.util.Set;
+import java.util.TreeSet;
+
+@Mixin(TranslationStorage.class)
+public abstract class WarnOnMissingTranslations {
+ @Shadow
+ public abstract boolean hasTranslation(String key);
+
+ @Unique
+ private final Set<String> missingTranslations = new TreeSet<>();
+
+ @Inject(method = "get", at = @At("HEAD"))
+ private void onGetTranslationKey(String key, String fallback, CallbackInfoReturnable<String> cir) {
+ warnForMissingTranslation(key);
+ }
+
+ @Unique
+ private void warnForMissingTranslation(String key) {
+ if (!key.contains("firmament")) return;
+ if (hasTranslation(key)) return;
+ if (!missingTranslations.add(key)) return;
+ MC.INSTANCE.sendChat(Text.literal("Missing firmament translation: " + key));
+ DeveloperFeatures.hookMissingTranslations(missingTranslations);
+ }
+}