aboutsummaryrefslogtreecommitdiff
path: root/src/client/java/dev/isxander/yacl/impl
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/java/dev/isxander/yacl/impl')
-rw-r--r--src/client/java/dev/isxander/yacl/impl/ButtonOptionImpl.java28
-rw-r--r--src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java28
-rw-r--r--src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java44
-rw-r--r--src/client/java/dev/isxander/yacl/impl/ListOptionEntryImpl.java12
-rw-r--r--src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java26
-rw-r--r--src/client/java/dev/isxander/yacl/impl/OptionGroupImpl.java26
-rw-r--r--src/client/java/dev/isxander/yacl/impl/OptionImpl.java36
-rw-r--r--src/client/java/dev/isxander/yacl/impl/PlaceholderCategoryImpl.java39
-rw-r--r--src/client/java/dev/isxander/yacl/impl/YetAnotherConfigLibImpl.java15
9 files changed, 126 insertions, 128 deletions
diff --git a/src/client/java/dev/isxander/yacl/impl/ButtonOptionImpl.java b/src/client/java/dev/isxander/yacl/impl/ButtonOptionImpl.java
index 25260c4..33cb474 100644
--- a/src/client/java/dev/isxander/yacl/impl/ButtonOptionImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/ButtonOptionImpl.java
@@ -3,8 +3,8 @@ package dev.isxander.yacl.impl;
import com.google.common.collect.ImmutableSet;
import dev.isxander.yacl.api.*;
import dev.isxander.yacl.gui.YACLScreen;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -18,16 +18,16 @@ import java.util.function.Function;
@ApiStatus.Internal
public final class ButtonOptionImpl implements ButtonOption {
- private final Text name;
- private final Text tooltip;
+ private final Component name;
+ private final Component tooltip;
private final BiConsumer<YACLScreen, ButtonOption> action;
private boolean available;
private final Controller<BiConsumer<YACLScreen, ButtonOption>> controller;
private final Binding<BiConsumer<YACLScreen, ButtonOption>> binding;
public ButtonOptionImpl(
- @NotNull Text name,
- @Nullable Text tooltip,
+ @NotNull Component name,
+ @Nullable Component tooltip,
@NotNull BiConsumer<YACLScreen, ButtonOption> action,
boolean available,
@NotNull Function<ButtonOption, Controller<BiConsumer<YACLScreen, ButtonOption>>> controlGetter
@@ -41,12 +41,12 @@ public final class ButtonOptionImpl implements ButtonOption {
}
@Override
- public @NotNull Text name() {
+ public @NotNull Component name() {
return name;
}
@Override
- public @NotNull Text tooltip() {
+ public @NotNull Component tooltip() {
return tooltip;
}
@@ -144,14 +144,14 @@ public final class ButtonOptionImpl implements ButtonOption {
@ApiStatus.Internal
public static final class BuilderImpl implements ButtonOption.Builder {
- private Text name;
- private final List<Text> tooltipLines = new ArrayList<>();
+ private Component name;
+ private final List<Component> tooltipLines = new ArrayList<>();
private boolean available = true;
private Function<ButtonOption, Controller<BiConsumer<YACLScreen, ButtonOption>>> controlGetter;
private BiConsumer<YACLScreen, ButtonOption> action;
@Override
- public ButtonOption.Builder name(@NotNull Text name) {
+ public ButtonOption.Builder name(@NotNull Component name) {
Validate.notNull(name, "`name` cannot be null");
this.name = name;
@@ -159,7 +159,7 @@ public final class ButtonOptionImpl implements ButtonOption {
}
@Override
- public ButtonOption.Builder tooltip(@NotNull Text... tooltips) {
+ public ButtonOption.Builder tooltip(@NotNull Component... tooltips) {
Validate.notNull(tooltips, "`tooltips` cannot be empty");
tooltipLines.addAll(List.of(tooltips));
@@ -203,9 +203,9 @@ public final class ButtonOptionImpl implements ButtonOption {
Validate.notNull(controlGetter, "`control` must not be null when building `Option`");
Validate.notNull(action, "`action` must not be null when building `Option`");
- MutableText concatenatedTooltip = Text.empty();
+ MutableComponent concatenatedTooltip = Component.empty();
boolean first = true;
- for (Text line : tooltipLines) {
+ for (Component line : tooltipLines) {
if (!first) concatenatedTooltip.append("\n");
first = false;
diff --git a/src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java b/src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java
index 6879e17..efbd8c9 100644
--- a/src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java
@@ -6,8 +6,8 @@ import dev.isxander.yacl.api.ListOption;
import dev.isxander.yacl.api.Option;
import dev.isxander.yacl.api.OptionGroup;
import dev.isxander.yacl.impl.utils.YACLConstants;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -18,18 +18,18 @@ import java.util.List;
@ApiStatus.Internal
public final class ConfigCategoryImpl implements ConfigCategory {
- private final Text name;
+ private final Component name;
private final ImmutableList<OptionGroup> groups;
- private final Text tooltip;
+ private final Component tooltip;
- public ConfigCategoryImpl(Text name, ImmutableList<OptionGroup> groups, Text tooltip) {
+ public ConfigCategoryImpl(Component name, ImmutableList<OptionGroup> groups, Component tooltip) {
this.name = name;
this.groups = groups;
this.tooltip = tooltip;
}
@Override
- public @NotNull Text name() {
+ public @NotNull Component name() {
return name;
}
@@ -39,21 +39,21 @@ public final class ConfigCategoryImpl implements ConfigCategory {
}
@Override
- public @NotNull Text tooltip() {
+ public @NotNull Component tooltip() {
return tooltip;
}
@ApiStatus.Internal
public static final class BuilderImpl implements Builder {
- private Text name;
+ private Component name;
private final List<Option<?>> rootOptions = new ArrayList<>();
private final List<OptionGroup> groups = new ArrayList<>();
- private final List<Text> tooltipLines = new ArrayList<>();
+ private final List<Component> tooltipLines = new ArrayList<>();
@Override
- public Builder name(@NotNull Text name) {
+ public Builder name(@NotNull Component name) {
Validate.notNull(name, "`name` cannot be null");
this.name = name;
@@ -101,7 +101,7 @@ public final class ConfigCategoryImpl implements ConfigCategory {
}
@Override
- public Builder tooltip(@NotNull Text... tooltips) {
+ public Builder tooltip(@NotNull Component... tooltips) {
Validate.notEmpty(tooltips, "`tooltips` cannot be empty");
tooltipLines.addAll(List.of(tooltips));
@@ -113,14 +113,14 @@ public final class ConfigCategoryImpl implements ConfigCategory {
Validate.notNull(name, "`name` must not be null to build `ConfigCategory`");
List<OptionGroup> combinedGroups = new ArrayList<>();
- combinedGroups.add(new OptionGroupImpl(Text.empty(), Text.empty(), ImmutableList.copyOf(rootOptions), false, true));
+ combinedGroups.add(new OptionGroupImpl(Component.empty(), Component.empty(), ImmutableList.copyOf(rootOptions), false, true));
combinedGroups.addAll(groups);
Validate.notEmpty(combinedGroups, "at least one option must be added to build `ConfigCategory`");
- MutableText concatenatedTooltip = Text.empty();
+ MutableComponent concatenatedTooltip = Component.empty();
boolean first = true;
- for (Text line : tooltipLines) {
+ for (Component line : tooltipLines) {
if (!first) concatenatedTooltip.append("\n");
first = false;
diff --git a/src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java b/src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java
index a816b82..b6c3c09 100644
--- a/src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/LabelOptionImpl.java
@@ -3,8 +3,8 @@ package dev.isxander.yacl.impl;
import com.google.common.collect.ImmutableSet;
import dev.isxander.yacl.api.*;
import dev.isxander.yacl.gui.controllers.LabelController;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -17,40 +17,40 @@ import java.util.function.BiConsumer;
@ApiStatus.Internal
public final class LabelOptionImpl implements LabelOption {
- private final Text label;
- private final Text name = Text.literal("Label Option");
- private final Text tooltip = Text.empty();
+ private final Component label;
+ private final Component name = Component.literal("Label Option");
+ private final Component tooltip = Component.empty();
private final LabelController labelController;
- private final Binding<Text> binding;
+ private final Binding<Component> binding;
- public LabelOptionImpl(Text label) {
+ public LabelOptionImpl(Component label) {
this.label = label;
this.labelController = new LabelController(this);
this.binding = Binding.immutable(label);
}
@Override
- public @NotNull Text label() {
+ public @NotNull Component label() {
return label;
}
@Override
- public @NotNull Text name() {
+ public @NotNull Component name() {
return name;
}
@Override
- public @NotNull Text tooltip() {
+ public @NotNull Component tooltip() {
return tooltip;
}
@Override
- public @NotNull Controller<Text> controller() {
+ public @NotNull Controller<Component> controller() {
return labelController;
}
@Override
- public @NotNull Binding<Text> binding() {
+ public @NotNull Binding<Component> binding() {
return binding;
}
@@ -65,8 +65,8 @@ public final class LabelOptionImpl implements LabelOption {
}
@Override
- public @NotNull Class<Text> typeClass() {
- return Text.class;
+ public @NotNull Class<Component> typeClass() {
+ return Component.class;
}
@Override
@@ -80,12 +80,12 @@ public final class LabelOptionImpl implements LabelOption {
}
@Override
- public @NotNull Text pendingValue() {
+ public @NotNull Component pendingValue() {
return label;
}
@Override
- public void requestSet(Text value) {
+ public void requestSet(Component value) {
}
@@ -115,16 +115,16 @@ public final class LabelOptionImpl implements LabelOption {
}
@Override
- public void addListener(BiConsumer<Option<Text>, Text> changedListener) {
+ public void addListener(BiConsumer<Option<Component>, Component> changedListener) {
}
@ApiStatus.Internal
public static final class BuilderImpl implements LabelOption.Builder {
- private final List<Text> lines = new ArrayList<>();
+ private final List<Component> lines = new ArrayList<>();
@Override
- public Builder line(@NotNull Text line) {
+ public dev.isxander.yacl.api.LabelOption.Builder line(@NotNull Component line) {
Validate.notNull(line, "`line` must not be null");
this.lines.add(line);
@@ -132,15 +132,15 @@ public final class LabelOptionImpl implements LabelOption {
}
@Override
- public Builder lines(@NotNull Collection<? extends Text> lines) {
+ public dev.isxander.yacl.api.LabelOption.Builder lines(@NotNull Collection<? extends Component> lines) {
this.lines.addAll(lines);
return this;
}
@Override
public LabelOption build() {
- MutableText text = Text.empty();
- Iterator<Text> iterator = lines.iterator();
+ MutableComponent text = Component.empty();
+ Iterator<Component> iterator = lines.iterator();
while (iterator.hasNext()) {
text.append(iterator.next());
diff --git a/src/client/java/dev/isxander/yacl/impl/ListOptionEntryImpl.java b/src/client/java/dev/isxander/yacl/impl/ListOptionEntryImpl.java
index 98188dc..c15efe6 100644
--- a/src/client/java/dev/isxander/yacl/impl/ListOptionEntryImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/ListOptionEntryImpl.java
@@ -5,7 +5,7 @@ import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.gui.AbstractWidget;
import dev.isxander.yacl.gui.YACLScreen;
import dev.isxander.yacl.gui.controllers.ListEntryWidget;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -29,13 +29,13 @@ public final class ListOptionEntryImpl<T> implements ListOptionEntry<T> {
}
@Override
- public @NotNull Text name() {
- return Text.empty();
+ public @NotNull Component name() {
+ return Component.empty();
}
@Override
- public @NotNull Text tooltip() {
- return Text.empty();
+ public @NotNull Component tooltip() {
+ return Component.empty();
}
@Override
@@ -119,7 +119,7 @@ public final class ListOptionEntryImpl<T> implements ListOptionEntry<T> {
}
@Override
- public Text formatValue() {
+ public Component formatValue() {
return controller.formatValue();
}
diff --git a/src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java b/src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java
index fb74601..e7230b0 100644
--- a/src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/ListOptionImpl.java
@@ -3,8 +3,8 @@ package dev.isxander.yacl.impl;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import dev.isxander.yacl.api.*;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -18,8 +18,8 @@ import java.util.stream.Collectors;
@ApiStatus.Internal
public final class ListOptionImpl<T> implements ListOption<T> {
- private final Text name;
- private final Text tooltip;
+ private final Component name;
+ private final Component tooltip;
private final Binding<List<T>> binding;
private final T initialValue;
private final List<ListOptionEntry<T>> entries;
@@ -31,7 +31,7 @@ public final class ListOptionImpl<T> implements ListOption<T> {
private final List<BiConsumer<Option<List<T>>, List<T>>> listeners;
private final List<Runnable> refreshListeners;
- public ListOptionImpl(@NotNull Text name, @NotNull Text tooltip, @NotNull Binding<List<T>> binding, @NotNull T initialValue, @NotNull Class<T> typeClass, @NotNull Function<ListOptionEntry<T>, Controller<T>> controllerFunction, ImmutableSet<OptionFlag> flags, boolean collapsed, boolean available) {
+ public ListOptionImpl(@NotNull Component name, @NotNull Component tooltip, @NotNull Binding<List<T>> binding, @NotNull T initialValue, @NotNull Class<T> typeClass, @NotNull Function<ListOptionEntry<T>, Controller<T>> controllerFunction, ImmutableSet<OptionFlag> flags, boolean collapsed, boolean available) {
this.name = name;
this.tooltip = tooltip;
this.binding = binding;
@@ -48,12 +48,12 @@ public final class ListOptionImpl<T> implements ListOption<T> {
}
@Override
- public @NotNull Text name() {
+ public @NotNull Component name() {
return this.name;
}
@Override
- public @NotNull Text tooltip() {
+ public @NotNull Component tooltip() {
return this.tooltip;
}
@@ -211,8 +211,8 @@ public final class ListOptionImpl<T> implements ListOption<T> {
@ApiStatus.Internal
public static final class BuilderImpl<T> implements ListOption.Builder<T> {
- private Text name = Text.empty();
- private final List<Text> tooltipLines = new ArrayList<>();
+ private Component name = Component.empty();
+ private final List<Component> tooltipLines = new ArrayList<>();
private Function<ListOptionEntry<T>, Controller<T>> controllerFunction;
private Binding<List<T>> binding = null;
private final Set<OptionFlag> flags = new HashSet<>();
@@ -226,7 +226,7 @@ public final class ListOptionImpl<T> implements ListOption<T> {
}
@Override
- public ListOption.Builder<T> name(@NotNull Text name) {
+ public ListOption.Builder<T> name(@NotNull Component name) {
Validate.notNull(name, "`name` must not be null");
this.name = name;
@@ -234,7 +234,7 @@ public final class ListOptionImpl<T> implements ListOption<T> {
}
@Override
- public ListOption.Builder<T> tooltip(@NotNull Text... tooltips) {
+ public ListOption.Builder<T> tooltip(@NotNull Component... tooltips) {
Validate.notEmpty(tooltips, "`tooltips` cannot be empty");
tooltipLines.addAll(List.of(tooltips));
@@ -309,9 +309,9 @@ public final class ListOptionImpl<T> implements ListOption<T> {
Validate.notNull(binding, "`binding` must not be null");
Validate.notNull(initialValue, "`initialValue` must not be null");
- MutableText concatenatedTooltip = Text.empty();
+ MutableComponent concatenatedTooltip = Component.empty();
boolean first = true;
- for (Text line : tooltipLines) {
+ for (Component line : tooltipLines) {
if (!first) concatenatedTooltip.append("\n");
first = false;
diff --git a/src/client/java/dev/isxander/yacl/impl/OptionGroupImpl.java b/src/client/java/dev/isxander/yacl/impl/OptionGroupImpl.java
index 1612a7e..0f883d9 100644
--- a/src/client/java/dev/isxander/yacl/impl/OptionGroupImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/OptionGroupImpl.java
@@ -4,8 +4,8 @@ import com.google.common.collect.ImmutableList;
import dev.isxander.yacl.api.ListOption;
import dev.isxander.yacl.api.Option;
import dev.isxander.yacl.api.OptionGroup;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -16,13 +16,13 @@ import java.util.List;
@ApiStatus.Internal
public final class OptionGroupImpl implements OptionGroup {
- private final @NotNull Text name;
- private final @NotNull Text tooltip;
+ private final @NotNull Component name;
+ private final @NotNull Component tooltip;
private final ImmutableList<? extends Option<?>> options;
private final boolean collapsed;
private final boolean isRoot;
- public OptionGroupImpl(@NotNull Text name, @NotNull Text tooltip, ImmutableList<? extends Option<?>> options, boolean collapsed, boolean isRoot) {
+ public OptionGroupImpl(@NotNull Component name, @NotNull Component tooltip, ImmutableList<? extends Option<?>> options, boolean collapsed, boolean isRoot) {
this.name = name;
this.tooltip = tooltip;
this.options = options;
@@ -31,12 +31,12 @@ public final class OptionGroupImpl implements OptionGroup {
}
@Override
- public @NotNull Text name() {
+ public @NotNull Component name() {
return name;
}
@Override
- public @NotNull Text tooltip() {
+ public @NotNull Component tooltip() {
return tooltip;
}
@@ -57,13 +57,13 @@ public final class OptionGroupImpl implements OptionGroup {
@ApiStatus.Internal
public static final class BuilderImpl implements OptionGroup.Builder {
- private Text name = Text.empty();
- private final List<Text> tooltipLines = new ArrayList<>();
+ private Component name = Component.empty();
+ private final List<Component> tooltipLines = new ArrayList<>();
private final List<Option<?>> options = new ArrayList<>();
private boolean collapsed = false;
@Override
- public Builder name(@NotNull Text name) {
+ public Builder name(@NotNull Component name) {
Validate.notNull(name, "`name` must not be null");
this.name = name;
@@ -71,7 +71,7 @@ public final class OptionGroupImpl implements OptionGroup {
}
@Override
- public Builder tooltip(@NotNull Text... tooltips) {
+ public Builder tooltip(@NotNull Component... tooltips) {
Validate.notEmpty(tooltips, "`tooltips` cannot be empty");
tooltipLines.addAll(List.of(tooltips));
@@ -110,9 +110,9 @@ public final class OptionGroupImpl implements OptionGroup {
public OptionGroup build() {
Validate.notEmpty(options, "`options` must not be empty to build `OptionGroup`");
- MutableText concatenatedTooltip = Text.empty();
+ MutableComponent concatenatedTooltip = Component.empty();
boolean first = true;
- for (Text line : tooltipLines) {
+ for (Component line : tooltipLines) {
if (!first) concatenatedTooltip.append("\n");
first = false;
diff --git a/src/client/java/dev/isxander/yacl/impl/OptionImpl.java b/src/client/java/dev/isxander/yacl/impl/OptionImpl.java
index d2815e1..d333e36 100644
--- a/src/client/java/dev/isxander/yacl/impl/OptionImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/OptionImpl.java
@@ -5,9 +5,9 @@ import dev.isxander.yacl.api.Binding;
import dev.isxander.yacl.api.Controller;
import dev.isxander.yacl.api.Option;
import dev.isxander.yacl.api.OptionFlag;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
+import net.minecraft.ChatFormatting;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -22,8 +22,8 @@ import java.util.stream.Stream;
@ApiStatus.Internal
public final class OptionImpl<T> implements Option<T> {
- private final Text name;
- private Text tooltip;
+ private final Component name;
+ private Component tooltip;
private final Controller<T> controller;
private final Binding<T> binding;
private boolean available;
@@ -37,8 +37,8 @@ public final class OptionImpl<T> implements Option<T> {
private final List<BiConsumer<Option<T>, T>> listeners;
public OptionImpl(
- @NotNull Text name,
- @Nullable Function<T, Text> tooltipGetter,
+ @NotNull Component name,
+ @Nullable Function<T, Component> tooltipGetter,
@NotNull Function<Option<T>, Controller<T>> controlGetter,
@NotNull Binding<T> binding,
boolean available,
@@ -59,12 +59,12 @@ public final class OptionImpl<T> implements Option<T> {
}
@Override
- public @NotNull Text name() {
+ public @NotNull Component name() {
return name;
}
@Override
- public @NotNull Text tooltip() {
+ public @NotNull Component tooltip() {
return tooltip;
}
@@ -145,9 +145,9 @@ public final class OptionImpl<T> implements Option<T> {
@ApiStatus.Internal
public static class BuilderImpl<T> implements Option.Builder<T> {
- private Text name = Text.literal("Name not specified!").formatted(Formatting.RED);
+ private Component name = Component.literal("Name not specified!").withStyle(ChatFormatting.RED);
- private final List<Function<T, Text>> tooltipGetters = new ArrayList<>();
+ private final List<Function<T, Component>> tooltipGetters = new ArrayList<>();
private Function<Option<T>, Controller<T>> controlGetter;
@@ -168,7 +168,7 @@ public final class OptionImpl<T> implements Option<T> {
}
@Override
- public Option.Builder<T> name(@NotNull Text name) {
+ public Option.Builder<T> name(@NotNull Component name) {
Validate.notNull(name, "`name` cannot be null");
this.name = name;
@@ -177,7 +177,7 @@ public final class OptionImpl<T> implements Option<T> {
@Override
@SafeVarargs
- public final Option.Builder<T> tooltip(@NotNull Function<T, Text>... tooltipGetter) {
+ public final Option.Builder<T> tooltip(@NotNull Function<T, Component>... tooltipGetter) {
Validate.notNull(tooltipGetter, "`tooltipGetter` cannot be null");
this.tooltipGetters.addAll(List.of(tooltipGetter));
@@ -185,10 +185,10 @@ public final class OptionImpl<T> implements Option<T> {
}
@Override
- public Option.Builder<T> tooltip(@NotNull Text... tooltips) {
+ public Option.Builder<T> tooltip(@NotNull Component... tooltips) {
Validate.notNull(tooltips, "`tooltips` cannot be empty");
- this.tooltipGetters.addAll(Stream.of(tooltips).map(text -> (Function<T, Text>) t -> text).toList());
+ this.tooltipGetters.addAll(Stream.of(tooltips).map(Component -> (Function<T, Component>) t -> Component).toList());
return this;
}
@@ -264,10 +264,10 @@ public final class OptionImpl<T> implements Option<T> {
Validate.notNull(binding, "`binding` must not be null when building `Option`");
Validate.isTrue(!instant || flags.isEmpty(), "instant application does not support option flags");
- Function<T, Text> concatenatedTooltipGetter = value -> {
- MutableText concatenatedTooltip = Text.empty();
+ Function<T, Component> concatenatedTooltipGetter = value -> {
+ MutableComponent concatenatedTooltip = Component.empty();
boolean first = true;
- for (Function<T, Text> line : tooltipGetters) {
+ for (Function<T, Component> line : tooltipGetters) {
if (!first) concatenatedTooltip.append("\n");
first = false;
diff --git a/src/client/java/dev/isxander/yacl/impl/PlaceholderCategoryImpl.java b/src/client/java/dev/isxander/yacl/impl/PlaceholderCategoryImpl.java
index 738b9e2..0b77466 100644
--- a/src/client/java/dev/isxander/yacl/impl/PlaceholderCategoryImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/PlaceholderCategoryImpl.java
@@ -1,14 +1,13 @@
package dev.isxander.yacl.impl;
import com.google.common.collect.ImmutableList;
-import dev.isxander.yacl.api.ConfigCategory;
import dev.isxander.yacl.api.OptionGroup;
import dev.isxander.yacl.api.PlaceholderCategory;
import dev.isxander.yacl.gui.YACLScreen;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -19,11 +18,11 @@ import java.util.function.BiFunction;
@ApiStatus.Internal
public final class PlaceholderCategoryImpl implements PlaceholderCategory {
- private final Text name;
- private final BiFunction<MinecraftClient, YACLScreen, Screen> screen;
- private final Text tooltip;
+ private final Component name;
+ private final BiFunction<Minecraft, YACLScreen, Screen> screen;
+ private final Component tooltip;
- public PlaceholderCategoryImpl(Text name, BiFunction<MinecraftClient, YACLScreen, Screen> screen, Text tooltip) {
+ public PlaceholderCategoryImpl(Component name, BiFunction<Minecraft, YACLScreen, Screen> screen, Component tooltip) {
this.name = name;
this.screen = screen;
this.tooltip = tooltip;
@@ -35,30 +34,30 @@ public final class PlaceholderCategoryImpl implements PlaceholderCategory {
}
@Override
- public @NotNull Text name() {
+ public @NotNull Component name() {
return name;
}
@Override
- public BiFunction<MinecraftClient, YACLScreen, Screen> screen() {
+ public BiFunction<Minecraft, YACLScreen, Screen> screen() {
return screen;
}
@Override
- public @NotNull Text tooltip() {
+ public @NotNull Component tooltip() {
return tooltip;
}
@ApiStatus.Internal
public static final class BuilderImpl implements PlaceholderCategory.Builder {
- private Text name;
+ private Component name;
- private final List<Text> tooltipLines = new ArrayList<>();
+ private final List<Component> tooltipLines = new ArrayList<>();
- private BiFunction<MinecraftClient, YACLScreen, Screen> screenFunction;
+ private BiFunction<Minecraft, YACLScreen, Screen> screenFunction;
@Override
- public Builder name(@NotNull Text name) {
+ public Builder name(@NotNull Component name) {
Validate.notNull(name, "`name` cannot be null");
this.name = name;
@@ -66,7 +65,7 @@ public final class PlaceholderCategoryImpl implements PlaceholderCategory {
}
@Override
- public Builder tooltip(@NotNull Text... tooltips) {
+ public Builder tooltip(@NotNull Component... tooltips) {
Validate.notEmpty(tooltips, "`tooltips` cannot be empty");
tooltipLines.addAll(List.of(tooltips));
@@ -74,7 +73,7 @@ public final class PlaceholderCategoryImpl implements PlaceholderCategory {
}
@Override
- public Builder screen(@NotNull BiFunction<MinecraftClient, YACLScreen, Screen> screenFunction) {
+ public Builder screen(@NotNull BiFunction<Minecraft, YACLScreen, Screen> screenFunction) {
Validate.notNull(screenFunction, "`screenFunction` cannot be null");
this.screenFunction = screenFunction;
@@ -85,9 +84,9 @@ public final class PlaceholderCategoryImpl implements PlaceholderCategory {
public PlaceholderCategory build() {
Validate.notNull(name, "`name` must not be null to build `ConfigCategory`");
- MutableText concatenatedTooltip = Text.empty();
+ MutableComponent concatenatedTooltip = Component.empty();
boolean first = true;
- for (Text line : tooltipLines) {
+ for (Component line : tooltipLines) {
if (!first) concatenatedTooltip.append("\n");
first = false;
diff --git a/src/client/java/dev/isxander/yacl/impl/YetAnotherConfigLibImpl.java b/src/client/java/dev/isxander/yacl/impl/YetAnotherConfigLibImpl.java
index 576c1bf..21c776a 100644
--- a/src/client/java/dev/isxander/yacl/impl/YetAnotherConfigLibImpl.java
+++ b/src/client/java/dev/isxander/yacl/impl/YetAnotherConfigLibImpl.java
@@ -6,8 +6,8 @@ import dev.isxander.yacl.api.PlaceholderCategory;
import dev.isxander.yacl.api.YetAnotherConfigLib;
import dev.isxander.yacl.gui.YACLScreen;
import dev.isxander.yacl.impl.utils.YACLConstants;
-import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.text.Text;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.Component;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -15,19 +15,18 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Objects;
import java.util.function.Consumer;
@ApiStatus.Internal
public final class YetAnotherConfigLibImpl implements YetAnotherConfigLib {
- private final Text title;
+ private final Component title;
private final ImmutableList<ConfigCategory> categories;
private final Runnable saveFunction;
private final Consumer<YACLScreen> initConsumer;
private boolean generated = false;
- public YetAnotherConfigLibImpl(Text title, ImmutableList<ConfigCategory> categories, Runnable saveFunction, Consumer<YACLScreen> initConsumer) {
+ public YetAnotherConfigLibImpl(Component title, ImmutableList<ConfigCategory> categories, Runnable saveFunction, Consumer<YACLScreen> initConsumer) {
this.title = title;
this.categories = categories;
this.saveFunction = saveFunction;
@@ -45,7 +44,7 @@ public final class YetAnotherConfigLibImpl implements YetAnotherConfigLib {
}
@Override
- public Text title() {
+ public Component title() {
return title;
}
@@ -66,13 +65,13 @@ public final class YetAnotherConfigLibImpl implements YetAnotherConfigLib {
@ApiStatus.Internal
public static final class BuilderImpl implements YetAnotherConfigLib.Builder {
- private Text title;
+ private Component title;
private final List<ConfigCategory> categories = new ArrayList<>();
private Runnable saveFunction = () -> {};
private Consumer<YACLScreen> initConsumer = screen -> {};
@Override
- public YetAnotherConfigLib.Builder title(@NotNull Text title) {
+ public YetAnotherConfigLib.Builder title(@NotNull Component title) {
Validate.notNull(title, "`title` cannot be null");
this.title = title;