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