mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-02-05 13:00:30 +08:00
Fix watchdog, add negative y support. (#1782)
This commit is contained in:
parent
043c3315aa
commit
a57f66f7cc
@ -125,7 +125,7 @@ public int schedule(long delay, long period, Runnable task) {
|
||||
|
||||
@Override
|
||||
public Watchdog getWatchdog() {
|
||||
return watchdog.valueOrThrow();
|
||||
return watchdog.value().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,6 +59,8 @@
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
@ -76,6 +78,9 @@ public class BukkitWorld extends AbstractWorld {
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
private static final boolean HAS_3D_BIOMES;
|
||||
private static final boolean HAS_MIN_Y;
|
||||
private static final Method GET_MIN_Y;
|
||||
private int minY;
|
||||
|
||||
private static final Map<Integer, Effect> effects = new HashMap<>();
|
||||
|
||||
@ -94,6 +99,16 @@ public class BukkitWorld extends AbstractWorld {
|
||||
temp = false;
|
||||
}
|
||||
HAS_3D_BIOMES = temp;
|
||||
Method tempGetMinY;
|
||||
try {
|
||||
tempGetMinY = World.class.getMethod("getMinHeight");
|
||||
temp = true;
|
||||
} catch (NoSuchMethodException e) {
|
||||
tempGetMinY = null;
|
||||
temp = false;
|
||||
}
|
||||
GET_MIN_Y = tempGetMinY;
|
||||
HAS_MIN_Y = temp;
|
||||
}
|
||||
|
||||
private final WeakReference<World> worldRef;
|
||||
@ -112,6 +127,13 @@ public BukkitWorld(World world) {
|
||||
} else {
|
||||
this.worldNativeAccess = null;
|
||||
}
|
||||
if (HAS_MIN_Y) {
|
||||
try {
|
||||
minY = (int) GET_MIN_Y.invoke(world);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
minY = super.getMinY();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -350,6 +372,15 @@ public int getMaxY() {
|
||||
return getWorld().getMaxHeight() - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinY() {
|
||||
/*if (HAS_MIN_Y) {
|
||||
return getWorld().getMinHeight();
|
||||
}
|
||||
return super.getMinY();*/
|
||||
return minY;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void fixAfterFastMode(Iterable<BlockVector2> chunks) {
|
||||
|
Loading…
Reference in New Issue
Block a user