Fixed exploit in Tree Feller

This commit is contained in:
nossr50 2012-02-24 04:52:30 -08:00
parent 04f13ab090
commit 3ff9a28fa7

View File

@ -54,7 +54,7 @@ public class WoodCutting
ArrayList<Block> toBeFelled = new ArrayList<Block>(); ArrayList<Block> toBeFelled = new ArrayList<Block>();
//NOTE: Tree Feller will cut upwards like how you actually fell trees //NOTE: Tree Feller will cut upwards like how you actually fell trees
processTreeFelling(firstBlock, world, toBeFelled); processTreeFelling(firstBlock, world, toBeFelled, plugin);
removeBlocks(toBeFelled, player, PP, plugin); removeBlocks(toBeFelled, player, PP, plugin);
} }
@ -172,7 +172,7 @@ public class WoodCutting
return block.getType() == Material.LOG || block.getType() == Material.LEAVES || block.getType() == Material.AIR; return block.getType() == Material.LOG || block.getType() == Material.LEAVES || block.getType() == Material.AIR;
} }
private static void processTreeFelling(Block currentBlock, World world, ArrayList<Block> toBeFelled) private static void processTreeFelling(Block currentBlock, World world, ArrayList<Block> toBeFelled, mcMMO plugin)
{ {
int x = currentBlock.getX(), y = currentBlock.getY(), z = currentBlock.getZ(); int x = currentBlock.getX(), y = currentBlock.getY(), z = currentBlock.getZ();
@ -187,23 +187,27 @@ public class WoodCutting
Block zPositive = world.getBlockAt(x, y, z+1); Block zPositive = world.getBlockAt(x, y, z+1);
Block zNegative = world.getBlockAt(x, y, z-1); Block zNegative = world.getBlockAt(x, y, z-1);
if(!isTooAgressive(isAirOrLeaves, xPositive) && treeFellerCompatible(xPositive) && !toBeFelled.contains(xPositive)) if(!plugin.misc.blockWatchList.contains(currentBlock) &&
processTreeFelling(xPositive, world, toBeFelled); !isTooAgressive(isAirOrLeaves, xPositive) && treeFellerCompatible(xPositive) && !toBeFelled.contains(xPositive))
if(!isTooAgressive(isAirOrLeaves, xNegative) && treeFellerCompatible(xNegative) && !toBeFelled.contains(xNegative)) processTreeFelling(xPositive, world, toBeFelled, plugin);
processTreeFelling(xNegative, world, toBeFelled); if(!plugin.misc.blockWatchList.contains(currentBlock) &&
if(!isTooAgressive(isAirOrLeaves, zPositive) && treeFellerCompatible(zPositive) && !toBeFelled.contains(zPositive)) !isTooAgressive(isAirOrLeaves, xNegative) && treeFellerCompatible(xNegative) && !toBeFelled.contains(xNegative))
processTreeFelling(zPositive, world, toBeFelled); processTreeFelling(xNegative, world, toBeFelled, plugin);
if(!isTooAgressive(isAirOrLeaves, zNegative) && treeFellerCompatible(zNegative) && !toBeFelled.contains(zNegative)) if(!plugin.misc.blockWatchList.contains(currentBlock) &&
processTreeFelling(zNegative, world, toBeFelled); !isTooAgressive(isAirOrLeaves, zPositive) && treeFellerCompatible(zPositive) && !toBeFelled.contains(zPositive))
processTreeFelling(zPositive, world, toBeFelled, plugin);
if(!plugin.misc.blockWatchList.contains(currentBlock) &&
!isTooAgressive(isAirOrLeaves, zNegative) && treeFellerCompatible(zNegative) && !toBeFelled.contains(zNegative))
processTreeFelling(zNegative, world, toBeFelled, plugin);
//Finally go Y+ //Finally go Y+
Block yPositive = world.getBlockAt(x, y+1, z); Block yPositive = world.getBlockAt(x, y+1, z);
if(treeFellerCompatible(yPositive)) if(treeFellerCompatible(yPositive))
{ {
if(!toBeFelled.contains(yPositive)) if(!plugin.misc.blockWatchList.contains(currentBlock) && !toBeFelled.contains(yPositive))
{ {
processTreeFelling(yPositive, world, toBeFelled); processTreeFelling(yPositive, world, toBeFelled, plugin);
} }
} }
} }