Add fall detection and fix access modifiers
- Added Y-coordinate fall detection (spawn.Y - 30) - Players now respawn when falling below threshold - Fixed fall() access modifier (protected -> public) - Added debug logging for locale loading issues
This commit is contained in:
parent
c142d21a26
commit
03ee678b68
4 changed files with 34 additions and 7 deletions
|
|
@ -90,9 +90,15 @@ public class Locales {
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Item getItem(@NotNull String locale, @NotNull String path, String... replace) {
|
public static Item getItem(@NotNull String locale, @NotNull String path, String... replace) {
|
||||||
synchronized (locales) {
|
synchronized (locales) {
|
||||||
if (locales.isEmpty()) return new Item(Material.STONE, "");
|
if (locales.isEmpty()) {
|
||||||
|
LoParkour.getPlugin().getLogger().warning("Locales are empty! Returning STONE item for path: " + path);
|
||||||
|
return new Item(Material.STONE, "");
|
||||||
|
}
|
||||||
FileConfiguration config = locales.get(locale);
|
FileConfiguration config = locales.get(locale);
|
||||||
if (config == null) return new Item(Material.STONE, "");
|
if (config == null) {
|
||||||
|
LoParkour.getPlugin().getLogger().warning("Locale '" + locale + "' not found! Available: " + locales.keySet() + ". Returning STONE for path: " + path);
|
||||||
|
return new Item(Material.STONE, "");
|
||||||
|
}
|
||||||
return buildItem(config, path, replace);
|
return buildItem(config, path, replace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ public class ParkourGenerator {
|
||||||
// Lifecycle methods
|
// Lifecycle methods
|
||||||
public void startTick() { lifecycle.startTick(); }
|
public void startTick() { lifecycle.startTick(); }
|
||||||
public void tick() { lifecycle.tick(); }
|
public void tick() { lifecycle.tick(); }
|
||||||
protected void fall() { lifecycle.fall(); }
|
public void fall() { lifecycle.fall(); }
|
||||||
protected void score() { lifecycle.score(); }
|
protected void score() { lifecycle.score(); }
|
||||||
|
|
||||||
public void reset(boolean regenerate) {
|
public void reset(boolean regenerate) {
|
||||||
|
|
|
||||||
|
|
@ -44,20 +44,41 @@ public class LifecycleTickManager {
|
||||||
*/
|
*/
|
||||||
public void tick() {
|
public void tick() {
|
||||||
tickCounter++;
|
tickCounter++;
|
||||||
|
|
||||||
|
// Check if players fell below threshold
|
||||||
|
checkPlayerFall();
|
||||||
|
|
||||||
if (tickCounter % Option.CLEANUP_INTERVAL == 0) {
|
if (tickCounter % Option.CLEANUP_INTERVAL == 0) {
|
||||||
cleanup.cleanupDistantBlocks();
|
cleanup.cleanupDistantBlocks();
|
||||||
}
|
}
|
||||||
if (tickCounter % TIME_UI_INTERVAL == 0) {
|
if (tickCounter % TIME_UI_INTERVAL == 0) {
|
||||||
visualUpdater.updateTimeDisplays();
|
visualUpdater.updateTimeDisplays();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate more blocks if needed
|
// Generate more blocks if needed
|
||||||
maintainBlockLead();
|
maintainBlockLead();
|
||||||
|
|
||||||
// Update player visuals
|
// Update player visuals
|
||||||
visualUpdater.updateAllPlayers();
|
visualUpdater.updateAllPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if any player fell below the threshold.
|
||||||
|
*/
|
||||||
|
private void checkPlayerFall() {
|
||||||
|
if (generator.state.playerSpawn == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
double fallThreshold = generator.state.playerSpawn.getY() - 30;
|
||||||
|
|
||||||
|
for (var player : generator.getPlayers()) {
|
||||||
|
if (player.player.getLocation().getY() < fallThreshold) {
|
||||||
|
generator.fall();
|
||||||
|
break; // Only trigger once per tick
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset tick counter.
|
* Reset tick counter.
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ public class CoopMode implements MultiMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void fall() {
|
public void fall() {
|
||||||
// Show each player their individual contribution before reset
|
// Show each player their individual contribution before reset
|
||||||
getPlayers().forEach(pp -> {
|
getPlayers().forEach(pp -> {
|
||||||
int contrib = contributions.getOrDefault(pp.getUUID(), 0);
|
int contrib = contributions.getOrDefault(pp.getUUID(), 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue