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
|
|
@ -1,7 +1,7 @@
|
|||
package dev.loki.loparkour.menu.core;
|
||||
|
||||
import dev.loki.loparkour.config.locale.Locales;
|
||||
import dev.loki.loparkour.config.options.Option;
|
||||
import dev.loki.loparkour.config.options.OptionGeneral;
|
||||
import dev.loki.loparkour.util.text.ColorUtil;
|
||||
import dev.loki.loparkour.menu.gui.inventory.InventoryGui;
|
||||
import org.bukkit.Material;
|
||||
|
|
@ -26,7 +26,7 @@ public abstract class LPMenu {
|
|||
|
||||
protected String locale(@NotNull Player player) {
|
||||
final var user = dev.loki.loparkour.player.core.ParkourUser.getUser(player);
|
||||
final String loc = user != null ? user.locale : Option.OPTIONS_DEFAULTS.get(ParkourOption.LANG);
|
||||
final String loc = user != null ? user.locale : OptionGeneral.optionsDefaults().get(ParkourOption.LANG);
|
||||
return (loc != null && !loc.isBlank()) ? loc : "en";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package dev.loki.loparkour.menu.core.screen;
|
||||
|
||||
import dev.loki.loparkour.config.core.Config;
|
||||
import dev.loki.loparkour.config.options.Option;
|
||||
import dev.loki.loparkour.config.options.OptionGeneral;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
/**
|
||||
|
|
@ -69,7 +69,7 @@ public enum ParkourOption {
|
|||
* @return True if the player is allowed to view/perform this option, false if not.
|
||||
*/
|
||||
public boolean mayPerform(Permissible permissible) {
|
||||
final boolean value = Option.OPTIONS_ENABLED.getOrDefault(this, true);
|
||||
final boolean value = OptionGeneral.optionsEnabled().getOrDefault(this, true);
|
||||
|
||||
if (value) {
|
||||
if (Config.CONFIG.getBoolean("permissions.enabled")) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue