Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1902' into 2002
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxNeedsSnacks committed Feb 6, 2024
2 parents 5aa597b + 3f481aa commit ffc69f4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
2 changes: 0 additions & 2 deletions common/src/main/java/dev/latvian/mods/kubejs/KubeJS.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.nio.file.Path;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Locale;

public class KubeJS {
public static final String MOD_ID = "kubejs";
Expand Down Expand Up @@ -86,7 +85,6 @@ public static ScriptManager getClientScriptManager() {
public KubeJS() throws Throwable {
instance = this;
gameDirectory = Platform.getGameFolder().normalize().toAbsolutePath();
Locale.setDefault(Locale.US);

if (Files.notExists(KubeJSPaths.README)) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.ComponentContents;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.contents.ScoreContents;
import net.minecraft.network.chat.contents.SelectorContents;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
import org.jetbrains.annotations.Nullable;
Expand All @@ -22,6 +24,7 @@
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

@Info("The hub for all things text components. Format text to your hearts content!")
public class TextWrapper {
Expand Down Expand Up @@ -180,6 +183,11 @@ public static MutableComponent join(MutableComponent separator, Iterable<? exten
return joined;
}

@Info("Returns an empty component")
public static MutableComponent empty() {
return Component.empty();
}

@Info("Joins all components")
public static MutableComponent join(Component... texts) {
return join(Component.empty(), Arrays.asList(texts));
Expand All @@ -190,21 +198,51 @@ public static MutableComponent string(String text) {
return Component.literal(text);
}

@Info("Returns a plain component of the input")
public static MutableComponent literal(String text) {
return Component.literal(text);
}

@Info("Returns a translatable component of the input key")
public static MutableComponent translate(String key) {
return Component.translatable(key, new Object[0]);
return Component.translatable(key);
}

@Info("Returns a translatable component of the input key, with args of the objects")
public static MutableComponent translate(String key, Object... objects) {
return Component.translatable(key, objects);
}

@Info("Returns a translatable component of the input key")
public static MutableComponent translatable(String key) {
return Component.translatable(key);
}

@Info("Returns a translatable component of the input key, with args of the objects")
public static MutableComponent translatable(String key, Object... objects) {
return Component.translatable(key, objects);
}

@Info("Returns a keybinding component of the input keybinding descriptor")
public static MutableComponent keybind(String keybind) {
return Component.keybind(keybind);
}

@Info("Returns a score component of the input objective, for the provided selector")
public static MutableComponent score(String selector, String objective) {
return MutableComponent.create(new ScoreContents(selector, objective));
}

@Info("Returns a component displaying all entities matching the input selector")
public static MutableComponent selector(String selector) {
return MutableComponent.create(new SelectorContents(selector, Optional.empty()));
}

@Info("Returns a component displaying all entities matching the input selector, with a custom separator")
public static MutableComponent selector(String selector, Component separator) {
return MutableComponent.create(new SelectorContents(selector, Optional.of(separator)));
}

@Info("Returns a component of the input, colored black")
public static MutableComponent black(Object text) {
return of(text).kjs$black();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.latvian.mods.kubejs.generator.DataJsonGenerator;
import dev.latvian.mods.kubejs.typings.Info;
import dev.latvian.mods.kubejs.util.UtilsJS;
import net.minecraft.Util;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

Expand Down Expand Up @@ -117,7 +118,7 @@ public void generateAssetJsons(AssetJsonGenerator generator) {

public String getBuilderTranslationKey() {
if (translationKey.isEmpty()) {
return getTranslationKeyGroup() + '.' + id.getNamespace() + '.' + id.getPath();
return Util.makeDescriptionId(getTranslationKeyGroup(), id);
}

return translationKey;
Expand Down

0 comments on commit ffc69f4

Please sign in to comment.