From 26d97bf7eb146dffdfa7591ba7bb2853e04813ac Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 28 Apr 2017 19:29:23 +0100 Subject: [PATCH] Up the water damage check rate --- .../game/arcade/managers/GameFlagManager.java | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index b7a2119d0..e711f894c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -1084,41 +1084,40 @@ public class GameFlagManager implements Listener @EventHandler public void WorldWaterDamage(UpdateEvent event) { - if (event.getType() != UpdateType.FAST) - return; - - Game game = Manager.GetGame(); - if (game == null) return; - - if (!game.IsLive()) - return; - - if (game.WorldWaterDamage <= 0) + if (event.getType() != UpdateType.FASTER) { - if (!game.WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty()) - { - game.WorldWaterDamage = 4; - } - else - { - return; - } + return; } - for (GameTeam team : game.GetTeamList()) - for (Player player : team.GetPlayers(true)) - 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) - { - //Damage Event - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.DROWNING, game.WorldWaterDamage, true, false, false, - "Water", "Water Damage"); + Game game = Manager.GetGame(); + if (game == null || !game.IsLive()) + { + return; + } - player.getWorld().playSound(player.getLocation(), - Sound.SPLASH, 0.8f, - 1f + (float) Math.random() / 2); - } + if (game.WorldWaterDamage <= 0 && !game.WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty()) + { + 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)