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;
57 public static Setting<HexColor> colorWorldSpawn;
58 public static Setting<HexColor> colorLazySpawnChunks;
59 public static Setting<HexColor> colorMobSpawners;
60 public static Setting<HexColor> colorMobSpawnersLineFarAway;
61 public static Setting<HexColor> colorMobSpawnersLineNearby;
62 public static Setting<HexColor> colorMobSpawnersLineActive;
63 public static Setting<HexColor> colorSlimeChunks;
64 public static Setting<HexColor> colorAFKSpheres;
65 public static Setting<HexColor> colorAFKSpheresSafeArea;
66 public static Setting<HexColor> colorBiomeBorders;
67 public static Setting<HexColor> colorBeacons;
68 public static Setting<HexColor> colorCustom;
69 public static Setting<HexColor> colorConduits;
70 public static Setting<HexColor> colorConduitMobHarmArea;
71 public static Setting<HexColor> colorSpawnableBlocks;
72 public static Setting<HexColor> colorJungleTemples;
73 public static Setting<HexColor> colorDesertTemples;
74 public static Setting<HexColor> colorWitchHuts;
75 public static Setting<HexColor> colorOceanMonuments;
76 public static Setting<HexColor> colorShipwrecks;
77 public static Setting<HexColor> colorOceanRuins;
78 public static Setting<HexColor> colorBuriedTreasure;
79 public static Setting<HexColor> colorStrongholds;
80 public static Setting<HexColor> colorMineShafts;
81 public static Setting<HexColor> colorNetherFortresses;
82 public static Setting<HexColor> colorEndCities;
83 public static Setting<HexColor> colorMansions;
84 public static Setting<HexColor> colorIgloos;
85 public static Setting<HexColor> colorPillagerOutposts;
86 public static Setting<HexColor> colorVillages;
87 public static Setting<HexColor> colorNetherFossils;
88 public static Setting<HexColor> colorBastionRemnants;
89 public static Setting<HexColor> colorRuinedPortals;
91 public static Setting<HexColor> buttonOnOverlay;
93 public static void loadConfig() {
94 configDir = new File(".", "config");
96 Configuration config = loadConfiguration();
98 fill = setup(config, "general", "fill", true, "If set to true the bounding boxes are filled.");
99 outerBoxesOnly = setup(config, "general", "outerBoxesOnly", false, "If set to true only the outer bounding boxes are rendered.");
100 alwaysVisible = setup(config, "general", "alwaysVisible", false, "If set to true boxes will be visible even through other blocks.");
101 keepCacheBetweenSessions = setup(config, "general", "keepCacheBetweenSessions", false, "If set to true bounding box caches will be kept between sessions.");
102 invertBoxColorPlayerInside = setup(config, "general", "invertBoxColorPlayerInside", false, "If set to true the color of any bounding box the player is inside will be inverted.");
103 renderSphereAsDots = setup(config, "general", "renderSphereAsDots", false, "If set to true spheres will be rendered as dots.");
104 buttonOnOverlay = setup(config, "general", "buttonEnabledOverlay", HexColor.from("#3000ff00"), "The color and alpha of the button overlay when a button is on.");
106 drawBeacons = setup(config, "beacons", "drawBeacons", true, "If set to true beacon bounding boxes will be drawn.");
108 drawConduits = setup(config, "conduits", "drawConduits", true, "If set to true conduit bounding spheres will be drawn.");
109 renderConduitMobHarmArea = setup(config, "conduits", "renderConduitMobHarmArea", true, "If set to true a box to show the area where hostile mobs are harmed will be drawn");
111 drawBiomeBorders = setup(config, "biomeBorders", "drawBiomeBorders", true, "If set to true biome borders will be drawn.");
112 renderOnlyCurrentBiome = setup(config, "biomeBorders", "renderOnlyCurrentBiome", true, "If set to true only the biome border for the current biome will be drawn.");
113 biomeBordersRenderDistance = setup(config, "biomeBorders", "biomeBordersRenderDistance", 3, "The distance from the player where biome borders will be drawn.");
114 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.");
116 drawVillages = setup(config, "structures", "drawVillages", false, "If set to true village bounding boxes will be drawn.");
117 drawDesertTemples = setup(config, "structures", "drawDesertTemples", true, "If set to true desert temple bounding boxes are drawn.");
118 drawJungleTemples = setup(config, "structures", "drawJungleTemples", true, "If set to true jungle temple bounding boxes are drawn.");
119 drawWitchHuts = setup(config, "structures", "drawWitchHuts", true, "If set to true witch hut bounding boxes are drawn.");
120 drawStrongholds = setup(config, "structures", "drawStrongholds", false, "If set to true stronghold bounding boxes are drawn.");
121 drawMineShafts = setup(config, "structures", "drawMineShafts", false, "If set to true mineshaft bounding boxes are drawn.");
122 drawNetherFortresses = setup(config, "structures", "drawNetherFortresses", true, "If set to true nether fortress bounding boxes are drawn.");
123 drawOceanMonuments = setup(config, "structures", "drawOceanMonuments", true, "If set to true ocean monument bounding boxes are drawn.");
124 drawEndCities = setup(config, "structures", "drawEndCities", true, "If set to true end city bounding boxes will be drawn.");
125 drawMansions = setup(config, "structures", "drawMansions", true, "If set to true woodland mansions will be drawn.");
126 drawIgloos = setup(config, "structures", "drawIgloos", true, "If set to true igloos will be drawn.");
127 drawShipwrecks = setup(config, "structures", "drawShipwrecks", true, "If set to true shipwrecks will be drawn.");
128 drawOceanRuins = setup(config, "structures", "drawOceanRuins", true, "If set to true ocean ruins will be drawn.");
129 drawBuriedTreasure = setup(config, "structures", "drawBuriedTreasures", true, "If set to true buried treasure will be drawn.");
130 drawPillagerOutposts = setup(config, "structures", "drawPillagerOutposts", true, "If set to true pillager outposts will be drawn.");
131 drawNetherFossils = setup(config, "structures", "drawNetherFossils", true, "If set to true nether fossils will be drawn.");
132 drawBastionRemnants = setup(config, "structures", "drawBastionRemnants", true, "If set to true bastion remnants will be drawn.");
133 drawRuinedPortals = setup(config, "structures", "drawRuinedPortals", true, "If set to true ruined portals will be drawn.");
135 drawSlimeChunks = setup(config, "slimeChunks", "drawSlimeChunks", true, "If set to true slime chunks bounding boxes are drawn.");
136 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.");
138 drawWorldSpawn = setup(config, "worldSpawn", "drawWorldSpawn", true, "If set to true world spawn and spawn chunks bounding boxes are drawn.");
139 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.");
140 drawLazySpawnChunks = setup(config, "worldSpawn", "drawLazySpawnChunks", false, "If set to true the lazy spawn chunks bounding boxes will be drawn.");
142 drawMobSpawners = setup(config, "mobSpawners", "drawMobSpawners", true, "If set to true mob spawners will be drawn.");
143 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");
144 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");
146 drawAFKSpheres = setup(config, "afkSpot", "drawAFKSpheres", true, "If set to true afk spot spheres will be drawn.");
147 renderAFKSpawnableBlocks = setup(config, "afkSpot", "renderAFKSpawnableBlocks", true, "If set to true boxes to show spawnable blocks within the AFK sphere will be drawn.");
148 afkSpawnableBlocksRenderDistance = setup(config, "afkSpot", "afkSpawnableBlocksRenderDistance", 3, "The distance from the player where spawnable blocks within the AFK sphere will be drawn.");
150 drawSpawnableBlocks = setup(config, "spawnableBlocks", "drawSpawnableBlocks", false, "If set to true boxes to show spawnable blocks will be drawn.");
151 spawnableBlocksRenderWidth = setup(config, "spawnableBlocks", "spawnableBlocksRenderWidth", 2, "The distance from the player where spawnable blocks will be drawn in X and Z axis.");
152 spawnableBlocksRenderHeight = setup(config, "spawnableBlocks", "spawnableBlocksRenderHeight", 1, "The distance from the player where spawnable blocks will be drawn in Y axis.");
154 colorWorldSpawn = setup(config, "colors", "colorWorldSpawn", HexColor.from("#ff0000"), "Color of world spawn and spawn chunks bounding boxes.");
155 colorLazySpawnChunks = setup(config, "colors", "colorLazySpawnChunks", HexColor.from("#ff0000"), "Color of lazy spawn chunks bounding boxes.");
156 colorMobSpawners = setup(config, "colors", "colorMobSpawners", HexColor.from("#00ff00"), "Color of mob spawners.");
157 colorMobSpawnersLineFarAway = setup(config, "colors", "colorMobSpawnersLineFarAway", HexColor.from("#ff0000"), "Color of mob spawner activation line if spawner far away.");
158 colorMobSpawnersLineNearby = setup(config, "colors", "colorMobSpawnersLineNearby", HexColor.from("#ff7f00"), "Color of mob spawners activation line if spawner nearby.");
159 colorMobSpawnersLineActive = setup(config, "colors", "colorMobSpawnersLineActive", HexColor.from("#00ff00"), "Color of mob spawners activation line if spawner active.");
160 colorSlimeChunks = setup(config, "colors", "colorSlimeChunks", HexColor.from("#006000"), "Color of slime chunks bounding boxes.");
161 colorAFKSpheres = setup(config, "colors", "colorAFKSpheres", HexColor.from("#ff0000"), "Color of afk spot spheres.");
162 colorAFKSpheresSafeArea = setup(config, "colors", "colorAFKSpheresSafeArea", HexColor.from("#00ff00"), "Color of afk spot safe area spheres.");
163 colorBiomeBorders = setup(config, "colors", "colorBiomeBorders", HexColor.from("#00ff00"), "Color of biome borders.");
164 colorBeacons = setup(config, "colors", "colorBeacons", HexColor.from("#ffffff"), "Color of beacon bounding boxes.");
165 colorCustom = setup(config, "colors", "colorCustom", HexColor.from("#ffffff"), "Color of all types of custom boxes.");
166 colorConduits = setup(config, "colors", "colorConduits", HexColor.from("#00ffff"), "Color of conduit bounding spheres.");
167 colorConduitMobHarmArea = setup(config, "colors", "colorConduitMobHarmArea", HexColor.from("#ff7f00"), "Color of conduit mob harm bounding boxes.");
168 colorSpawnableBlocks = setup(config, "colors", "colorSpawnableBlocks", HexColor.from("#ff0000"), "Color of spawnable blocks.");
169 colorJungleTemples = setup(config, "colors", "colorJungleTemples", HexColor.from("#006000"), "Color of jungle temple bounding boxes.");
170 colorDesertTemples = setup(config, "colors", "colorDesertTemples", HexColor.from("#ffc800"), "Color of desert temple bounding boxes.");
171 colorWitchHuts = setup(config, "colors", "colorWitchHuts", HexColor.from("#0000ff"), "Color of witch hut bounding boxes.");
172 colorOceanMonuments = setup(config, "colors", "colorOceanMonuments", HexColor.from("#00ffff"), "Color of ocean monument bounding boxes.");
173 colorShipwrecks = setup(config, "colors", "colorShipwrecks", HexColor.from("#00ffff"), "Color of ship wrecks.");
174 colorOceanRuins = setup(config, "colors", "colorOceanRuins", HexColor.from("#00ffff"), "Color of ocean ruins.");
175 colorBuriedTreasure = setup(config, "colors", "colorBuriedTreasure", HexColor.from("#00ffff"), "Color of buried treasure.");
176 colorStrongholds = setup(config, "colors", "colorStrongholds", HexColor.from("#ffff00"), "Color of stronghold bounding boxes.");
177 colorMineShafts = setup(config, "colors", "colorMineShafts", HexColor.from("#c0c0c0"), "Color of mineshaft bounding boxes.");
178 colorNetherFortresses = setup(config, "colors", "colorNetherFortresses", HexColor.from("#ff0000"), "Color of nether fortress bounding boxes.");
179 colorEndCities = setup(config, "colors", "colorEndCities", HexColor.from("#ff00ff"), "Color of end cities.");
180 colorMansions = setup(config, "colors", "colorMansions", HexColor.from("#8b4513"), "Color of woodland mansions.");
181 colorIgloos = setup(config, "colors", "colorIgloos", HexColor.from("#ffffff"), "Color of igloos.");
182 colorPillagerOutposts = setup(config, "colors", "colorPillagerOutposts", HexColor.from("#404040"), "Color of pillager outposts.");
183 colorVillages = setup(config, "colors", "colorVillages", HexColor.from("#800080"), "Color of village bounding boxes.");
184 colorNetherFossils = setup(config, "colors", "colorNetherFossils", HexColor.from("#ffffff"), "Color of nether fossils.");
185 colorBastionRemnants = setup(config, "colors", "colorBastionRemnants", HexColor.from("#c0c0c0"), "Color of bastion remnants.");
186 colorRuinedPortals = setup(config, "colors", "colorRuinedPortals", HexColor.from("#c800ff"), "Color of ruined portals.");
191 private static Configuration loadConfiguration() {
192 Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
197 public static void saveConfig() {
198 Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
199 for (Setting<?> setting : settings) {
205 private static <T> Setting<T> setup(Configuration config, String category, String settingName, T defaultValue, String comment) {
206 Setting<T> setting = config.get(category, settingName, defaultValue);
207 setting.category = category;
208 setting.name = settingName;
209 setting.defaultValue = defaultValue;
210 if (setting.get() == null)
212 setting.comment = comment + " (default: " + defaultValue.toString() + ")";
213 settings.add(setting);
217 public static void Toggle(Setting<Boolean> setting) {
218 setting.set(!setting.get());
221 public static Set<Setting<?>> getSettings() {