fix: resolve last 4 bugs (slab util, ice thresholds, Date hack, unsafe materials)

This commit is contained in:
loki5512344 2026-06-08 14:47:47 +02:00
parent a40c2863a9
commit 126e29f1c7
5 changed files with 49 additions and 38 deletions

View file

@ -140,12 +140,12 @@ public class GeneratorProfileManager {
}
// Add ice variants on higher difficulties
// difficulty >= ~1.0 = hard: packed ice, >= ~2.0 = expert: blue ice
if (difficulty >= 1.0) {
// difficulty >= ~0.3 = hard: packed ice, >= ~0.6 = expert: blue ice
if (difficulty >= 0.3) {
generator.state.specialChances.put(
org.bukkit.Bukkit.createBlockData("minecraft:packed_ice"), 15.0);
}
if (difficulty >= 2.0) {
if (difficulty >= 0.6) {
generator.state.specialChances.put(
org.bukkit.Bukkit.createBlockData("minecraft:blue_ice"), 10.0);
}

View file

@ -7,8 +7,7 @@ import dev.loki.loparkour.mode.base.Mode;
import dev.loki.loparkour.player.core.ParkourPlayer;
import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.time.Duration;
/**
* Manages generator statistics and time formatting.
@ -85,13 +84,22 @@ public class GeneratorStatistics {
if (generator.state.start == null) {
return "00:00.000";
}
long elapsed = java.time.Duration.between(generator.state.start, java.time.Instant.now()).toMillis();
Date date = new Date(elapsed);
SimpleDateFormat formatter = new SimpleDateFormat(format);
formatter.setTimeZone(java.util.TimeZone.getTimeZone("UTC"));
return formatter.format(date);
Duration d = Duration.ofMillis(elapsed);
if (format.equals("HH:mm:ss.SSS")) {
long hours = d.toHours();
long minutes = d.toMinutesPart();
long seconds = d.toSecondsPart();
long millis = d.toMillisPart();
return String.format("%d:%02d:%02d.%03d", hours, minutes, seconds, millis);
}
// Default: mm:ss.SSS
long totalMinutes = d.toMinutes();
long seconds = d.toSecondsPart();
long millis = d.toMillisPart();
return String.format("%d:%02d.%03d", totalMinutes, seconds, millis);
}
}

View file

@ -1,5 +1,6 @@
package dev.loki.loparkour.generator.jump.calculation;
import dev.loki.loparkour.util.misc.MaterialUtil;
import org.bukkit.Location;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
@ -46,7 +47,7 @@ public class JumpValidator {
private double getSlabHeightAdjustment(@NotNull Location location) {
try {
org.bukkit.block.Block block = location.getBlock();
if (block != null && isSlabMaterial(block.getType())) {
if (block != null && MaterialUtil.isSlabMaterial(block.getType())) {
org.bukkit.block.data.BlockData blockData = block.getBlockData();
if (blockData instanceof org.bukkit.block.data.type.Slab slab) {
if (slab.getType() == org.bukkit.block.data.type.Slab.Type.BOTTOM) {
@ -61,15 +62,6 @@ public class JumpValidator {
return 0.0; // No adjustment for full blocks
}
/**
* Check if material is a slab type.
*/
private boolean isSlabMaterial(org.bukkit.Material material) {
return material == org.bukkit.Material.SMOOTH_QUARTZ_SLAB ||
material == org.bukkit.Material.STONE_SLAB ||
material.name().endsWith("_SLAB");
}
private boolean canJumpWithAdjustment(@NotNull Vector from, @NotNull Vector to, double heightAdjustment) {
// Null safety check
if (from == null || to == null) {

View file

@ -4,6 +4,7 @@ import dev.loki.loparkour.api.core.Registry;
import dev.loki.loparkour.generator.core.coordinator.ParkourGenerator;
import dev.loki.loparkour.generator.jump.calculation.JumpType;
import dev.loki.loparkour.style.core.Style;
import dev.loki.loparkour.util.misc.MaterialUtil;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.jetbrains.annotations.NotNull;
@ -52,16 +53,12 @@ public class BlockSelector {
* can NPE on high/void parkour worlds when adjacent chunks have no loaded state.
*/
static boolean isUnsafeParkourMaterial(@NotNull Material m) {
if (m == Material.CARVED_PUMPKIN || m == Material.JACK_O_LANTERN || m == Material.PUMPKIN) {
if (m == Material.CARVED_PUMPKIN || m == Material.JACK_O_LANTERN) {
return true;
}
if (m == Material.DRAGON_EGG) {
return true;
}
String n = m.name();
if (n.endsWith("_BED")) {
return true;
}
return false;
}
@ -75,15 +72,6 @@ public class BlockSelector {
return types[(int) (Math.random() * types.length)];
}
/**
* Check if material is a slab type.
*/
public boolean isSlabMaterial(@NotNull Material material) {
return material == Material.SMOOTH_QUARTZ_SLAB ||
material == Material.STONE_SLAB ||
material.name().endsWith("_SLAB");
}
/**
* Get a slab material from the current player's style.
*/
@ -96,7 +84,7 @@ public class BlockSelector {
// Try to get a slab material from the style multiple times
for (int i = 0; i < 20; i++) {
Material material = style.getNext();
if (isSlabMaterial(material)) {
if (MaterialUtil.isSlabMaterial(material)) {
return material;
}
}
@ -110,7 +98,7 @@ public class BlockSelector {
* Check if material is a special block type that affects jump mechanics.
*/
public boolean isSpecialMaterial(@NotNull Material material) {
return isSlabMaterial(material) ||
return MaterialUtil.isSlabMaterial(material) ||
material == Material.GLASS_PANE ||
material == Material.PACKED_ICE ||
material == Material.BLUE_ICE ||

View file

@ -0,0 +1,23 @@
package dev.loki.loparkour.util.misc;
import org.bukkit.Material;
import org.jetbrains.annotations.NotNull;
/**
* Utility methods for Material handling.
*/
public final class MaterialUtil {
private MaterialUtil() {
// Utility class, no instantiation
}
/**
* Check if material is a slab type.
*/
public static boolean isSlabMaterial(@NotNull Material material) {
return material == Material.SMOOTH_QUARTZ_SLAB ||
material == Material.STONE_SLAB ||
material.name().endsWith("_SLAB");
}
}