Only call org.bukkit.World height methods if they're present (1.17+) (#1551)

* Only call org.bukkit.World height methods if they're present (1.17+)

* Switch to WorldEdit get height methods in GPFeature
This commit is contained in:
Jordan 2022-01-29 13:12:16 +01:00 committed by GitHub
parent 4610688fcb
commit 178604bbb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import com.fastasyncworldedit.core.queue.implementation.SingleThreadQueueExtent;
import com.fastasyncworldedit.core.util.MathMan;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
@ -283,7 +284,8 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
});
}
source = new SingleThreadQueueExtent(originalBukkitWorld.getMinHeight(), originalBukkitWorld.getMaxHeight());
source = new SingleThreadQueueExtent(BukkitWorld.HAS_MIN_Y ? originalBukkitWorld.getMinHeight() : 0,
BukkitWorld.HAS_MIN_Y ? originalBukkitWorld.getMaxHeight() : 256);
source.init(target, initSourceQueueCache(), null);
return true;
}

View File

@ -3,6 +3,7 @@ package com.fastasyncworldedit.bukkit.regions;
import com.fastasyncworldedit.core.regions.FaweMask;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.math.BlockVector3;
@ -40,12 +41,12 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
claim.getGreaterBoundaryCorner().getBlockX();
final BlockVector3 pos1 = BlockVector3.at(
claim.getLesserBoundaryCorner().getBlockX(),
player.getWorld().getMinHeight(),
wePlayer.getWorld().getMinY(),
claim.getLesserBoundaryCorner().getBlockZ()
);
final BlockVector3 pos2 = BlockVector3.at(
claim.getGreaterBoundaryCorner().getBlockX(),
player.getWorld().getMaxHeight(),
wePlayer.getWorld().getMaxY(),
claim.getGreaterBoundaryCorner().getBlockZ()
);
return new FaweMask(new CuboidRegion(pos1, pos2)) {

View File

@ -85,7 +85,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;
//FAWE start - allow access for easy checking if World#getMin/MaxHeight exists
public static final boolean HAS_MIN_Y;
//FAWE end
private static final Map<Integer, Effect> effects = new HashMap<>();