Skip to content

Commit 74bcc11

Browse files
committed
2.4.1
1 parent 257a50d commit 74bcc11

8 files changed

Lines changed: 56 additions & 6 deletions

File tree

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plugins {
1616
val ciRun = System.getenv().containsKey("GITHUB_ACTIONS")
1717

1818
group = "dev.isxander"
19-
version = "2.4.0"
19+
version = "2.4.1"
2020

2121
if (ciRun)
2222
version = "$version+${grgit.branch.current().name.replace('/', '.')}-SNAPSHOT"
@@ -192,6 +192,7 @@ publishing {
192192
artifactId = "yet-another-config-lib"
193193

194194
from(components["java"])
195+
artifact(tasks["remapSourcesJar"])
195196
}
196197
}
197198

changelogs/2.4.1.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Features
2+
3+
- `OptionGroup.Builder` and `ConfigCategory.Builder` now extend `OptionAddable` so you can abstractly
4+
add options to either of them.
5+
6+
## API Changes
7+
8+
- Deprecated the varargs tooltip builder method in `Option.Builder` due to unsafe varargs. There is now
9+
an equivalent that is not varargs but a single function.

src/client/java/dev/isxander/yacl/api/ConfigCategory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static Builder createBuilder() {
3636
return new ConfigCategoryImpl.BuilderImpl();
3737
}
3838

39-
interface Builder {
39+
interface Builder extends OptionAddable {
4040
/**
4141
* Sets name of the category
4242
*
@@ -52,6 +52,7 @@ interface Builder {
5252
* @see ConfigCategory#groups()
5353
* @see OptionGroup#isRoot()
5454
*/
55+
@Override
5556
Builder option(@NotNull Option<?> option);
5657

5758
/**
@@ -62,7 +63,8 @@ interface Builder {
6263
* @see ConfigCategory#groups()
6364
* @see OptionGroup#isRoot()
6465
*/
65-
Builder options(@NotNull Collection<Option<?>> options);
66+
@Override
67+
Builder options(@NotNull Collection<? extends Option<?>> options);
6668

6769
/**
6870
* Adds an option group.

src/client/java/dev/isxander/yacl/api/Option.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,15 @@ interface Builder<T> {
132132
*
133133
* @param tooltipGetter function to get tooltip depending on value {@link Builder#build()}.
134134
*/
135-
@SuppressWarnings("unchecked")
135+
Builder<T> tooltip(@NotNull Function<T, Component> tooltipGetter);
136+
137+
/**
138+
* Sets the tooltip to be used by the option.
139+
* No need to wrap the text yourself, the gui does this itself.
140+
*
141+
* @param tooltipGetter function to get tooltip depending on value {@link Builder#build()}.
142+
*/
143+
@Deprecated
136144
Builder<T> tooltip(@NotNull Function<T, Component>... tooltipGetter);
137145

138146
/**
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package dev.isxander.yacl.api;
2+
3+
import org.jetbrains.annotations.NotNull;
4+
5+
import java.util.Collection;
6+
7+
public interface OptionAddable {
8+
/**
9+
* Adds an option to an abstract builder.
10+
* To construct an option, use {@link Option#createBuilder(Class)}
11+
*/
12+
OptionAddable option(@NotNull Option<?> option);
13+
14+
/**
15+
* Adds multiple options to an abstract builder.
16+
* To construct an option, use {@link Option#createBuilder(Class)}
17+
*/
18+
OptionAddable options(@NotNull Collection<? extends Option<?>> options);
19+
}

src/client/java/dev/isxander/yacl/api/OptionGroup.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static Builder createBuilder() {
4747
return new OptionGroupImpl.BuilderImpl();
4848
}
4949

50-
interface Builder {
50+
interface Builder extends OptionAddable {
5151
/**
5252
* Sets name of the group, can be {@link Component#empty()} to just separate options, like sodium.
5353
*
@@ -70,6 +70,7 @@ interface Builder {
7070
*
7171
* @see OptionGroup#options()
7272
*/
73+
@Override
7374
Builder option(@NotNull Option<?> option);
7475

7576
/**
@@ -78,6 +79,7 @@ interface Builder {
7879
*
7980
* @see OptionGroup#options()
8081
*/
82+
@Override
8183
Builder options(@NotNull Collection<? extends Option<?>> options);
8284

8385
/**

src/client/java/dev/isxander/yacl/impl/ConfigCategoryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public Builder option(@NotNull Option<?> option) {
7474
}
7575

7676
@Override
77-
public Builder options(@NotNull Collection<Option<?>> options) {
77+
public Builder options(@NotNull Collection<? extends Option<?>> options) {
7878
Validate.notNull(options, "`options` must not be null");
7979

8080
if (options.stream().anyMatch(ListOption.class::isInstance))

src/client/java/dev/isxander/yacl/impl/OptionImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,17 @@ public Option.Builder<T> name(@NotNull Component name) {
175175
return this;
176176
}
177177

178+
@Override
179+
public Builder<T> tooltip(@NotNull Function<T, Component> tooltipGetter) {
180+
Validate.notNull(tooltipGetter, "`tooltipGetter` cannot be null");
181+
182+
this.tooltipGetters.add(tooltipGetter);
183+
return this;
184+
}
185+
178186
@Override
179187
@SafeVarargs
188+
@Deprecated
180189
public final Option.Builder<T> tooltip(@NotNull Function<T, Component>... tooltipGetter) {
181190
Validate.notNull(tooltipGetter, "`tooltipGetter` cannot be null");
182191

0 commit comments

Comments
 (0)