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