/
MechworksConfig.java
104 lines (80 loc) · 4.02 KB
/
MechworksConfig.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package slimeknights.tmechworks.common.config;
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import net.minecraftforge.common.ForgeConfigSpec;
import slimeknights.tmechworks.TMechworks;
import slimeknights.tmechworks.library.Util;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
public class MechworksConfig {
public static final Path CONFIG_PATH = Paths.get(TMechworks.CONFIG_ROOT.toString(), "Config.toml");
public static void load() {
CommentedFileConfig config = CommentedFileConfig.builder(CONFIG_PATH).build();
config.load();
SPEC.setConfig(config);
}
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
public static final WorldGeneration WORLD_GENERATION = new WorldGeneration();
public static final class WorldGeneration {
public final ForgeConfigSpec.BooleanValue enabled;
public final Ore COPPER = new Ore("copper");
public final Ore ALUMINUM = new Ore("aluminum");
WorldGeneration() {
BUILDER.push("world");
enabled = BUILDER
.comment("Whether world generation is enabled as a whole")
.define("enabled", true);
BUILDER.pop();
}
public static class Ore {
public ForgeConfigSpec.BooleanValue enabled;
public ForgeConfigSpec.BooleanValue isWhitelist;
public ForgeConfigSpec.ConfigValue<List<? extends String>> filter;
Ore(String name) {
this(name, true);
}
Ore(String name, boolean onByDefault) {
this(name, onByDefault, false, Collections.emptyList());
}
Ore(String name, boolean onByDefault, boolean isWhitelist, List<String> filter) {
BUILDER.push("world." + name);
enabled = BUILDER
.comment("Whether or not this ore is generated")
.define("enabled", onByDefault);
this.isWhitelist = BUILDER
.comment("If true, the filter will act as a whitelist, otherwise, blacklist")
.define("isWhitelist", isWhitelist);
this.filter = BUILDER
.comment("A list of fully qualified biome names, for example \"minecraft:river\"")
.defineList("filter", filter, (obj) -> obj != null && Util.validateResourceName(obj.toString()));
BUILDER.pop(2);
}
}
}
public static final Drawbridge DRAWBRIDGE = new Drawbridge();
public static final class Drawbridge {
public final ForgeConfigSpec.IntValue extendLength;
public final ForgeConfigSpec.IntValue extendUpgradeValue;
public final ForgeConfigSpec.DoubleValue delay;
public final ForgeConfigSpec.DoubleValue speedUpgradeValue;
Drawbridge() {
BUILDER.push("drawbridge");
extendLength = BUILDER
.comment("Total drawbridge distance (with upgrades) going above 66 in an advanced drawbridge may cause slots to overlap with player inventory slots")
.comment("The distance that the base drawbridge can extend")
.defineInRange("extendLength", 16, 1, 64);
extendUpgradeValue = BUILDER
.comment("How much each distance upgrade increases the max distance by")
.defineInRange("extendUpgradeValue", 16, 0, 64);
delay = BUILDER
.comment("The base delay between each block place/destroy")
.defineInRange("delay", 0.5D, 0F, Integer.MAX_VALUE);
speedUpgradeValue = BUILDER
.comment("The amount by which each speed upgrade decreases the delay")
.defineInRange("speedUpgradeValue", 0.1D, 0F, Integer.MAX_VALUE);
BUILDER.pop();
}
}
private static final ForgeConfigSpec SPEC = BUILDER.build();
}