]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/config/ConfigManager.java
Fully stop needing config on BoundingBoxType
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / config / ConfigManager.java
1 package com.irtimaled.bbor.config;
2
3 import java.io.File;
4 import java.util.HashSet;
5 import java.util.Set;
6
7 public class ConfigManager {
8     private static final Set<Setting<?>> settings = new HashSet<>();
9     public static File configDir;
10
11     public static Setting<Boolean> fill;
12     public static Setting<Boolean> drawVillages;
13     public static Setting<Boolean> drawDesertTemples;
14     public static Setting<Boolean> drawJungleTemples;
15     public static Setting<Boolean> drawWitchHuts;
16     public static Setting<Boolean> drawStrongholds;
17     public static Setting<Boolean> drawMineShafts;
18     public static Setting<Boolean> drawNetherFortresses;
19     public static Setting<Boolean> drawOceanMonuments;
20     public static Setting<Boolean> alwaysVisible;
21     public static Setting<Boolean> drawIronGolemSpawnArea;
22     public static Setting<Boolean> drawVillageDoors;
23     public static Setting<Boolean> drawSlimeChunks;
24     public static Setting<Integer> slimeChunkMaxY;
25     public static Setting<Boolean> keepCacheBetweenSessions;
26     public static Setting<Boolean> drawWorldSpawn;
27     public static Setting<Integer> worldSpawnMaxY;
28     public static Setting<Boolean> drawLazySpawnChunks;
29     public static Setting<Boolean> drawEndCities;
30     public static Setting<Boolean> drawMansions;
31     public static Setting<Boolean> drawShipwrecks;
32     public static Setting<Boolean> drawOceanRuins;
33     public static Setting<Boolean> drawBuriedTreasure;
34     public static Setting<Boolean> drawIgloos;
35     public static Setting<Boolean> drawMobSpawners;
36     public static Setting<Boolean> renderMobSpawnerSpawnArea;
37     public static Setting<Boolean> renderMobSpawnerActivationLines;
38     public static Setting<Boolean> drawPillagerOutposts;
39     public static Setting<Boolean> outerBoxesOnly;
40     public static Setting<Integer> villageSphereDotSize;
41     public static Setting<Integer> villageSphereDensity;
42     public static Setting<Boolean> drawVillageSpheres;
43     public static Setting<Boolean> drawAFKSpheres;
44     public static Setting<Boolean> renderAFKSpawnableBlocks;
45     public static Setting<Integer> afkSpawnableBlocksRenderDistance;
46     public static Setting<Boolean> drawBeacons;
47     public static Setting<Boolean> drawBiomeBorders;
48     public static Setting<Boolean> renderOnlyCurrentBiome;
49     public static Setting<Integer> biomeBordersRenderDistance;
50     public static Setting<Integer> biomeBordersMaxY;
51     public static Setting<Boolean> drawNetherFossils;
52     public static Setting<Boolean> drawBastionRemnants;
53     public static Setting<Boolean> drawRuinedPortals;
54     public static Setting<Boolean> drawConduits;
55     public static Setting<Boolean> renderConduitMobHarmArea;
56
57     public static void loadConfig(File mcConfigDir) {
58         configDir = new File(mcConfigDir, "config");
59         configDir.mkdirs();
60         Configuration config = loadConfig();
61
62         fill = setup(config, "general", "fill", true, "If set to true the bounding boxes are filled.");
63         outerBoxesOnly = setup(config, "general", "outerBoxesOnly", false, "If set to true only the outer bounding boxes are rendered.");
64         alwaysVisible = setup(config, "general", "alwaysVisible", false, "If set to true boxes will be visible even through other blocks.");
65         keepCacheBetweenSessions = setup(config, "general", "keepCacheBetweenSessions", false, "If set to true bounding box caches will be kept between sessions.");
66
67         drawBeacons = setup(config, "beacons", "drawBeacons", true, "If set to true beacon bounding boxes will be drawn.");
68
69         drawConduits = setup(config, "conduits", "drawConduits", true, "If set to true conduit bounding spheres will be drawn.");
70         renderConduitMobHarmArea = setup(config, "conduits", "renderConduitMobHarmArea", true, "If set to true a box to show the area where hostile mobs are harmed will be drawn");
71
72         drawBiomeBorders = setup(config, "biomeBorders", "drawBiomeBorders", true, "If set to true biome borders will be drawn.");
73         renderOnlyCurrentBiome = setup(config, "biomeBorders", "renderOnlyCurrentBiome", true, "If set to true only the biome border for the current biome will be drawn.");
74         biomeBordersRenderDistance = setup(config, "biomeBorders", "biomeBordersRenderDistance", 3, "The distance from the player where biome borders will be drawn.");
75         biomeBordersMaxY = setup(config, "biomeBorders", "biomeBordersMaxY", -1, "The maximum top of the biome borders. If set to -1 it will use the value when activated, if set to 0 it will always track the players feet.");
76
77         drawVillageSpheres = setup(config, "villages", "drawVillageSpheres", true, "If set to true village bounding spheres are drawn.");
78         drawIronGolemSpawnArea = setup(config, "villages", "drawIronGolemSpawnArea", true, "If set to true the iron golem spawn area of the village will be drawn. (default:true)");
79         drawVillageDoors = setup(config, "villages", "drawVillageDoors", false, "If set to true lines between the village centre and doors will be drawn. (default:false)");
80         villageSphereDotSize = setup(config, "villages", "villageSphereDotSize", 2, "The size of the dots used when rendering village as sphere.");
81         villageSphereDensity = setup(config, "villages", "villageSphereDensity", 3, "The density of the dots used when rendering village as sphere.");
82
83         drawVillages = setup(config, "structures", "drawVillages", false, "If set to true village bounding boxes will be drawn.");
84         drawDesertTemples = setup(config, "structures", "drawDesertTemples", true, "If set to true desert temple bounding boxes are drawn.");
85         drawJungleTemples = setup(config, "structures", "drawJungleTemples", true, "If set to true jungle temple bounding boxes are drawn.");
86         drawWitchHuts = setup(config, "structures", "drawWitchHuts", true, "If set to true witch hut bounding boxes are drawn.");
87         drawStrongholds = setup(config, "structures", "drawStrongholds", false, "If set to true stronghold bounding boxes are drawn.");
88         drawMineShafts = setup(config, "structures", "drawMineShafts", false, "If set to true mineshaft bounding boxes are drawn.");
89         drawNetherFortresses = setup(config, "structures", "drawNetherFortresses", true, "If set to true nether fortress bounding boxes are drawn.");
90         drawOceanMonuments = setup(config, "structures", "drawOceanMonuments", true, "If set to true ocean monument bounding boxes are drawn.");
91         drawEndCities = setup(config, "structures", "drawEndCities", true, "If set to true end city bounding boxes will be drawn.");
92         drawMansions = setup(config, "structures", "drawMansions", true, "If set to true woodland mansions will be drawn.");
93         drawIgloos = setup(config, "structures", "drawIgloos", true, "If set to true igloos will be drawn.");
94         drawShipwrecks = setup(config, "structures", "drawShipwrecks", true, "If set to true shipwrecks will be drawn.");
95         drawOceanRuins = setup(config, "structures", "drawOceanRuins", true, "If set to true ocean ruins will be drawn.");
96         drawBuriedTreasure = setup(config, "structures", "drawBuriedTreasures", true, "If set to true buried treasure will be drawn.");
97         drawPillagerOutposts = setup(config, "structures", "drawPillagerOutposts", true, "If set to true pillager outposts will be drawn.");
98         drawNetherFossils = setup(config, "structures", "drawNetherFossils", true, "If set to true nether fossils will be drawn.");
99         drawBastionRemnants = setup(config, "structures", "drawBastionRemnants", true, "If set to true bastion remnants will be drawn.");
100         drawRuinedPortals = setup(config, "structures", "drawRuinedPortals", true, "If set to true ruined portals will be drawn.");
101
102         drawSlimeChunks = setup(config, "slimeChunks", "drawSlimeChunks", true, "If set to true slime chunks bounding boxes are drawn.");
103         slimeChunkMaxY = setup(config, "slimeChunks", "slimeChunkMaxY", -1, "The maximum top of the slime chunk bounding box. If set to -1 it will use the value when activated, if set to 0 it will always track the player's feet.");
104
105         drawWorldSpawn = setup(config, "worldSpawn", "drawWorldSpawn", true, "If set to true world spawn and spawn chunks bounding boxes are drawn.");
106         worldSpawnMaxY = setup(config, "worldSpawn", "worldSpawnMaxY", -1, "The maximum top of the world spawn bounding boxes. If set to -1 it will use the value when activated, if set to 0 it will always track the players feet.");
107         drawLazySpawnChunks = setup(config, "worldSpawn", "drawLazySpawnChunks", false, "If set to true the lazy spawn chunks bounding boxes will be drawn.");
108
109         drawMobSpawners = setup(config, "mobSpawners", "drawMobSpawners", true, "If set to true mob spawners will be drawn.");
110         renderMobSpawnerSpawnArea = setup(config, "mobSpawners", "renderMobSpawnerSpawnArea", true, "If set to true a box to show the maximum possible spawn area (10x10x4) for a spawner will be drawn");
111         renderMobSpawnerActivationLines = setup(config, "mobSpawners", "renderMobSpawnerActivationLines", true, "If set to true a red/orange/green line will be drawn to show if the spawner is active");
112
113         drawAFKSpheres = setup(config, "afkSpot", "drawAFKSpheres", true, "If set to true afk spot spheres will be drawn.");
114         renderAFKSpawnableBlocks = setup(config, "afkSpot", "renderAFKSpawnableBlocks", true, "If set to true boxes to show spawnable blocks within the AFK sphere will be drawn.");
115         afkSpawnableBlocksRenderDistance = setup(config, "afkSpot", "afkSpawnableBlocksRenderDistance", 3, "The distance from the player where spawnable blocks within the AFK sphere will be drawn.");
116
117         config.save();
118     }
119
120     private static Configuration loadConfig() {
121         Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
122         config.load();
123         return config;
124     }
125
126     public static void saveConfig() {
127         Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
128         for (Setting<?> setting : settings) {
129             config.put(setting);
130         }
131         config.save();
132     }
133
134     private static <T> Setting<T> setup(Configuration config, String category, String settingName, T defaultValue, String comment) {
135         Setting<T> setting = config.get(category, settingName, defaultValue);
136         setting.category = category;
137         setting.name = settingName;
138         setting.comment = comment + " (default: " + defaultValue.toString() + ")";
139         settings.add(setting);
140         return setting;
141     }
142
143     public static void Toggle(Setting<Boolean> setting) {
144         setting.set(!setting.get());
145     }
146
147     public static Set<Setting<?>> getSettings() {
148         return settings;
149     }
150 }