Fix Perks not being unregistered from the EventHandler

This commit is contained in:
xXVevzZXx 2016-10-28 18:53:48 +02:00
parent cf85742583
commit 89efc22208
4 changed files with 35 additions and 19 deletions

View File

@ -813,11 +813,35 @@ public abstract class Game implements Listener
HandlerList.unregisterAll(kit); HandlerList.unregisterAll(kit);
for (Perk perk : kit.GetPerks()) if (kit instanceof ProgressingKit)
{ {
HandlerList.unregisterAll(perk); if (((ProgressingKit) kit).hasUpgrades())
perk.unregisteredEvents(); {
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();
}
}
} }
} }

View File

@ -114,6 +114,7 @@ public class HomingArrow
arrowToPlayer.multiply(1.9); arrowToPlayer.multiply(1.9);
UtilAction.velocity(_arrow, arrowToPlayer); UtilAction.velocity(_arrow, arrowToPlayer);
if (_updates % firework == 0) if (_updates % firework == 0)
UtilFirework.playFirework(_arrow.getLocation(), Type.BALL, Color.RED, true, false); UtilFirework.playFirework(_arrow.getLocation(), Type.BALL, Color.RED, true, false);

View File

@ -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 SUPPLY_DROP_TIME = 1000*60*5; // 5 Minutes
private static final long DEATHMATCH_START_TIME = 1000*30; // 30 Seconds 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 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 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()); Player player = _tntMap.remove(event.getEntity());
for (Player other : UtilPlayer.getNearby(event.getEntity() for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), TNT_EXPLOSION_RADIUS))
.getLocation(), 14)) Manager.GetCondition().Factory().Explosion("Throwing TNT", other, player, 50, 0.1, false, false);
Manager.GetCondition()
.Factory()
.Explosion("Throwing TNT", other, player, 50, 0.1, false,
false);
Location loc = event.getEntity().getLocation(); event.setCancelled(true);
for (Block block : UtilBlock.getSurrounding(loc.getBlock(), true))
{
if (block.getType() == _boosterRings.get(0).getType())
{
event.setCancelled(true);
return;
}
}
} }
@EventHandler @EventHandler

View File

@ -15,6 +15,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.skyfall.HomingArrow; import nautilus.game.arcade.game.games.skyfall.HomingArrow;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.ProgressingKit;
/** /**
* Perk that lets Players shot * Perk that lets Players shot
@ -53,7 +54,7 @@ public class PerkDeadeye extends Perk
return; return;
Player shooter = (Player) event.getEntity(); Player shooter = (Player) event.getEntity();
if (!hasPerk(shooter)) if (!hasPerk(shooter))
return; return;