- 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.
55 lines
1.5 KiB
Java
55 lines
1.5 KiB
Java
package dev.loki.loparkour.elytra.obstacle;
|
|
|
|
import dev.loki.loparkour.config.locale.Locales;
|
|
import dev.loki.loparkour.leaderboard.core.Leaderboard;
|
|
import dev.loki.loparkour.mode.base.Mode;
|
|
import dev.loki.loparkour.mode.base.ModeMessages;
|
|
import dev.loki.loparkour.player.core.ParkourPlayer;
|
|
import dev.loki.loparkour.session.core.Session;
|
|
import dev.loki.loparkour.util.item.Item;
|
|
import dev.loki.loparkour.player.service.UserRegistry;
|
|
import org.bukkit.entity.Player;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
/**
|
|
* Elytra mode with client-side obstacles to fly around.
|
|
*/
|
|
public class ObstacleMode implements Mode {
|
|
|
|
private final Leaderboard leaderboard = new Leaderboard(getName(), Leaderboard.Sort.SCORE);
|
|
|
|
@Override
|
|
@NotNull
|
|
public String getName() {
|
|
return "obstacle";
|
|
}
|
|
|
|
@Override
|
|
@Nullable
|
|
public Item getItem(String locale) {
|
|
return Locales.getItem(locale, "play.elytra.obstacle");
|
|
}
|
|
|
|
@Override
|
|
@NotNull
|
|
public Leaderboard getLeaderboard() {
|
|
return leaderboard;
|
|
}
|
|
|
|
@Override
|
|
public void create(Player player) {
|
|
if (!ModeMessages.checkJoiningEnabled(player)) {
|
|
return;
|
|
}
|
|
|
|
final ParkourPlayer pp = UserRegistry.getPlayer(player);
|
|
if (pp != null && pp.session.generator() != null && pp.session.generator().getMode() instanceof ObstacleMode) {
|
|
return;
|
|
}
|
|
|
|
player.closeInventory();
|
|
|
|
Session.create(ObstacleGenerator::new, null, null, player);
|
|
}
|
|
}
|