mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Fix up LimitExtent
- Correctly handle block state limit checks. - Don't quash exceptions thrown in a region operation by having a "max-fails" check that can only be hit once.... Fixes #1127
This commit is contained in:
parent
96ed367420
commit
391869cf3a
@ -224,239 +224,119 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
public void addCaves(Region region) throws WorldEditException {
|
public void addCaves(Region region) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
super.addCaves(region);
|
super.addCaves(region);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generate(Region region, GenBase gen) throws WorldEditException {
|
public void generate(Region region, GenBase gen) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
super.generate(region, gen);
|
super.generate(region, gen);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
|
public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
super.addSchems(region, mask, clipboards, rarity, rotate);
|
super.addSchems(region, mask, clipboards, rarity, rotate);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
|
public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
super.spawnResource(region, gen, rarity, frequency);
|
super.spawnResource(region, gen, rarity, frequency);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
super.addOre(region, mask, material, size, frequency, rarity, minY, maxY);
|
super.addOre(region, mask, material, size, frequency, rarity, minY, maxY);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOres(Region region, Mask mask) throws WorldEditException {
|
public void addOres(Region region, Mask mask) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
super.addOres(region, mask);
|
super.addOres(region, mask);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Countable<BlockType>> getBlockDistribution(Region region) {
|
public List<Countable<BlockType>> getBlockDistribution(Region region) {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
try {
|
|
||||||
return super.getBlockDistribution(region);
|
return super.getBlockDistribution(region);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
|
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
try {
|
|
||||||
return super.getBlockDistributionWithData(region);
|
return super.getBlockDistributionWithData(region);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
try {
|
|
||||||
return super.countBlocks(region, searchBlocks);
|
return super.countBlocks(region, searchBlocks);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countBlocks(Region region, Mask searchMask) {
|
public int countBlocks(Region region, Mask searchMask) {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
try {
|
|
||||||
return super.countBlocks(region, searchMask);
|
return super.countBlocks(region, searchMask);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
return super.setBlocks(region, block);
|
return super.setBlocks(region, block);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
return super.setBlocks(region, pattern);
|
return super.setBlocks(region, pattern);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
|
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
return super.replaceBlocks(region, filter, replacement);
|
return super.replaceBlocks(region, filter, replacement);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
return super.replaceBlocks(region, filter, pattern);
|
return super.replaceBlocks(region, filter, pattern);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
|
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
return super.replaceBlocks(region, mask, pattern);
|
return super.replaceBlocks(region, mask, pattern);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
public int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
return super.center(region, pattern);
|
return super.center(region, pattern);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int setBlocks(Set<BlockVector3> vset, Pattern pattern) {
|
public int setBlocks(Set<BlockVector3> vset, Pattern pattern) {
|
||||||
limit.THROW_MAX_CHANGES(vset.size());
|
limit.THROW_MAX_CHANGES(vset.size());
|
||||||
try {
|
|
||||||
return super.setBlocks(vset, pattern);
|
return super.setBlocks(vset, pattern);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Filter> T apply(Region region, T filter, boolean full) {
|
public <T extends Filter> T apply(Region region, T filter, boolean full) {
|
||||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||||
try {
|
|
||||||
return super.apply(region, filter, full);
|
return super.apply(region, filter, full);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -476,22 +356,22 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
ExtentFilterBlock block = new ExtentFilterBlock(this);
|
ExtentFilterBlock block = new ExtentFilterBlock(this);
|
||||||
for (BlockVector3 pos : positions) {
|
for (BlockVector3 pos : positions) {
|
||||||
limit.THROW_MAX_CHECKS();
|
limit.THROW_MAX_CHECKS();
|
||||||
|
try {
|
||||||
filter.applyBlock(block.init(pos));
|
filter.applyBlock(block.init(pos));
|
||||||
|
} catch (FaweException e) {
|
||||||
|
if (!limit.MAX_FAILS()) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
limit.THROW_MAX_CHECKS(size);
|
limit.THROW_MAX_CHECKS(size);
|
||||||
limit.THROW_MAX_CHANGES(size);
|
limit.THROW_MAX_CHANGES(size);
|
||||||
try {
|
|
||||||
return super.apply(positions, filter);
|
return super.apply(positions, filter);
|
||||||
} catch (FaweException e) {
|
|
||||||
if (!limit.MAX_FAILS()) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
limit.THROW_MAX_CHECKS();
|
limit.THROW_MAX_CHECKS();
|
||||||
try {
|
try {
|
||||||
@ -573,8 +453,8 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHANGES();
|
limit.THROW_MAX_CHANGES();
|
||||||
if (block.hasNbtData()) {
|
if (block.getNbtData() != null || block.getBlockType().getMaterial().isTile()) {
|
||||||
limit.MAX_BLOCKSTATES();
|
limit.THROW_MAX_BLOCKSTATES();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return super.setBlock(position, block);
|
return super.setBlock(position, block);
|
||||||
@ -589,8 +469,8 @@ public class LimitExtent extends AbstractDelegateExtent {
|
|||||||
@Override
|
@Override
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
limit.THROW_MAX_CHANGES();
|
limit.THROW_MAX_CHANGES();
|
||||||
if (block.hasNbtData()) {
|
if (block.getNbtData() != null || block.getBlockType().getMaterial().isTile()) {
|
||||||
limit.MAX_BLOCKSTATES();
|
limit.THROW_MAX_BLOCKSTATES();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return super.setBlock(x, y, z, block);
|
return super.setBlock(x, y, z, block);
|
||||||
|
Loading…
Reference in New Issue
Block a user