Up the water damage check rate

This commit is contained in:
Sam 2017-04-28 19:29:23 +01:00
parent 59699f930e
commit 26d97bf7eb

View File

@ -1084,40 +1084,39 @@ public class GameFlagManager implements Listener
@EventHandler @EventHandler
public void WorldWaterDamage(UpdateEvent event) public void WorldWaterDamage(UpdateEvent event)
{ {
if (event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.FASTER)
{
return; return;
}
Game game = Manager.GetGame(); Game game = Manager.GetGame();
if (game == null) return; if (game == null || !game.IsLive())
if (!game.IsLive())
return;
if (game.WorldWaterDamage <= 0)
{ {
if (!game.WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty()) return;
}
if (game.WorldWaterDamage <= 0 && !game.WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty())
{ {
game.WorldWaterDamage = 4; game.WorldWaterDamage = 4;
} }
else
for (Player player : game.GetPlayers(true))
{ {
return; if (!Recharge.Instance.use(player, "Water Damage", 500, false, false))
} {
continue;
} }
for (GameTeam team : game.GetTeamList()) Block block = player.getLocation().getBlock();
for (Player player : team.GetPlayers(true)) Material lower = block.getType();
if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 8 || Material upper = block.getRelative(BlockFace.UP).getType();
player.getLocation().getBlock().getTypeId() == 9 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 9)
if (lower == Material.WATER || lower == Material.STATIONARY_WATER || upper == Material.WATER || upper == Material.STATIONARY_WATER)
{ {
//Damage Event //Damage Event
Manager.GetDamage().NewDamageEvent(player, null, null, Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.DROWNING, game.WorldWaterDamage, true, false, false, "Water", "Water Damage");
DamageCause.DROWNING, game.WorldWaterDamage, true, false, false, player.getWorld().playSound(player.getLocation(), Sound.SPLASH, 0.8f, 1f + (float) Math.random() / 2);
"Water", "Water Damage"); }
player.getWorld().playSound(player.getLocation(),
Sound.SPLASH, 0.8f,
1f + (float) Math.random() / 2);
} }
} }