-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathGuideConfig.java
More file actions
52 lines (40 loc) · 2.09 KB
/
GuideConfig.java
File metadata and controls
52 lines (40 loc) · 2.09 KB
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
package amerifrance.guideapi;
import amerifrance.guideapi.api.GuideAPI;
import amerifrance.guideapi.api.impl.Book;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.commons.lang3.tuple.Pair;
import java.util.HashMap;
import java.util.Map;
public class GuideConfig {
/**
* For side independent configuration. Not synced.
* Loaded after registry events but before setup
*/
public static Common COMMON;
public static class Common {
public final ForgeConfigSpec.BooleanValue canSpawnWithBook;
public final ForgeConfigSpec.BooleanValue enableLogging;
public final Map<Book, ForgeConfigSpec.BooleanValue> SPAWN_BOOKS = new HashMap<>();
Common(ForgeConfigSpec.Builder builder) {
builder.comment("Common configurations settings").push("common");
enableLogging = builder.comment("Enables extra information being printed to the console.").define("enableLogging", true);
canSpawnWithBook = builder.comment("Allows books to spawn with new players.\nThis is a global override for all books if set to false.").define("canSpawnWithBook", true);
builder.comment("If the player should spawn with this book").push("spawnBook");
for (Book book : GuideAPI.getBooks().values()) {
SPAWN_BOOKS.put(book, builder.define(book.getRegistryName().getNamespace() + "-" + book.getRegistryName().getPath(), book.shouldSpawnWithBook()));
}
builder.pop();
builder.pop();
}
}
public static void buildConfiguration() {
final Pair<Common, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(Common::new);
ForgeConfigSpec commonSpec = specPair.getRight();
COMMON = specPair.getLeft();
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, commonSpec);
FMLJavaModLoadingContext.get().getModEventBus().register(GuideConfig.class);
}
}