1 package com.irtimaled.bbor.client.config;
4 import java.util.HashSet;
7 public class ConfigManager {
8 private static final Set<Setting<?>> settings = new HashSet<>();
9 private static File configDir;
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;
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;
106 public static Setting<HexColor> buttonOnOverlay;
108 public static Setting<Integer> fastRender;
110 public static void loadConfig() {
111 configDir = new File(".", "config");
113 Configuration config = loadConfiguration();
115 fill = setup(config, "general", "fill", true, "If set to true the bounding boxes are filled.");
116 outerBoxesOnly = setup(config, "general", "outerBoxesOnly", false, "If set to true only the outer bounding boxes are rendered.");
117 alwaysVisible = setup(config, "general", "alwaysVisible", false, "If set to true boxes will be visible even through other blocks.");
118 keepCacheBetweenSessions = setup(config, "general", "keepCacheBetweenSessions", false, "If set to true bounding box caches will be kept between sessions.");
119 invertBoxColorPlayerInside = setup(config, "general", "invertBoxColorPlayerInside", false, "If set to true the color of any bounding box the player is inside will be inverted.");
120 renderSphereAsDots = setup(config, "general", "renderSphereAsDots", false, "If set to true spheres will be rendered as dots.");
121 buttonOnOverlay = setup(config, "general", "buttonEnabledOverlay", HexColor.from("#3000ff00"), "The color and alpha of the button overlay when a button is on.");
122 fastRender = setup(config, "general", "fastRender", 2, "Fast render settings. Higher value for faster rendering. ");
124 drawBeacons = setup(config, "beacons", "drawBeacons", true, "If set to true beacon bounding boxes will be drawn.");
126 drawConduits = setup(config, "conduits", "drawConduits", true, "If set to true conduit bounding spheres will be drawn.");
127 renderConduitMobHarmArea = setup(config, "conduits", "renderConduitMobHarmArea", true, "If set to true a box to show the area where hostile mobs are harmed will be drawn");
129 drawBiomeBorders = setup(config, "biomeBorders", "drawBiomeBorders", true, "If set to true biome borders will be drawn.");
130 renderOnlyCurrentBiome = setup(config, "biomeBorders", "renderOnlyCurrentBiome", true, "If set to true only the biome border for the current biome will be drawn.");
131 biomeBordersRenderDistance = setup(config, "biomeBorders", "biomeBordersRenderDistance", 3, "The distance from the player where biome borders will be drawn.");
132 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.");
134 // drawFlowerForests = setup(config, "flowerForests", "drawFlowerForests", true, "If set to true flower forest flower overlays will be drawn.");
135 // flowerForestsRenderDistance = setup(config, "flowerForests", "flowerForestsRenderDistance", 3, "The distance from the player where flower forests will be drawn.");
137 drawBedrockCeilingBlocks = setup(config, "bedrockCeiling", "drawBedrockCeilingBlocks", true, "If set to true position with only one layer of bedrock will be drawn.");
139 drawVillages = setup(config, "structures", "drawVillages", false, "If set to true village bounding boxes will be drawn.");
140 drawDesertTemples = setup(config, "structures", "drawDesertTemples", true, "If set to true desert temple bounding boxes are drawn.");
141 drawJungleTemples = setup(config, "structures", "drawJungleTemples", true, "If set to true jungle temple bounding boxes are drawn.");
142 drawWitchHuts = setup(config, "structures", "drawWitchHuts", true, "If set to true witch hut bounding boxes are drawn.");
143 drawStrongholds = setup(config, "structures", "drawStrongholds", false, "If set to true stronghold bounding boxes are drawn.");
144 drawMineShafts = setup(config, "structures", "drawMineShafts", false, "If set to true mineshaft bounding boxes are drawn.");
145 drawNetherFortresses = setup(config, "structures", "drawNetherFortresses", true, "If set to true nether fortress bounding boxes are drawn.");
146 drawOceanMonuments = setup(config, "structures", "drawOceanMonuments", true, "If set to true ocean monument bounding boxes are drawn.");
147 drawEndCities = setup(config, "structures", "drawEndCities", true, "If set to true end city bounding boxes will be drawn.");
148 drawMansions = setup(config, "structures", "drawMansions", true, "If set to true woodland mansions will be drawn.");
149 drawIgloos = setup(config, "structures", "drawIgloos", true, "If set to true igloos will be drawn.");
150 drawShipwrecks = setup(config, "structures", "drawShipwrecks", true, "If set to true shipwrecks will be drawn.");
151 drawOceanRuins = setup(config, "structures", "drawOceanRuins", true, "If set to true ocean ruins will be drawn.");
152 drawBuriedTreasure = setup(config, "structures", "drawBuriedTreasures", true, "If set to true buried treasure will be drawn.");
153 drawPillagerOutposts = setup(config, "structures", "drawPillagerOutposts", true, "If set to true pillager outposts will be drawn.");
154 drawNetherFossils = setup(config, "structures", "drawNetherFossils", true, "If set to true nether fossils will be drawn.");
155 drawBastionRemnants = setup(config, "structures", "drawBastionRemnants", true, "If set to true bastion remnants will be drawn.");
156 drawRuinedPortals = setup(config, "structures", "drawRuinedPortals", true, "If set to true ruined portals will be drawn.");
158 drawSlimeChunks = setup(config, "slimeChunks", "drawSlimeChunks", true, "If set to true slime chunks bounding boxes are drawn.");
159 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.");
161 drawWorldSpawn = setup(config, "worldSpawn", "drawWorldSpawn", true, "If set to true world spawn and spawn chunks bounding boxes are drawn.");
162 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.");
163 drawLazySpawnChunks = setup(config, "worldSpawn", "drawLazySpawnChunks", false, "If set to true the lazy spawn chunks bounding boxes will be drawn.");
165 drawMobSpawners = setup(config, "mobSpawners", "drawMobSpawners", true, "If set to true mob spawners will be drawn.");
166 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");
167 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");
169 drawAFKSpheres = setup(config, "afkSpot", "drawAFKSpheres", true, "If set to true afk spot spheres will be drawn.");
170 renderAFKSpawnableBlocks = setup(config, "afkSpot", "renderAFKSpawnableBlocks", true, "If set to true boxes to show spawnable blocks within the AFK sphere will be drawn.");
171 afkSpawnableBlocksRenderDistance = setup(config, "afkSpot", "afkSpawnableBlocksRenderDistance", 3, "The distance from the player where spawnable blocks within the AFK sphere will be drawn.");
173 drawSpawnableBlocks = setup(config, "spawnableBlocks", "drawSpawnableBlocks", false, "If set to true boxes to show spawnable blocks will be drawn.");
174 spawnableBlocksRenderWidth = setup(config, "spawnableBlocks", "spawnableBlocksRenderWidth", 2, "The distance from the player where spawnable blocks will be drawn in X and Z axis.");
175 spawnableBlocksRenderHeight = setup(config, "spawnableBlocks", "spawnableBlocksRenderHeight", 1, "The distance from the player where spawnable blocks will be drawn in Y axis.");
177 colorWorldSpawn = setup(config, "colors", "colorWorldSpawn", HexColor.from("#ff0000"), "Color of world spawn and spawn chunks bounding boxes.");
178 colorLazySpawnChunks = setup(config, "colors", "colorLazySpawnChunks", HexColor.from("#ff0000"), "Color of lazy spawn chunks bounding boxes.");
179 colorMobSpawners = setup(config, "colors", "colorMobSpawners", HexColor.from("#00ff00"), "Color of mob spawners.");
180 colorMobSpawnersLineFarAway = setup(config, "colors", "colorMobSpawnersLineFarAway", HexColor.from("#ff0000"), "Color of mob spawner activation line if spawner far away.");
181 colorMobSpawnersLineNearby = setup(config, "colors", "colorMobSpawnersLineNearby", HexColor.from("#ff7f00"), "Color of mob spawners activation line if spawner nearby.");
182 colorMobSpawnersLineActive = setup(config, "colors", "colorMobSpawnersLineActive", HexColor.from("#00ff00"), "Color of mob spawners activation line if spawner active.");
183 colorSlimeChunks = setup(config, "colors", "colorSlimeChunks", HexColor.from("#006000"), "Color of slime chunks bounding boxes.");
184 colorAFKSpheres = setup(config, "colors", "colorAFKSpheres", HexColor.from("#ff0000"), "Color of afk spot spheres.");
185 colorAFKSpheresSafeArea = setup(config, "colors", "colorAFKSpheresSafeArea", HexColor.from("#00ff00"), "Color of afk spot safe area spheres.");
186 colorBiomeBorders = setup(config, "colors", "colorBiomeBorders", HexColor.from("#00ff00"), "Color of biome borders.");
187 colorBeacons = setup(config, "colors", "colorBeacons", HexColor.from("#ffffff"), "Color of beacon bounding boxes.");
188 colorCustom = setup(config, "colors", "colorCustom", HexColor.from("#ffffff"), "Color of all types of custom boxes.");
189 colorConduits = setup(config, "colors", "colorConduits", HexColor.from("#00ffff"), "Color of conduit bounding spheres.");
190 colorConduitMobHarmArea = setup(config, "colors", "colorConduitMobHarmArea", HexColor.from("#ff7f00"), "Color of conduit mob harm bounding boxes.");
191 colorSpawnableBlocks = setup(config, "colors", "colorSpawnableBlocks", HexColor.from("#ff0000"), "Color of spawnable blocks.");
192 colorJungleTemples = setup(config, "colors", "colorJungleTemples", HexColor.from("#006000"), "Color of jungle temple bounding boxes.");
193 colorDesertTemples = setup(config, "colors", "colorDesertTemples", HexColor.from("#ffc800"), "Color of desert temple bounding boxes.");
194 colorWitchHuts = setup(config, "colors", "colorWitchHuts", HexColor.from("#0000ff"), "Color of witch hut bounding boxes.");
195 colorOceanMonuments = setup(config, "colors", "colorOceanMonuments", HexColor.from("#00ffff"), "Color of ocean monument bounding boxes.");
196 colorShipwrecks = setup(config, "colors", "colorShipwrecks", HexColor.from("#00ffff"), "Color of ship wrecks.");
197 colorOceanRuins = setup(config, "colors", "colorOceanRuins", HexColor.from("#00ffff"), "Color of ocean ruins.");
198 colorBuriedTreasure = setup(config, "colors", "colorBuriedTreasure", HexColor.from("#00ffff"), "Color of buried treasure.");
199 colorStrongholds = setup(config, "colors", "colorStrongholds", HexColor.from("#ffff00"), "Color of stronghold bounding boxes.");
200 colorMineShafts = setup(config, "colors", "colorMineShafts", HexColor.from("#c0c0c0"), "Color of mineshaft bounding boxes.");
201 colorNetherFortresses = setup(config, "colors", "colorNetherFortresses", HexColor.from("#ff0000"), "Color of nether fortress bounding boxes.");
202 colorEndCities = setup(config, "colors", "colorEndCities", HexColor.from("#ff00ff"), "Color of end cities.");
203 colorMansions = setup(config, "colors", "colorMansions", HexColor.from("#8b4513"), "Color of woodland mansions.");
204 colorIgloos = setup(config, "colors", "colorIgloos", HexColor.from("#ffffff"), "Color of igloos.");
205 colorPillagerOutposts = setup(config, "colors", "colorPillagerOutposts", HexColor.from("#404040"), "Color of pillager outposts.");
206 colorVillages = setup(config, "colors", "colorVillages", HexColor.from("#800080"), "Color of village bounding boxes.");
207 colorNetherFossils = setup(config, "colors", "colorNetherFossils", HexColor.from("#ffffff"), "Color of nether fossils.");
208 colorBastionRemnants = setup(config, "colors", "colorBastionRemnants", HexColor.from("#c0c0c0"), "Color of bastion remnants.");
209 colorRuinedPortals = setup(config, "colors", "colorRuinedPortals", HexColor.from("#c800ff"), "Color of ruined portals.");
210 colorFlowerForestDandelion = setup(config, "colors", "colorFlowerForestDandelion", HexColor.from("#ffff00"), "Color of Flower Forest Dandelion");
211 colorFlowerForestPoppy = setup(config, "colors", "colorFlowerForestPoppy", HexColor.from("#ff0000"), "Color of Flower Forest Poppy");
212 colorFlowerForestAllium = setup(config, "colors", "colorFlowerForestAllium", HexColor.from("#ff00ff"), "Color of Flower Forest Allium");
213 colorFlowerForestAzureBluet = setup(config, "colors", "colorFlowerForestAzureBluet", HexColor.from("#d3d3d3"), "Color of Flower Forest Azure Bluet");
214 colorFlowerForestRedTulip = setup(config, "colors", "colorFlowerForestRedTulip", HexColor.from("#ff0000"), "Color of Flower Forest Red Tulip");
215 colorFlowerForestOrangeTulip = setup(config, "colors", "colorFlowerForestOrangeTulip", HexColor.from("#ff681f"), "Color of Flower Forest Orange Tulip");
216 colorFlowerForestWhiteTulip = setup(config, "colors", "colorFlowerForestWhiteTulip", HexColor.from("#d3d3d3"), "Color of Flower Forest White Tulip");
217 colorFlowerForestPinkTulip = setup(config, "colors", "colorFlowerForestPinkTulip", HexColor.from("#ff69b4"), "Color of Flower Forest Pink Tulip");
218 colorFlowerForestOxeyeDaisy = setup(config, "colors", "colorFlowerForestOxeyeDaisy", HexColor.from("#d3d3d3"), "Color of Flower Forest Oxeye Daisy");
219 colorFlowerForestCornflower = setup(config, "colors", "colorFlowerForestCornflower", HexColor.from("#0000ff"), "Color of Flower Forest Cornflower");
220 colorFlowerForestLilyOfTheValley = setup(config, "colors", "colorFlowerForestLilyOfTheValley", HexColor.from("#ffffff"), "Color of Flower Forest Lily Of The Valley");
221 colorBedrockCeilingBlocks = setup(config, "colors", "colorBedrockCeilingBlocks", HexColor.from("#00ff00"), "Color of Bedrock Ceiling Blocks");
225 private static Configuration loadConfiguration() {
226 Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
231 public static void saveConfig() {
232 Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
233 for (Setting<?> setting : settings) {
239 private static <T> Setting<T> setup(Configuration config, String category, String settingName, T defaultValue, String comment) {
240 Setting<T> setting = config.get(category, settingName, defaultValue);
241 setting.category = category;
242 setting.name = settingName;
243 setting.defaultValue = defaultValue;
244 if (setting.get() == null)
246 setting.comment = comment + " (default: " + defaultValue.toString() + ")";
247 settings.add(setting);
251 public static void Toggle(Setting<Boolean> setting) {
252 setting.set(!setting.get());
255 public static Set<Setting<?>> getSettings() {