Skip to content

Commit

Permalink
LangEntries#path()
Browse files Browse the repository at this point in the history
  • Loading branch information
ZZZank committed Jun 6, 2024
1 parent 9bc64d2 commit 05bf8c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,9 @@ private void generateLang(AssetJsonGenerator generator) {
//using a special namespace to keep backward equivalence
langEvent.get("kubejs_generated", "en_us").addAll(langMap);

for (var entry : langEvent.namespace2lang2entries.entrySet()) {
var namespace = entry.getKey();
var lang2entries = entry.getValue();
for (var e : lang2entries.entrySet()) {
var lang = e.getKey();
var entries = e.getValue();
generator.json(new ResourceLocation(namespace, "lang/" + lang), entries.asJson());
for (var lang2entries : langEvent.namespace2lang2entries.values()) {
for (var entries : lang2entries.values()) {
generator.json(entries.path(), entries.asJson());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.latvian.kubejs.KubeJS;
import dev.latvian.kubejs.event.EventJS;
import dev.latvian.kubejs.item.ItemStackJS;
import dev.latvian.mods.rhino.annotations.typing.JSInfo;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -50,7 +51,12 @@ public JsonObject asJson() {
return obj;
}

public static void ensureValid(String key, String text) {
@JSInfo("`{namespace}:lang/{lang}`")
public ResourceLocation path() {
return new ResourceLocation(namespace, "lang/" + lang);
}

static void ensureValid(String key, String text) {
if (key == null || text == null || key.trim().isEmpty()) {
throw new IllegalArgumentException("Invalid key or value: [" + key + ", " + text + "]");
}
Expand Down

0 comments on commit 05bf8c8

Please sign in to comment.