mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-27 03:04:43 +02:00
Address some deprecations for regions and biome setting
This commit is contained in:
@ -40,7 +40,6 @@ import com.plotsquared.core.queue.QueueCoordinator;
|
||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||
import com.plotsquared.core.util.ChunkManager;
|
||||
import com.plotsquared.core.util.RegionManager;
|
||||
import com.plotsquared.core.util.RegionUtil;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.plotsquared.core.util.entity.EntityCategories;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
@ -261,7 +260,7 @@ public class BukkitRegionManager extends RegionManager {
|
||||
if (checkX2 && checkZ2) {
|
||||
map.saveRegion(world, xxt2, xxt, zzt2, zzt); //
|
||||
}
|
||||
CuboidRegion currentPlotClear = RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
|
||||
CuboidRegion currentPlotClear = new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3());
|
||||
map.saveEntitiesOut(Bukkit.getWorld(world.getName()).getChunkAt(x, z), currentPlotClear);
|
||||
AugmentedUtils.bypass(
|
||||
ignoreAugment,
|
||||
@ -300,7 +299,7 @@ public class BukkitRegionManager extends RegionManager {
|
||||
}, world.getName(), chunk)
|
||||
);
|
||||
//map.restoreBlocks(worldObj, 0, 0);
|
||||
map.restoreEntities(Bukkit.getWorld(world.getName()), 0, 0);
|
||||
map.restoreEntities(Bukkit.getWorld(world.getName()));
|
||||
});
|
||||
regenQueue.setCompleteTask(whenDone);
|
||||
queue.setCompleteTask(regenQueue::enqueue);
|
||||
|
@ -44,7 +44,6 @@ import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -61,7 +60,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
@ -386,27 +384,6 @@ public class BukkitUtil extends WorldUtil {
|
||||
return new StringComparison<BlockState>().new ComparisonResult(1, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiomes(
|
||||
final @NonNull String worldName,
|
||||
final @NonNull CuboidRegion region,
|
||||
final @NonNull BiomeType biomeType
|
||||
) {
|
||||
final World world = getWorld(worldName);
|
||||
if (world == null) {
|
||||
LOGGER.warn("An error occurred while setting the biome because the world was null", new RuntimeException());
|
||||
return;
|
||||
}
|
||||
final Biome biome = BukkitAdapter.adapt(biomeType);
|
||||
for (int x = region.getMinimumPoint().getX(); x <= region.getMaximumPoint().getX(); x++) {
|
||||
for (int z = region.getMinimumPoint().getZ(); z <= region.getMaximumPoint().getZ(); z++) {
|
||||
if (world.getBiome(x, z) != biome) {
|
||||
world.setBiome(x, z, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.sk89q.worldedit.world.@NonNull World getWeWorld(final @NonNull String world) {
|
||||
return new BukkitWorld(Bukkit.getWorld(world));
|
||||
|
@ -70,7 +70,7 @@ public class ContentMap {
|
||||
}
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
saveBlocks(world, x, z, 0, 0);
|
||||
saveBlocks(world, x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,14 +92,7 @@ public class ContentMap {
|
||||
}
|
||||
}
|
||||
|
||||
void saveEntitiesIn(Chunk chunk, CuboidRegion region) {
|
||||
saveEntitiesIn(chunk, region, 0, 0, false);
|
||||
}
|
||||
|
||||
void saveEntitiesIn(
|
||||
Chunk chunk, CuboidRegion region, int offsetX, int offsetZ,
|
||||
boolean delete
|
||||
) {
|
||||
void saveEntitiesIn(Chunk chunk, CuboidRegion region, boolean delete) {
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||
int x = location.getX();
|
||||
@ -111,8 +104,6 @@ public class ContentMap {
|
||||
continue;
|
||||
}
|
||||
EntityWrapper wrap = new ReplicatingEntityWrapper(entity, (short) 2);
|
||||
wrap.x += offsetX;
|
||||
wrap.z += offsetZ;
|
||||
wrap.saveEntity();
|
||||
this.entities.add(wrap);
|
||||
if (delete) {
|
||||
@ -123,10 +114,10 @@ public class ContentMap {
|
||||
}
|
||||
}
|
||||
|
||||
void restoreEntities(World world, int xOffset, int zOffset) {
|
||||
void restoreEntities(World world) {
|
||||
for (EntityWrapper entity : this.entities) {
|
||||
try {
|
||||
entity.spawn(world, xOffset, zOffset);
|
||||
entity.spawn(world, 0, 0);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to restore entity", e);
|
||||
}
|
||||
@ -134,13 +125,13 @@ public class ContentMap {
|
||||
this.entities.clear();
|
||||
}
|
||||
|
||||
private void saveBlocks(BukkitWorld world, int x, int z, int offsetX, int offsetZ) {
|
||||
private void saveBlocks(BukkitWorld world, int x, int z) {
|
||||
BaseBlock[] ids = new BaseBlock[world.getMaxY() - world.getMinY() + 1];
|
||||
for (short yIndex = 0; yIndex <= world.getMaxY() - world.getMinY(); yIndex++) {
|
||||
BaseBlock block = world.getFullBlock(BlockVector3.at(x, yIndex + world.getMinY(), z));
|
||||
ids[yIndex] = block;
|
||||
}
|
||||
PlotLoc loc = new PlotLoc(x + offsetX, z + offsetZ);
|
||||
PlotLoc loc = new PlotLoc(x, z);
|
||||
this.allBlocks.put(loc, ids);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user