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 void loadConfig() {
63 configDir = new File(".", "config");
65 Configuration config = loadConfiguration();
67 fill = setup(config, "general", "fill", true, "If set to true the bounding boxes are filled.");
68 outerBoxesOnly = setup(config, "general", "outerBoxesOnly", false, "If set to true only the outer bounding boxes are rendered.");
69 alwaysVisible = setup(config, "general", "alwaysVisible", false, "If set to true boxes will be visible even through other blocks.");
70 keepCacheBetweenSessions = setup(config, "general", "keepCacheBetweenSessions", false, "If set to true bounding box caches will be kept between sessions.");
71 invertBoxColorPlayerInside = setup(config, "general", "invertBoxColorPlayerInside", false, "If set to true the color of any bounding box the player is inside will be inverted.");
72 renderSphereAsDots = setup(config, "general", "renderSphereAsDots", false, "If set to true spheres will be rendered as dots.");
74 drawBeacons = setup(config, "beacons", "drawBeacons", true, "If set to true beacon bounding boxes will be drawn.");
76 drawConduits = setup(config, "conduits", "drawConduits", true, "If set to true conduit bounding spheres will be drawn.");
77 renderConduitMobHarmArea = setup(config, "conduits", "renderConduitMobHarmArea", true, "If set to true a box to show the area where hostile mobs are harmed will be drawn");
79 drawBiomeBorders = setup(config, "biomeBorders", "drawBiomeBorders", true, "If set to true biome borders will be drawn.");
80 renderOnlyCurrentBiome = setup(config, "biomeBorders", "renderOnlyCurrentBiome", true, "If set to true only the biome border for the current biome will be drawn.");
81 biomeBordersRenderDistance = setup(config, "biomeBorders", "biomeBordersRenderDistance", 3, "The distance from the player where biome borders will be drawn.");
82 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.");
84 drawVillageSpheres = setup(config, "villages", "drawVillageSpheres", true, "If set to true village bounding spheres are drawn.");
85 drawIronGolemSpawnArea = setup(config, "villages", "drawIronGolemSpawnArea", true, "If set to true the iron golem spawn area of the village will be drawn. (default:true)");
86 drawVillageDoors = setup(config, "villages", "drawVillageDoors", false, "If set to true lines between the village centre and doors will be drawn. (default:false)");
87 villageSphereDotSize = setup(config, "villages", "villageSphereDotSize", 2, "The size of the dots used when rendering village as sphere.");
88 villageSphereDensity = setup(config, "villages", "villageSphereDensity", 3, "The density of the dots used when rendering village as sphere.");
90 drawVillages = setup(config, "structures", "drawVillages", false, "If set to true village bounding boxes will be drawn.");
91 drawDesertTemples = setup(config, "structures", "drawDesertTemples", true, "If set to true desert temple bounding boxes are drawn.");
92 drawJungleTemples = setup(config, "structures", "drawJungleTemples", true, "If set to true jungle temple bounding boxes are drawn.");
93 drawWitchHuts = setup(config, "structures", "drawWitchHuts", true, "If set to true witch hut bounding boxes are drawn.");
94 drawStrongholds = setup(config, "structures", "drawStrongholds", false, "If set to true stronghold bounding boxes are drawn.");
95 drawMineShafts = setup(config, "structures", "drawMineShafts", false, "If set to true mineshaft bounding boxes are drawn.");
96 drawNetherFortresses = setup(config, "structures", "drawNetherFortresses", true, "If set to true nether fortress bounding boxes are drawn.");
97 drawOceanMonuments = setup(config, "structures", "drawOceanMonuments", true, "If set to true ocean monument bounding boxes are drawn.");
98 drawEndCities = setup(config, "structures", "drawEndCities", true, "If set to true end city bounding boxes will be drawn.");
99 drawMansions = setup(config, "structures", "drawMansions", true, "If set to true woodland mansions will be drawn.");
100 drawIgloos = setup(config, "structures", "drawIgloos", true, "If set to true igloos will be drawn.");
101 drawShipwrecks = setup(config, "structures", "drawShipwrecks", true, "If set to true shipwrecks will be drawn.");
102 drawOceanRuins = setup(config, "structures", "drawOceanRuins", true, "If set to true ocean ruins will be drawn.");
103 drawBuriedTreasure = setup(config, "structures", "drawBuriedTreasures", true, "If set to true buried treasure will be drawn.");
104 drawPillagerOutposts = setup(config, "structures", "drawPillagerOutposts", true, "If set to true pillager outposts will be drawn.");
105 drawNetherFossils = setup(config, "structures", "drawNetherFossils", true, "If set to true nether fossils will be drawn.");
106 drawBastionRemnants = setup(config, "structures", "drawBastionRemnants", true, "If set to true bastion remnants will be drawn.");
107 drawRuinedPortals = setup(config, "structures", "drawRuinedPortals", true, "If set to true ruined portals will be drawn.");
109 drawSlimeChunks = setup(config, "slimeChunks", "drawSlimeChunks", true, "If set to true slime chunks bounding boxes are drawn.");
110 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.");
112 drawWorldSpawn = setup(config, "worldSpawn", "drawWorldSpawn", true, "If set to true world spawn and spawn chunks bounding boxes are drawn.");
113 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.");
114 drawLazySpawnChunks = setup(config, "worldSpawn", "drawLazySpawnChunks", false, "If set to true the lazy spawn chunks bounding boxes will be drawn.");
116 drawMobSpawners = setup(config, "mobSpawners", "drawMobSpawners", true, "If set to true mob spawners will be drawn.");
117 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");
118 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");
120 drawAFKSpheres = setup(config, "afkSpot", "drawAFKSpheres", true, "If set to true afk spot spheres will be drawn.");
121 renderAFKSpawnableBlocks = setup(config, "afkSpot", "renderAFKSpawnableBlocks", true, "If set to true boxes to show spawnable blocks within the AFK sphere will be drawn.");
122 afkSpawnableBlocksRenderDistance = setup(config, "afkSpot", "afkSpawnableBlocksRenderDistance", 3, "The distance from the player where spawnable blocks within the AFK sphere will be drawn.");
124 drawSpawnableBlocks = setup(config, "spawnableBlocks", "drawSpawnableBlocks", false, "If set to true boxes to show spawnable blocks will be drawn.");
125 spawnableBlocksRenderWidth = setup(config, "spawnableBlocks", "spawnableBlocksRenderWidth", 2, "The distance from the player where spawnable blocks will be drawn in X and Z axis.");
126 spawnableBlocksRenderHeight = setup(config, "spawnableBlocks", "spawnableBlocksRenderHeight", 1, "The distance from the player where spawnable blocks will be drawn in Y axis.");
131 private static Configuration loadConfiguration() {
132 Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
137 public static void saveConfig() {
138 Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
139 for (Setting<?> setting : settings) {
145 private static <T> Setting<T> setup(Configuration config, String category, String settingName, T defaultValue, String comment) {
146 Setting<T> setting = config.get(category, settingName, defaultValue);
147 setting.category = category;
148 setting.name = settingName;
149 setting.comment = comment + " (default: " + defaultValue.toString() + ")";
150 settings.add(setting);
154 public static void Toggle(Setting<Boolean> setting) {
155 setting.set(!setting.get());
158 public static Set<Setting<?>> getSettings() {