]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/config/ConfigManager.java
Add BedrockCeiling boxes
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / config / ConfigManager.java
1 package com.irtimaled.bbor.client.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     private 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> drawSlimeChunks;
22     public static Setting<Integer> slimeChunkMaxY;
23     public static Setting<Boolean> keepCacheBetweenSessions;
24     public static Setting<Boolean> drawWorldSpawn;
25     public static Setting<Integer> worldSpawnMaxY;
26     public static Setting<Boolean> drawLazySpawnChunks;
27     public static Setting<Boolean> drawEndCities;
28     public static Setting<Boolean> drawMansions;
29     public static Setting<Boolean> drawShipwrecks;
30     public static Setting<Boolean> drawOceanRuins;
31     public static Setting<Boolean> drawBuriedTreasure;
32     public static Setting<Boolean> drawIgloos;
33     public static Setting<Boolean> drawMobSpawners;
34     public static Setting<Boolean> renderMobSpawnerSpawnArea;
35     public static Setting<Boolean> renderMobSpawnerActivationLines;
36     public static Setting<Boolean> drawPillagerOutposts;
37     public static Setting<Boolean> outerBoxesOnly;
38     public static Setting<Boolean> drawAFKSpheres;
39     public static Setting<Boolean> renderAFKSpawnableBlocks;
40     public static Setting<Integer> afkSpawnableBlocksRenderDistance;
41     public static Setting<Boolean> drawBeacons;
42     public static Setting<Boolean> drawBiomeBorders;
43     public static Setting<Boolean> renderOnlyCurrentBiome;
44     public static Setting<Integer> biomeBordersRenderDistance;
45     public static Setting<Integer> biomeBordersMaxY;
46     public static Setting<Boolean> drawNetherFossils;
47     public static Setting<Boolean> drawBastionRemnants;
48     public static Setting<Boolean> drawRuinedPortals;
49     public static Setting<Boolean> drawConduits;
50     public static Setting<Boolean> renderConduitMobHarmArea;
51     public static Setting<Boolean> drawSpawnableBlocks;
52     public static Setting<Integer> spawnableBlocksRenderWidth;
53     public static Setting<Integer> spawnableBlocksRenderHeight;
54     public static Setting<Boolean> invertBoxColorPlayerInside;
55     public static Setting<Boolean> renderSphereAsDots;
56     public static Setting<Boolean> drawFlowerForests;
57     public static Setting<Integer> flowerForestsRenderDistance;
58     public static Setting<Boolean> drawBedrockCeilingBlocks;
59
60     public static Setting<HexColor> colorWorldSpawn;
61     public static Setting<HexColor> colorLazySpawnChunks;
62     public static Setting<HexColor> colorMobSpawners;
63     public static Setting<HexColor> colorMobSpawnersLineFarAway;
64     public static Setting<HexColor> colorMobSpawnersLineNearby;
65     public static Setting<HexColor> colorMobSpawnersLineActive;
66     public static Setting<HexColor> colorSlimeChunks;
67     public static Setting<HexColor> colorAFKSpheres;
68     public static Setting<HexColor> colorAFKSpheresSafeArea;
69     public static Setting<HexColor> colorBiomeBorders;
70     public static Setting<HexColor> colorBeacons;
71     public static Setting<HexColor> colorCustom;
72     public static Setting<HexColor> colorConduits;
73     public static Setting<HexColor> colorConduitMobHarmArea;
74     public static Setting<HexColor> colorSpawnableBlocks;
75     public static Setting<HexColor> colorJungleTemples;
76     public static Setting<HexColor> colorDesertTemples;
77     public static Setting<HexColor> colorWitchHuts;
78     public static Setting<HexColor> colorOceanMonuments;
79     public static Setting<HexColor> colorShipwrecks;
80     public static Setting<HexColor> colorOceanRuins;
81     public static Setting<HexColor> colorBuriedTreasure;
82     public static Setting<HexColor> colorStrongholds;
83     public static Setting<HexColor> colorMineShafts;
84     public static Setting<HexColor> colorNetherFortresses;
85     public static Setting<HexColor> colorEndCities;
86     public static Setting<HexColor> colorMansions;
87     public static Setting<HexColor> colorIgloos;
88     public static Setting<HexColor> colorPillagerOutposts;
89     public static Setting<HexColor> colorVillages;
90     public static Setting<HexColor> colorNetherFossils;
91     public static Setting<HexColor> colorBastionRemnants;
92     public static Setting<HexColor> colorRuinedPortals;
93     public static Setting<HexColor> colorFlowerForestDandelion;
94     public static Setting<HexColor> colorFlowerForestPoppy;
95     public static Setting<HexColor> colorFlowerForestAllium;
96     public static Setting<HexColor> colorFlowerForestAzureBluet;
97     public static Setting<HexColor> colorFlowerForestRedTulip;
98     public static Setting<HexColor> colorFlowerForestOrangeTulip;
99     public static Setting<HexColor> colorFlowerForestWhiteTulip;
100     public static Setting<HexColor> colorFlowerForestPinkTulip;
101     public static Setting<HexColor> colorFlowerForestOxeyeDaisy;
102     public static Setting<HexColor> colorFlowerForestCornflower;
103     public static Setting<HexColor> colorFlowerForestLilyOfTheValley;
104     public static Setting<HexColor> colorBedrockCeilingBlocks;
105
106     public static Setting<HexColor> buttonOnOverlay;
107
108     public static void loadConfig() {
109         configDir = new File(".", "config");
110         configDir.mkdirs();
111         Configuration config = loadConfiguration();
112
113         fill = setup(config, "general", "fill", true, "If set to true the bounding boxes are filled.");
114         outerBoxesOnly = setup(config, "general", "outerBoxesOnly", false, "If set to true only the outer bounding boxes are rendered.");
115         alwaysVisible = setup(config, "general", "alwaysVisible", false, "If set to true boxes will be visible even through other blocks.");
116         keepCacheBetweenSessions = setup(config, "general", "keepCacheBetweenSessions", false, "If set to true bounding box caches will be kept between sessions.");
117         invertBoxColorPlayerInside = setup(config, "general", "invertBoxColorPlayerInside", false, "If set to true the color of any bounding box the player is inside will be inverted.");
118         renderSphereAsDots = setup(config, "general", "renderSphereAsDots", false, "If set to true spheres will be rendered as dots.");
119         buttonOnOverlay = setup(config, "general", "buttonEnabledOverlay", HexColor.from("#3000ff00"), "The color and alpha of the button overlay when a button is on.");
120
121         drawBeacons = setup(config, "beacons", "drawBeacons", true, "If set to true beacon bounding boxes will be drawn.");
122
123         drawConduits = setup(config, "conduits", "drawConduits", true, "If set to true conduit bounding spheres will be drawn.");
124         renderConduitMobHarmArea = setup(config, "conduits", "renderConduitMobHarmArea", true, "If set to true a box to show the area where hostile mobs are harmed will be drawn");
125
126         drawBiomeBorders = setup(config, "biomeBorders", "drawBiomeBorders", true, "If set to true biome borders will be drawn.");
127         renderOnlyCurrentBiome = setup(config, "biomeBorders", "renderOnlyCurrentBiome", true, "If set to true only the biome border for the current biome will be drawn.");
128         biomeBordersRenderDistance = setup(config, "biomeBorders", "biomeBordersRenderDistance", 3, "The distance from the player where biome borders will be drawn.");
129         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.");
130
131         drawFlowerForests = setup(config, "flowerForests", "drawFlowerForests", true, "If set to true flower forest flower overlays will be drawn.");
132         flowerForestsRenderDistance = setup(config, "flowerForests", "flowerForestsRenderDistance", 3, "The distance from the player where flower forests will be drawn.");
133
134         drawBedrockCeilingBlocks = setup(config, "bedrockCeiling", "drawBedrockCeilingBlocks", true, "If set to true position with only one layer of bedrock will be drawn.");
135
136         drawVillages = setup(config, "structures", "drawVillages", false, "If set to true village bounding boxes will be drawn.");
137         drawDesertTemples = setup(config, "structures", "drawDesertTemples", true, "If set to true desert temple bounding boxes are drawn.");
138         drawJungleTemples = setup(config, "structures", "drawJungleTemples", true, "If set to true jungle temple bounding boxes are drawn.");
139         drawWitchHuts = setup(config, "structures", "drawWitchHuts", true, "If set to true witch hut bounding boxes are drawn.");
140         drawStrongholds = setup(config, "structures", "drawStrongholds", false, "If set to true stronghold bounding boxes are drawn.");
141         drawMineShafts = setup(config, "structures", "drawMineShafts", false, "If set to true mineshaft bounding boxes are drawn.");
142         drawNetherFortresses = setup(config, "structures", "drawNetherFortresses", true, "If set to true nether fortress bounding boxes are drawn.");
143         drawOceanMonuments = setup(config, "structures", "drawOceanMonuments", true, "If set to true ocean monument bounding boxes are drawn.");
144         drawEndCities = setup(config, "structures", "drawEndCities", true, "If set to true end city bounding boxes will be drawn.");
145         drawMansions = setup(config, "structures", "drawMansions", true, "If set to true woodland mansions will be drawn.");
146         drawIgloos = setup(config, "structures", "drawIgloos", true, "If set to true igloos will be drawn.");
147         drawShipwrecks = setup(config, "structures", "drawShipwrecks", true, "If set to true shipwrecks will be drawn.");
148         drawOceanRuins = setup(config, "structures", "drawOceanRuins", true, "If set to true ocean ruins will be drawn.");
149         drawBuriedTreasure = setup(config, "structures", "drawBuriedTreasures", true, "If set to true buried treasure will be drawn.");
150         drawPillagerOutposts = setup(config, "structures", "drawPillagerOutposts", true, "If set to true pillager outposts will be drawn.");
151         drawNetherFossils = setup(config, "structures", "drawNetherFossils", true, "If set to true nether fossils will be drawn.");
152         drawBastionRemnants = setup(config, "structures", "drawBastionRemnants", true, "If set to true bastion remnants will be drawn.");
153         drawRuinedPortals = setup(config, "structures", "drawRuinedPortals", true, "If set to true ruined portals will be drawn.");
154
155         drawSlimeChunks = setup(config, "slimeChunks", "drawSlimeChunks", true, "If set to true slime chunks bounding boxes are drawn.");
156         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.");
157
158         drawWorldSpawn = setup(config, "worldSpawn", "drawWorldSpawn", true, "If set to true world spawn and spawn chunks bounding boxes are drawn.");
159         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.");
160         drawLazySpawnChunks = setup(config, "worldSpawn", "drawLazySpawnChunks", false, "If set to true the lazy spawn chunks bounding boxes will be drawn.");
161
162         drawMobSpawners = setup(config, "mobSpawners", "drawMobSpawners", true, "If set to true mob spawners will be drawn.");
163         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");
164         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");
165
166         drawAFKSpheres = setup(config, "afkSpot", "drawAFKSpheres", true, "If set to true afk spot spheres will be drawn.");
167         renderAFKSpawnableBlocks = setup(config, "afkSpot", "renderAFKSpawnableBlocks", true, "If set to true boxes to show spawnable blocks within the AFK sphere will be drawn.");
168         afkSpawnableBlocksRenderDistance = setup(config, "afkSpot", "afkSpawnableBlocksRenderDistance", 3, "The distance from the player where spawnable blocks within the AFK sphere will be drawn.");
169
170         drawSpawnableBlocks = setup(config, "spawnableBlocks", "drawSpawnableBlocks", false, "If set to true boxes to show spawnable blocks will be drawn.");
171         spawnableBlocksRenderWidth = setup(config, "spawnableBlocks", "spawnableBlocksRenderWidth", 2, "The distance from the player where spawnable blocks will be drawn in X and Z axis.");
172         spawnableBlocksRenderHeight = setup(config, "spawnableBlocks", "spawnableBlocksRenderHeight", 1, "The distance from the player where spawnable blocks will be drawn in Y axis.");
173
174         colorWorldSpawn = setup(config, "colors", "colorWorldSpawn", HexColor.from("#ff0000"), "Color of world spawn and spawn chunks bounding boxes.");
175         colorLazySpawnChunks = setup(config, "colors", "colorLazySpawnChunks", HexColor.from("#ff0000"), "Color of lazy spawn chunks bounding boxes.");
176         colorMobSpawners = setup(config, "colors", "colorMobSpawners", HexColor.from("#00ff00"), "Color of mob spawners.");
177         colorMobSpawnersLineFarAway = setup(config, "colors", "colorMobSpawnersLineFarAway", HexColor.from("#ff0000"), "Color of mob spawner activation line if spawner far away.");
178         colorMobSpawnersLineNearby = setup(config, "colors", "colorMobSpawnersLineNearby", HexColor.from("#ff7f00"), "Color of mob spawners activation line if spawner nearby.");
179         colorMobSpawnersLineActive = setup(config, "colors", "colorMobSpawnersLineActive", HexColor.from("#00ff00"), "Color of mob spawners activation line if spawner active.");
180         colorSlimeChunks = setup(config, "colors", "colorSlimeChunks", HexColor.from("#006000"), "Color of slime chunks bounding boxes.");
181         colorAFKSpheres = setup(config, "colors", "colorAFKSpheres", HexColor.from("#ff0000"), "Color of afk spot spheres.");
182         colorAFKSpheresSafeArea = setup(config, "colors", "colorAFKSpheresSafeArea", HexColor.from("#00ff00"), "Color of afk spot safe area spheres.");
183         colorBiomeBorders = setup(config, "colors", "colorBiomeBorders", HexColor.from("#00ff00"), "Color of biome borders.");
184         colorBeacons = setup(config, "colors", "colorBeacons", HexColor.from("#ffffff"), "Color of beacon bounding boxes.");
185         colorCustom = setup(config, "colors", "colorCustom", HexColor.from("#ffffff"), "Color of all types of custom boxes.");
186         colorConduits = setup(config, "colors", "colorConduits", HexColor.from("#00ffff"), "Color of conduit bounding spheres.");
187         colorConduitMobHarmArea = setup(config, "colors", "colorConduitMobHarmArea", HexColor.from("#ff7f00"), "Color of conduit mob harm bounding boxes.");
188         colorSpawnableBlocks = setup(config, "colors", "colorSpawnableBlocks", HexColor.from("#ff0000"), "Color of spawnable blocks.");
189         colorJungleTemples = setup(config, "colors", "colorJungleTemples", HexColor.from("#006000"), "Color of jungle temple bounding boxes.");
190         colorDesertTemples = setup(config, "colors", "colorDesertTemples", HexColor.from("#ffc800"), "Color of desert temple bounding boxes.");
191         colorWitchHuts = setup(config, "colors", "colorWitchHuts", HexColor.from("#0000ff"), "Color of witch hut bounding boxes.");
192         colorOceanMonuments = setup(config, "colors", "colorOceanMonuments", HexColor.from("#00ffff"), "Color of ocean monument bounding boxes.");
193         colorShipwrecks = setup(config, "colors", "colorShipwrecks", HexColor.from("#00ffff"), "Color of ship wrecks.");
194         colorOceanRuins = setup(config, "colors", "colorOceanRuins", HexColor.from("#00ffff"), "Color of ocean ruins.");
195         colorBuriedTreasure = setup(config, "colors", "colorBuriedTreasure", HexColor.from("#00ffff"), "Color of buried treasure.");
196         colorStrongholds = setup(config, "colors", "colorStrongholds", HexColor.from("#ffff00"), "Color of stronghold bounding boxes.");
197         colorMineShafts = setup(config, "colors", "colorMineShafts", HexColor.from("#c0c0c0"), "Color of mineshaft bounding boxes.");
198         colorNetherFortresses = setup(config, "colors", "colorNetherFortresses", HexColor.from("#ff0000"), "Color of nether fortress bounding boxes.");
199         colorEndCities = setup(config, "colors", "colorEndCities", HexColor.from("#ff00ff"), "Color of end cities.");
200         colorMansions = setup(config, "colors", "colorMansions", HexColor.from("#8b4513"), "Color of woodland mansions.");
201         colorIgloos = setup(config, "colors", "colorIgloos", HexColor.from("#ffffff"), "Color of igloos.");
202         colorPillagerOutposts = setup(config, "colors", "colorPillagerOutposts", HexColor.from("#404040"), "Color of pillager outposts.");
203         colorVillages = setup(config, "colors", "colorVillages", HexColor.from("#800080"), "Color of village bounding boxes.");
204         colorNetherFossils = setup(config, "colors", "colorNetherFossils", HexColor.from("#ffffff"), "Color of nether fossils.");
205         colorBastionRemnants = setup(config, "colors", "colorBastionRemnants", HexColor.from("#c0c0c0"), "Color of bastion remnants.");
206         colorRuinedPortals = setup(config, "colors", "colorRuinedPortals", HexColor.from("#c800ff"), "Color of ruined portals.");
207         colorFlowerForestDandelion = setup(config, "colors", "colorFlowerForestDandelion", HexColor.from("#ffff00"), "Color of Flower Forest Dandelion");
208         colorFlowerForestPoppy = setup(config, "colors", "colorFlowerForestPoppy", HexColor.from("#ff0000"), "Color of Flower Forest Poppy");
209         colorFlowerForestAllium = setup(config, "colors", "colorFlowerForestAllium", HexColor.from("#ff00ff"), "Color of Flower Forest Allium");
210         colorFlowerForestAzureBluet = setup(config, "colors", "colorFlowerForestAzureBluet", HexColor.from("#d3d3d3"), "Color of Flower Forest Azure Bluet");
211         colorFlowerForestRedTulip = setup(config, "colors", "colorFlowerForestRedTulip", HexColor.from("#ff0000"), "Color of Flower Forest Red Tulip");
212         colorFlowerForestOrangeTulip = setup(config, "colors", "colorFlowerForestOrangeTulip", HexColor.from("#ff681f"), "Color of Flower Forest Orange Tulip");
213         colorFlowerForestWhiteTulip = setup(config, "colors", "colorFlowerForestWhiteTulip", HexColor.from("#d3d3d3"), "Color of Flower Forest White Tulip");
214         colorFlowerForestPinkTulip = setup(config, "colors", "colorFlowerForestPinkTulip", HexColor.from("#ff69b4"), "Color of Flower Forest Pink Tulip");
215         colorFlowerForestOxeyeDaisy = setup(config, "colors", "colorFlowerForestOxeyeDaisy", HexColor.from("#d3d3d3"), "Color of Flower Forest Oxeye Daisy");
216         colorFlowerForestCornflower = setup(config, "colors", "colorFlowerForestCornflower", HexColor.from("#0000ff"), "Color of Flower Forest Cornflower");
217         colorFlowerForestLilyOfTheValley = setup(config, "colors", "colorFlowerForestLilyOfTheValley", HexColor.from("#ffffff"), "Color of Flower Forest Lily Of The Valley");
218         colorBedrockCeilingBlocks = setup(config, "colors", "colorBedrockCeilingBlocks", HexColor.from("#00ff00"), "Color of Bedrock Ceiling Blocks");
219         config.save();
220     }
221
222     private static Configuration loadConfiguration() {
223         Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
224         config.load();
225         return config;
226     }
227
228     public static void saveConfig() {
229         Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
230         for (Setting<?> setting : settings) {
231             config.put(setting);
232         }
233         config.save();
234     }
235
236     private static <T> Setting<T> setup(Configuration config, String category, String settingName, T defaultValue, String comment) {
237         Setting<T> setting = config.get(category, settingName, defaultValue);
238         setting.category = category;
239         setting.name = settingName;
240         setting.defaultValue = defaultValue;
241         if (setting.get() == null)
242             setting.reset();
243         setting.comment = comment + " (default: " + defaultValue.toString() + ")";
244         settings.add(setting);
245         return setting;
246     }
247
248     public static void Toggle(Setting<Boolean> setting) {
249         setting.set(!setting.get());
250     }
251
252     public static Set<Setting<?>> getSettings() {
253         return settings;
254     }
255 }