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