fix: Wrap World#getMinHeight with fallback for older Minecraft versions

The method did not exist *back then* and we still want to support Spigot 1.8.8
This commit is contained in:
Christian Koop 2024-03-27 19:47:18 +01:00
parent e9642ad0cc
commit 7d86423744
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
2 changed files with 19 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package com.craftaro.skyblock.blockscanner;
import com.craftaro.core.compatibility.CompatibleMaterial;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.skyblock.utils.world.WorldUtil;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.skyblock.SkyBlock;
import com.craftaro.skyblock.island.Island;
@ -114,7 +115,7 @@ public final class BlockScanner extends BukkitRunnable {
if (ignoreY) {
startY = world.getMaxHeight();
} else {
startY = !ignoreLiquidsY && liquidSection.getBoolean("Enable") && !config.getBoolean("Island.Levelling.ScanLiquid") ? liquidSection.getInt("Height") + 1 : world.getMinHeight();
startY = !ignoreLiquidsY && liquidSection.getBoolean("Enable") && !config.getBoolean("Island.Levelling.ScanLiquid") ? liquidSection.getInt("Height") + 1 : WorldUtil.getMinHeight(world);
}
for (List<CachedChunk> sub : parts) {
@ -148,7 +149,7 @@ public final class BlockScanner extends BukkitRunnable {
if (this.island != null) {
Location islandLocation = this.island.getLocation(worldManager.getIslandWorld(world), IslandEnvironment.ISLAND);
Location minLocation = new Location(world, islandLocation.getBlockX() - this.island.getRadius(), world.getMinHeight(), islandLocation.getBlockZ() - this.island.getRadius());
Location minLocation = new Location(world, islandLocation.getBlockX() - this.island.getRadius(), WorldUtil.getMinHeight(world), islandLocation.getBlockZ() - this.island.getRadius());
Location maxLocation = new Location(world, islandLocation.getBlockX() + this.island.getRadius(), world.getMaxHeight(), islandLocation.getBlockZ() + this.island.getRadius());
int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX());

View File

@ -0,0 +1,16 @@
package com.craftaro.skyblock.utils.world;
import org.bukkit.World;
public final class WorldUtil {
private WorldUtil() {
}
public static int getMinHeight(World world) {
try {
return world.getMinHeight();
} catch (NoSuchMethodError e) {
return 0;
}
}
}