LoParkour/src/main/java/dev/loki/loparkour/player/data/PlayerSettings.java
loki5512344 02e2947f47
refactor(player): encapsulate game state behind PlayerSettings, clear VisibilityModifier and HiddenField
- ParkourUser/ParkourPlayer/GeneratorState public mutable fields -> private + short accessors
- per-player settings extracted to player/data/PlayerSettings (ParkourPlayer 188 -> 96 lines,
  PMD-counted methods 20 -> 9); this is what fixed the TooManyMethods violation that the
  encapsulation itself introduced — by decomposition, not by lowering the threshold
- disk storage reads and writes the same canonical 12-key map as the SQL JSON column;
  legacy key names normalized on read, @Expose dropped from domain classes
- 39 settings call sites rewritten across 7 files
- HiddenField backlog cleared (Config, ObstacleGenerator, GhostService, Leaderboard,
  PagedMenu, Reward, ParticleData, World)
- checkstyle ratchet: VisibilityModifier, HiddenField, EmptyLineSeparator and
  MissingDeprecated flipped to error once their counters hit zero; suppressions.xml empty
- javac -Xmaxwarns raised so NullAway/Error Prone counts are honest
  (baseline 165/289, now 164/265)

checkstyle 0 errors / 135 warnings, PMD 0 violations, tests 94/0 fail, ./gradlew check green.
TODO.md: items 30 and 107 updated, new items 167-170, ПРОГРЕСС-6/7 recorded.
2026-10-06 18:57:39 +02:00

115 lines
2.8 KiB
Java

package dev.loki.loparkour.player.data;
import java.util.ArrayList;
import java.util.List;
/**
* Per-player parkour preferences: what to show, which style to play, how hard the schematics may be.
*
* <p>Persistence goes through the flat key/value map built by PlayerSettingsManager, so the storage keys
* are stable and independent of these field names.
*
* @author loki
*/
public class PlayerSettings {
private Double schematicDifficulty;
private Integer blockLead;
private Boolean particles;
private Boolean sound;
private Boolean useSpecialBlocks;
private Boolean showFallMessage;
private Boolean showScoreboard;
private Boolean ghostRecording;
private Integer selectedTime;
private String style;
private List<String> collectedRewards;
public Double schematicDifficulty() {
return schematicDifficulty;
}
public void setSchematicDifficulty(Double schematicDifficulty) {
this.schematicDifficulty = schematicDifficulty;
}
public Integer blockLead() {
return blockLead;
}
public void setBlockLead(Integer blockLead) {
this.blockLead = blockLead;
}
public Boolean particles() {
return particles;
}
public void setParticles(Boolean particles) {
this.particles = particles;
}
public Boolean sound() {
return sound;
}
public void setSound(Boolean sound) {
this.sound = sound;
}
public Boolean useSpecialBlocks() {
return useSpecialBlocks;
}
public void setUseSpecialBlocks(Boolean useSpecialBlocks) {
this.useSpecialBlocks = useSpecialBlocks;
}
public Boolean showFallMessage() {
return showFallMessage;
}
public void setShowFallMessage(Boolean showFallMessage) {
this.showFallMessage = showFallMessage;
}
public Boolean showScoreboard() {
return showScoreboard;
}
public void setShowScoreboard(Boolean showScoreboard) {
this.showScoreboard = showScoreboard;
}
public Boolean ghostRecording() {
return ghostRecording;
}
public void setGhostRecording(Boolean ghostRecording) {
this.ghostRecording = ghostRecording;
}
public Integer selectedTime() {
return selectedTime;
}
public void setSelectedTime(Integer selectedTime) {
this.selectedTime = selectedTime;
}
public String style() {
return style;
}
public void setStyle(String style) {
this.style = style;
}
/** Reward keys already claimed by this player; never null after first access. */
public List<String> collectedRewards() {
if (collectedRewards == null) {
collectedRewards = new ArrayList<>();
}
return collectedRewards;
}
}