Fix critical bugs and improve code quality
Generator & Modes: - Fix potential NPE in ParkourGenerator zone initialization - Add null check in BlockPlacer.placeNormalBlock() - Fix unsafe Map operations in CoopMode.score() - Add session validation in RaceMode delayed reset - Extract magic number to constant in SpeedrunMode (TICKS_PER_SECOND) - Add world bounds checking in ElytraRingGenerator - Fix map normalization in GeneratorProfileManager (handle zero sum) - Complete schematic implementation in BlockPlacer Storage & Database: - CRITICAL: Fix connection leak in SQLConnectionManager - Add proper try-with-resources for Connection in SQLQueryExecutor - Deprecate unsafe prepareStatement() method - Add documentation about connection management Session & Player: - Optimize muted users count calculation in SessionStateManager All changes tested and verified with build + tests passing.
This commit is contained in:
parent
46f7b794c6
commit
9864fd6e30
10 changed files with 63 additions and 38 deletions
|
|
@ -77,6 +77,8 @@ public class SpeedrunMode implements Mode {
|
|||
|
||||
private static class SpeedrunGenerator extends ParkourGenerator {
|
||||
|
||||
private static final int TICKS_PER_SECOND = 20;
|
||||
|
||||
/** Tracks scheduled tasks per block. Key = block, value = [warningTask, removalTask]. */
|
||||
private final Map<Block, ScheduledTask[]> scheduledTasks = new HashMap<>();
|
||||
|
||||
|
|
@ -109,9 +111,9 @@ public class SpeedrunMode implements Mode {
|
|||
double blockLifetime = Config.CONFIG.getDouble("modes.speedrun.block-lifetime");
|
||||
double warningTime = Config.CONFIG.getDouble("modes.speedrun.warning-time");
|
||||
|
||||
// Convert seconds → ticks (20 ticks/s), minimum 1 tick
|
||||
long removalTicks = Math.max(1, Math.round(blockLifetime * 20));
|
||||
long warningTicks = Math.max(1, Math.round(warningTime * 20));
|
||||
// Convert seconds → ticks, minimum 1 tick
|
||||
long removalTicks = Math.max(1, Math.round(blockLifetime * TICKS_PER_SECOND));
|
||||
long warningTicks = Math.max(1, Math.round(warningTime * TICKS_PER_SECOND));
|
||||
|
||||
ScheduledTask warningTask = Scheduler.get(LoParkour.getPlugin()).runLater(() -> {
|
||||
if (block.getType() != Material.AIR) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue