mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36:45 +01:00
Fix biome setting in versions prior to 1.15
This commit is contained in:
parent
928ee3e3da
commit
7f1fbb2d69
@ -39,6 +39,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -46,6 +47,14 @@ import java.util.Set;
|
||||
|
||||
@SuppressWarnings({"unused", "WeakerAccess"}) public class BukkitUtil extends WorldUtil {
|
||||
|
||||
private static Method biomeSetter;
|
||||
static {
|
||||
try {
|
||||
biomeSetter = World.class.getMethod("setBiome", Integer.class, Integer.class, Biome.class);
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static String lastString = null;
|
||||
private static World lastWorld = null;
|
||||
|
||||
@ -425,7 +434,16 @@ import java.util.Set;
|
||||
for (int x = region.getMinimumPoint().getX(); x <= region.getMaximumPoint().getX(); x++) {
|
||||
for (int z = region.getMinimumPoint().getZ(); z <= region.getMaximumPoint().getZ(); z++) {
|
||||
for (int y = 0; y < world.getMaxHeight(); y++) {
|
||||
world.setBiome(x, y, z, biome);
|
||||
try {
|
||||
if (biomeSetter != null) {
|
||||
biomeSetter.invoke(world, x, z, biome);
|
||||
} else {
|
||||
world.setBiome(x, y, z, biome);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
PlotSquared.log("An error occurred setting the biome:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user