From 89efc22208e82eff8c1418b87a51490b9caec9e5 Mon Sep 17 00:00:00 2001 From: xXVevzZXx Date: Fri, 28 Oct 2016 18:53:48 +0200 Subject: [PATCH] Fix Perks not being unregistered from the EventHandler --- .../src/nautilus/game/arcade/game/Game.java | 30 +++++++++++++++++-- .../game/games/skyfall/HomingArrow.java | 1 + .../arcade/game/games/skyfall/Skyfall.java | 20 ++++--------- .../games/skyfall/kits/perks/PerkDeadeye.java | 3 +- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index f1739e81a..43b77f75c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -813,11 +813,35 @@ public abstract class Game implements Listener HandlerList.unregisterAll(kit); - for (Perk perk : kit.GetPerks()) + if (kit instanceof ProgressingKit) { - HandlerList.unregisterAll(perk); - perk.unregisteredEvents(); + if (((ProgressingKit) kit).hasUpgrades()) + { + ProgressingKit pKit = (ProgressingKit) kit; + for (Perk[] perks : pKit.getPerks()) + { + for (Perk perk : perks) + { + if (perk == null) + { + continue; + } + HandlerList.unregisterAll(perk); + perk.unregisteredEvents(); + } + } + } } + else + { + for (Perk perk : kit.GetPerks()) + { + HandlerList.unregisterAll(perk); + perk.unregisteredEvents(); + } + } + + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/HomingArrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/HomingArrow.java index c91eb303c..9131c9c0e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/HomingArrow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/HomingArrow.java @@ -114,6 +114,7 @@ public class HomingArrow arrowToPlayer.multiply(1.9); UtilAction.velocity(_arrow, arrowToPlayer); + if (_updates % firework == 0) UtilFirework.playFirework(_arrow.getLocation(), Type.BALL, Color.RED, true, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java index b47bea0bd..2d19258a7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/Skyfall.java @@ -112,6 +112,8 @@ public abstract class Skyfall extends Game private static final long SUPPLY_DROP_TIME = 1000*60*5; // 5 Minutes private static final long DEATHMATCH_START_TIME = 1000*30; // 30 Seconds private static final long DEATHMATCH_WAIT_TIME = 1000*10; // 10 Seconds + + private static final int TNT_EXPLOSION_RADIUS = 14; private static final long EAT_RECHARGE = 500; // 0.5 Second @@ -904,22 +906,10 @@ public abstract class Skyfall extends Game Player player = _tntMap.remove(event.getEntity()); - for (Player other : UtilPlayer.getNearby(event.getEntity() - .getLocation(), 14)) - Manager.GetCondition() - .Factory() - .Explosion("Throwing TNT", other, player, 50, 0.1, false, - false); + for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), TNT_EXPLOSION_RADIUS)) + Manager.GetCondition().Factory().Explosion("Throwing TNT", other, player, 50, 0.1, false, false); - Location loc = event.getEntity().getLocation(); - for (Block block : UtilBlock.getSurrounding(loc.getBlock(), true)) - { - if (block.getType() == _boosterRings.get(0).getType()) - { - event.setCancelled(true); - return; - } - } + event.setCancelled(true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/kits/perks/PerkDeadeye.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/kits/perks/PerkDeadeye.java index 4876a6506..7fecc9b30 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/kits/perks/PerkDeadeye.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/kits/perks/PerkDeadeye.java @@ -15,6 +15,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.skyfall.HomingArrow; import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; /** * Perk that lets Players shot @@ -53,7 +54,7 @@ public class PerkDeadeye extends Perk return; Player shooter = (Player) event.getEntity(); - + if (!hasPerk(shooter)) return;