refactor(config): encapsulate option sections, drop the Option mirror
Option was a facade of 45 public static fields kept in sync with the four sections by syncFields(); the sections themselves also exposed public static mutable fields. 88 VisibilityModifier violations in one place and two owners for every value. - Option keeps only init(boolean) (the reload entry ConfigLoader calls); the mirrors, syncFields() and the unused @Deprecated initStyles are gone - sections hold private static state behind fluent accessors (OptionSQL.enabled(), OptionGeneration.cleanupInterval(), OptionGeneral.goBackLocation()); the two Option.SQL = false writes become OptionSQL.disable() - collection/location accessors hand out unmodifiable views and a Location copy, so no caller can mutate loaded config state - ParticleShape promoted from nested enum to config/options/ParticleShape - delete 17 never-read generation probability fields and initGenerationProbabilities(): live weights come from advanced.* via GeneratorProfileManager/GenerationProfileLoader; min-y/max-y guard moved 1:1 into initBounds() - rewrite 63 Option.<FIELD> reads in 19 files to the section accessors - validateConfigs() now checks the paths the code actually consumes (advanced.distance/height/type weights) instead of the dead generation.normal.* - ParkourRestrictionListener.onChat: getOrDefault(CHAT, true) instead of unboxing a Boolean that may be absent checkstyle 0 errors / 329 -> 240 warnings (VisibilityModifier 163 -> 75); config/options itself is clean. Dead config keys found on the way are filed as TODO items 164-166. ./gradlew check green: PMD 0, 94 tests, NullAway unchanged.
This commit is contained in:
parent
4263df50a2
commit
c120309663
27 changed files with 386 additions and 359 deletions
|
|
@ -7,7 +7,7 @@ import dev.loki.loparkour.adaptive.model.SkillRating;
|
|||
import dev.loki.loparkour.adaptive.storage.FileStatsStorage;
|
||||
import dev.loki.loparkour.adaptive.storage.SQLStatsStorage;
|
||||
import dev.loki.loparkour.adaptive.storage.StatsRepository;
|
||||
import dev.loki.loparkour.config.options.Option;
|
||||
import dev.loki.loparkour.config.options.section.OptionSQL;
|
||||
import dev.loki.loparkour.generator.core.coordinator.ParkourGenerator;
|
||||
import dev.loki.loparkour.generator.core.model.Profile;
|
||||
import dev.loki.loparkour.player.core.ParkourPlayer;
|
||||
|
|
@ -42,7 +42,7 @@ public final class AdaptiveServices {
|
|||
}
|
||||
|
||||
final Runnable setup = () -> startCollector(createRepository());
|
||||
if (Option.SQL) {
|
||||
if (OptionSQL.enabled()) {
|
||||
Storage.runWhenReady(setup);
|
||||
} else {
|
||||
setup.run();
|
||||
|
|
@ -54,7 +54,7 @@ public final class AdaptiveServices {
|
|||
AdaptiveConfig.reload();
|
||||
if (plugin != null && AdaptiveConfig.isEnabled()) {
|
||||
final Runnable setup = () -> startCollector(createRepository());
|
||||
if (Option.SQL) {
|
||||
if (OptionSQL.enabled()) {
|
||||
Storage.runWhenReady(setup);
|
||||
} else {
|
||||
setup.run();
|
||||
|
|
@ -147,7 +147,7 @@ public final class AdaptiveServices {
|
|||
|
||||
@NotNull
|
||||
private static StatsRepository createRepository() {
|
||||
if (Option.SQL && StorageSQL.isConnected()) {
|
||||
if (OptionSQL.enabled() && StorageSQL.isConnected()) {
|
||||
return new SQLStatsStorage(StorageSQL.getConnectionManager());
|
||||
}
|
||||
return new FileStatsStorage();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue