Merge pull request 'Waterremover improvements' (#225) from improveWaterremover into master
Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Commit
61668b7292
@ -20,7 +20,7 @@
|
||||
package de.steamwar.fightsystem.utils;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import org.bukkit.Material;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
@ -29,49 +29,34 @@ import java.util.List;
|
||||
public class WaterRemover {
|
||||
private WaterRemover(){}
|
||||
|
||||
private static final int MIN_Y = Config.AlignWater ? Config.TeamBlueCornerY + Config.WaterDepth : Config.TeamBlueCornerY;
|
||||
|
||||
public static void add(List<Block> l) {
|
||||
for(Block b : l){
|
||||
//b cannot be water or air due to current explosion
|
||||
|
||||
int startX = b.getX();
|
||||
int startY = b.getY();
|
||||
int startZ = b.getZ();
|
||||
try{
|
||||
checkBlock(b.getRelative(BlockFace.EAST), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.WEST), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.NORTH), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.SOUTH), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.UP), startX, startY, startZ);
|
||||
}catch(IsAnOcean e){
|
||||
//ignore
|
||||
}
|
||||
checkBlock(b.getRelative(BlockFace.UP));
|
||||
checkBlock(b.getRelative(BlockFace.EAST));
|
||||
checkBlock(b.getRelative(BlockFace.WEST));
|
||||
checkBlock(b.getRelative(BlockFace.NORTH));
|
||||
checkBlock(b.getRelative(BlockFace.SOUTH));
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkBlock(Block b, int startX, int startY, int startZ) throws IsAnOcean {
|
||||
private static void checkBlock(Block b) {
|
||||
if(!removeWater(b))
|
||||
return;
|
||||
|
||||
// If distance to original block is greater than 20
|
||||
if(Math.abs(startX - b.getX()) + Math.abs(startY - b.getY() + Math.abs(startZ - b.getZ())) >= 20){
|
||||
b.setType(Material.WATER);
|
||||
throw new IsAnOcean();
|
||||
}
|
||||
if(b.getY() < MIN_Y)
|
||||
return;
|
||||
|
||||
try{
|
||||
checkBlock(b.getRelative(BlockFace.EAST), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.WEST), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.NORTH), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.SOUTH), startX, startY, startZ);
|
||||
checkBlock(b.getRelative(BlockFace.UP), startX, startY, startZ);
|
||||
}catch(IsAnOcean e){
|
||||
b.setType(Material.WATER);
|
||||
throw e;
|
||||
}
|
||||
checkBlock(b.getRelative(BlockFace.UP));
|
||||
checkBlock(b.getRelative(BlockFace.EAST));
|
||||
checkBlock(b.getRelative(BlockFace.WEST));
|
||||
checkBlock(b.getRelative(BlockFace.NORTH));
|
||||
checkBlock(b.getRelative(BlockFace.SOUTH));
|
||||
}
|
||||
|
||||
private static class IsAnOcean extends Throwable{}
|
||||
|
||||
public static boolean isWater(Block block){
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren