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