Prevent fully powered-up Sneaky Assassin players from using additional power-ups

This commit is contained in:
CoderTim 2014-07-21 16:29:15 -04:00
parent d2038670d6
commit 4460f2e651
4 changed files with 23 additions and 11 deletions

View File

@ -37,12 +37,20 @@ public class ArmorPowerUp extends PowerUp
}
@Override
public void powerUpPlayer(Player player)
public boolean powerUpPlayer(Player player)
{
if(powerUpArmor(player) || powerUpArmor(player))
if (powerUpArmor(player) || powerUpArmor(player))
{
player.sendMessage("Your armor was upgraded!");
return true;
}
else
{
player.sendMessage("Your armor is already fully upgraded!");
return false;
}
}
private boolean powerUpArmor(Player player)

View File

@ -108,5 +108,5 @@ public abstract class PowerUp
getPowerUpManager().removePowerUp(this);
}
public abstract void powerUpPlayer(Player player);
public abstract boolean powerUpPlayer(Player player);
}

View File

@ -145,21 +145,23 @@ public class PowerUpManager implements Listener
event.setCancelled(true);
}
@EventHandler
public void onPlayerPickUpPowerUp(PlayerPickupItemEvent event)
@EventHandler(ignoreCancelled = true)
public void onPlayerPickUpPowerUp(final PlayerPickupItemEvent event)
{
if (getGame().GetTeam(event.getPlayer()) != null)
{
PowerUp powerUp = getPowerUpByItem(event.getItem());
final PowerUp powerUp = getPowerUpByItem(event.getItem());
if (powerUp != null)
{
event.setCancelled(true);
powerUp.powerUpPlayer(event.getPlayer());
powerUp.remove();
if (powerUp.powerUpPlayer(event.getPlayer()))
{
powerUp.remove();
schedulePowerUpSpawn(10);
schedulePowerUpSpawn(10);
}
}
}
}

View File

@ -22,7 +22,7 @@ public class WeaponPowerUp extends PowerUp
}
@Override
public void powerUpPlayer(Player player)
public boolean powerUpPlayer(Player player)
{
for (int swordType = 0; swordType < SWORD_PROGRESSION.size(); swordType++)
{
@ -35,10 +35,12 @@ public class WeaponPowerUp extends PowerUp
player.sendMessage("You sword was upgraded!");
return;
return true;
}
}
player.sendMessage("Your sword is already fully upgraded!");
return false;
}
}