mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Better exception handling when setting data to LimitedRegion during chunk population
This commit is contained in:
parent
e159fa054d
commit
f17aa377b7
@ -34,6 +34,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.generator.LimitedRegion;
|
import org.bukkit.generator.LimitedRegion;
|
||||||
@ -46,6 +48,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
*/
|
*/
|
||||||
public class LimitedRegionWrapperQueue extends DelegateQueueCoordinator {
|
public class LimitedRegionWrapperQueue extends DelegateQueueCoordinator {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
private final LimitedRegion limitedRegion;
|
private final LimitedRegion limitedRegion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,7 +71,12 @@ public class LimitedRegionWrapperQueue extends DelegateQueueCoordinator {
|
|||||||
if (result && id.hasNbtData()) {
|
if (result && id.hasNbtData()) {
|
||||||
CompoundTag tag = id.getNbtData();
|
CompoundTag tag = id.getNbtData();
|
||||||
StateWrapper sw = new StateWrapper(tag);
|
StateWrapper sw = new StateWrapper(tag);
|
||||||
sw.restoreTag(limitedRegion.getBlockState(x, y, z).getBlock());
|
try {
|
||||||
|
sw.restoreTag(limitedRegion.getBlockState(x, y, z).getBlock());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
LOGGER.error("Error attempting to populate tile entity into the world at location {},{},{}", x, y, z, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -78,7 +87,7 @@ public class LimitedRegionWrapperQueue extends DelegateQueueCoordinator {
|
|||||||
limitedRegion.setType(x, y, z, BukkitAdapter.adapt(id.getBlockType()));
|
limitedRegion.setType(x, y, z, BukkitAdapter.adapt(id.getBlockType()));
|
||||||
limitedRegion.setBlockData(x, y, z, BukkitAdapter.adapt(id));
|
limitedRegion.setBlockData(x, y, z, BukkitAdapter.adapt(id));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("Error attempting to populate block into the world at location {},{},{}", x, y, z, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -86,15 +95,15 @@ public class LimitedRegionWrapperQueue extends DelegateQueueCoordinator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setEntity(@NonNull final Entity entity) {
|
public boolean setEntity(@NonNull final Entity entity) {
|
||||||
|
EntityType type = BukkitAdapter.adapt(entity.getState().getType());
|
||||||
|
double x = entity.getLocation().getX();
|
||||||
|
double y = entity.getLocation().getY();
|
||||||
|
double z = entity.getLocation().getZ();
|
||||||
|
Location location = new Location(limitedRegion.getWorld(), x, y, z);
|
||||||
try {
|
try {
|
||||||
EntityType type = BukkitAdapter.adapt(entity.getState().getType());
|
|
||||||
double x = entity.getLocation().getX();
|
|
||||||
double y = entity.getLocation().getY();
|
|
||||||
double z = entity.getLocation().getZ();
|
|
||||||
Location location = new Location(limitedRegion.getWorld(), x, y, z);
|
|
||||||
limitedRegion.spawnEntity(location, type);
|
limitedRegion.spawnEntity(location, type);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("Error attempting to populate entity into the world at location {},{},{}", (int) x, (int) y, (int) z, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -103,7 +112,12 @@ public class LimitedRegionWrapperQueue extends DelegateQueueCoordinator {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setTile(final int x, final int y, final int z, @NonNull final CompoundTag tag) {
|
public boolean setTile(final int x, final int y, final int z, @NonNull final CompoundTag tag) {
|
||||||
StateWrapper sw = new StateWrapper(tag);
|
StateWrapper sw = new StateWrapper(tag);
|
||||||
return sw.restoreTag(limitedRegion.getBlockState(x, y, z).getBlock());
|
try {
|
||||||
|
return sw.restoreTag(limitedRegion.getBlockState(x, y, z).getBlock());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
LOGGER.error("Error attempting to populate tile entity into the world at location {},{},{}", x, y, z, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user