SteamWar/FightSystem
Archiviert
13
1

Merge branch 'master' into gm1Spectator

Dieser Commit ist enthalten in:
Lixfel 2020-10-28 11:16:32 +01:00
Commit 97dd9794ef
4 geänderte Dateien mit 48 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -37,4 +37,24 @@ class WaterRemover_14 {
return ((Waterlogged) data).isWaterlogged();
}
static boolean removeWater(Block block){
if(block.getType() == Material.WATER){
block.setType(Material.AIR);
return true;
}
BlockData data = block.getBlockData();
if(!(data instanceof Waterlogged))
return false;
Waterlogged waterlogged = (Waterlogged) data;
if(waterlogged.isWaterlogged()){
waterlogged.setWaterlogged(false);
block.setBlockData(waterlogged);
return true;
}
return false;
}
}

Datei anzeigen

@ -29,4 +29,12 @@ public class WaterRemover_8 {
Material type = block.getType();
return type == Material.WATER || type == Material.STATIONARY_WATER;
}
static boolean removeWater(Block block){
if(isWater(block)){
block.setType(Material.AIR);
return true;
}
return false;
}
}

Datei anzeigen

@ -76,7 +76,7 @@ public class FightScoreboard {
objective.setDisplayName(fightTeam.getColoredName());
fightTeam.getPlayers().forEach(fp -> {
if(fp.isLiving())
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) fp.getPlayer().getHealth());
objective.getScore(fightTeam.getPrefix() + fp.getPlayer().getName()).setScore((int) Math.ceil(fp.getPlayer().getHealth()));
});
}

Datei anzeigen

@ -49,14 +49,15 @@ public class WaterRemover {
}
private static void checkBlock(Block b, int startX, int startY, int startZ) throws IsAnOcean {
if(!isWater(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)
if(Math.abs(startX - b.getX()) + Math.abs(startY - b.getY() + Math.abs(startZ - b.getZ())) >= 20){
b.setType(Material.WATER);
throw new IsAnOcean();
}
b.setType(Material.AIR);
try{
checkBlock(b.getRelative(BlockFace.EAST), startX, startY, startZ);
checkBlock(b.getRelative(BlockFace.WEST), startX, startY, startZ);
@ -84,4 +85,19 @@ public class WaterRemover {
return WaterRemover_14.isWater(block);
}
}
public static boolean removeWater(Block block){
//checks for water and removes it, if present
switch(Core.getVersion()){
case 8:
case 9:
case 10:
case 12:
return WaterRemover_8.removeWater(block);
case 14:
case 15:
default:
return WaterRemover_14.removeWater(block);
}
}
}