fix(config-ui-tiny): use correct Text for default preset
ci/woodpecker/push/docs Pipeline was successful Details
ci/woodpecker/push/jfmod Pipeline was successful Details

This commit is contained in:
Johannes Frohnmeyer 2024-04-25 19:38:45 +02:00
parent 8cfa3c2a93
commit 64f0f38668
Signed by: Johannes
GPG Key ID: E76429612C2929F4
2 changed files with 3 additions and 2 deletions

View File

@ -26,7 +26,7 @@ public class TinyConfigScreenFactory implements ConfigScreenFactory<Screen, Tiny
&& config.getPresets().keySet().stream().allMatch(s -> s.equals(CategoryBuilder.CONFIG_PRESET_DEFAULT))
&& config.getReferencedConfigs().isEmpty()
&& config.getCategories().isEmpty()) {
EntryInfo entry = config.getEntries().get(0);
EntryInfo entry = config.getEntries().getFirst();
Type type = entry.supportsRepresentation() ? entry.getValueType() : null;
if (type != null && !type.isInt() && !type.isLong() && !type.isFloat() && !type.isDouble() && !type.isString() && !type.isBool() && !type.isEnum()) {
final String jsonified;

View File

@ -2,6 +2,7 @@ package io.gitlab.jfronny.libjf.config.impl.ui.tiny.presets;
import io.gitlab.jfronny.libjf.LibJf;
import io.gitlab.jfronny.libjf.config.api.v2.ConfigCategory;
import io.gitlab.jfronny.libjf.config.api.v2.dsl.CategoryBuilder;
import io.gitlab.jfronny.libjf.config.impl.ConfigCore;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@ -31,7 +32,7 @@ public class PresetsScreen extends Screen {
super.init();
PresetListWidget list = new PresetListWidget(this.client, this.width, this.height, 32, 25);
for (Map.Entry<String, Runnable> entry : config.getPresets().entrySet()) {
list.addButton(ButtonWidget.builder(Text.translatable(config.getTranslationPrefix() + entry.getKey()),
list.addButton(ButtonWidget.builder(CategoryBuilder.CONFIG_PRESET_DEFAULT.equals(entry.getKey()) ? Text.translatable(entry.getKey()) : Text.translatable(config.getTranslationPrefix() + entry.getKey()),
button -> {
LibJf.LOGGER.info("Preset selected: " + entry.getKey());
entry.getValue().run();