generated from kikugie/mod-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExtendedOptions.java
60 lines (51 loc) · 3.24 KB
/
ExtendedOptions.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package dev.kikugie.commandconfig.api.option;
import com.mojang.brigadier.arguments.*;
import dev.kikugie.commandconfig.api.builders.ListOptionBuilder;
import dev.kikugie.commandconfig.api.builders.OptionBuilder;
import dev.kikugie.commandconfig.impl.command.CustomEnumArgumentType;
import dev.kikugie.commandconfig.impl.command.ListArgumentType;
import dev.kikugie.commandconfig.impl.option.GenericOptionBuilderImpl;
import dev.kikugie.commandconfig.impl.option.ListOptionBuilderImpl;
import net.minecraft.command.CommandSource;
import net.minecraft.util.StringIdentifiable;
import java.util.List;
/**
* Wrappers for complex options.
*/
@SuppressWarnings("unused")
public class ExtendedOptions {
/**
* Creates an enum option builder. Passed enum must implement {@link StringIdentifiable}.
*
* @param name Option name. Cannot contain spaces
* @param enumArg Target enum class
* @param type {@link CommandSource} class reference, passed from top level node
*/
public static <T extends Enum<T> & StringIdentifiable, S extends CommandSource> OptionBuilder<T, S> enumArg(String name, Class<T> enumArg, Class<S> type) {
return new GenericOptionBuilderImpl<>(name, CustomEnumArgumentType.enumArg(enumArg), enumArg, type);
}
public static <L extends List<Integer>, S extends CommandSource> ListOptionBuilder<L, Integer, S> intList(String name, Class<S> type) {
IntegerArgumentType argumentType = IntegerArgumentType.integer();
return new ListOptionBuilderImpl<>(name, ListArgumentType.list(argumentType), argumentType, Integer.class, type);
}
public static <L extends List<Long>, S extends CommandSource> ListOptionBuilder<L, Long, S> longList(String name, Class<S> type) {
LongArgumentType argumentType = LongArgumentType.longArg();
return new ListOptionBuilderImpl<>(name, ListArgumentType.list(argumentType), argumentType, Long.class, type);
}
public static <L extends List<Float>, S extends CommandSource> ListOptionBuilder<L, Float, S> floatList(String name, Class<S> type) {
FloatArgumentType argumentType = FloatArgumentType.floatArg();
return new ListOptionBuilderImpl<>(name, ListArgumentType.list(argumentType), argumentType, Float.class, type);
}
public static <L extends List<Double>, S extends CommandSource> ListOptionBuilder<L, Double, S> doubleList(String name, Class<S> type) {
DoubleArgumentType argumentType = DoubleArgumentType.doubleArg();
return new ListOptionBuilderImpl<>(name, ListArgumentType.list(argumentType), argumentType, Double.class, type);
}
public static <L extends List<String>, S extends CommandSource> ListOptionBuilder<L, String, S> stringList(String name, Class<S> type) {
StringArgumentType argumentType = StringArgumentType.word();
return new ListOptionBuilderImpl<>(name, ListArgumentType.list(argumentType), argumentType, String.class, type);
}
public static <L extends List<String>, S extends CommandSource> ListOptionBuilder<L, String, S> quotedStringList(String name, Class<S> type) {
StringArgumentType argumentType = StringArgumentType.string();
return new ListOptionBuilderImpl<>(name, ListArgumentType.list(argumentType), argumentType, String.class, type);
}
}