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:
loki 2026-04-08 16:54:42 +02:00
parent 46f7b794c6
commit 9864fd6e30
10 changed files with 63 additions and 38 deletions

View file

@ -77,14 +77,26 @@ public class ElytraRingGenerator {
@NotNull
private Location constrainHeight(@NotNull Location pos, @NotNull Location origin) {
double maxHeight = origin.getY() + config.getMaxHeightAboveSpawn();
double minHeight = origin.getY() - 20; // Don't go too low
double minHeight = Math.max(
origin.getWorld().getMinHeight() + 10, // World minimum + safety margin
origin.getY() - 20 // Don't go too far below spawn
);
double worldMaxHeight = origin.getWorld().getMaxHeight() - 10; // Safety margin from world ceiling
// Constrain to configured limits
if (pos.getY() > maxHeight) {
pos.setY(maxHeight);
pos.setY(Math.min(maxHeight, worldMaxHeight));
} else if (pos.getY() < minHeight) {
pos.setY(minHeight);
}
// Final world bounds check
if (pos.getY() > worldMaxHeight) {
pos.setY(worldMaxHeight);
} else if (pos.getY() < origin.getWorld().getMinHeight()) {
pos.setY(origin.getWorld().getMinHeight() + 10);
}
return pos;
}