Fixed bug where revealer doesn't always work

Prevent players from trading with sneaky assassin npcs
Display message when user powers up
This commit is contained in:
CoderTim 2014-07-18 02:48:06 -04:00
parent 64feaf63ed
commit efa74f509a
4 changed files with 60 additions and 39 deletions

View File

@ -14,6 +14,7 @@ import nautilus.game.arcade.kit.*;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.*; import org.bukkit.event.*;
import org.bukkit.event.player.*;
import java.util.*; import java.util.*;
@ -123,6 +124,13 @@ public class SneakyAssassins extends SoloGame
event.AddMod(GetName(), "Sword Damage", damage - event.GetDamage(), false); event.AddMod(GetName(), "Sword Damage", damage - event.GetDamage(), false);
} }
@EventHandler(ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
{
if(event.getRightClicked() instanceof Villager)
event.setCancelled(true);
}
public NpcManager getNpcManager() public NpcManager getNpcManager()
{ {
return _npcManager; return _npcManager;

View File

@ -39,11 +39,13 @@ public class ArmorPowerUp extends PowerUp
@Override @Override
public void powerUpPlayer(Player player) public void powerUpPlayer(Player player)
{ {
powerUpArmor(player); if(powerUpArmor(player) || powerUpArmor(player))
powerUpArmor(player); player.sendMessage("Your armor was upgraded!");
else
player.sendMessage("Your armor is already fully upgraded!");
} }
private void powerUpArmor(Player player) private boolean powerUpArmor(Player player)
{ {
ItemStack[] armor = player.getInventory().getArmorContents(); ItemStack[] armor = player.getInventory().getArmorContents();
@ -65,8 +67,10 @@ public class ArmorPowerUp extends PowerUp
armor[choice] = new ItemStack(ARMOR_PROGRESSION.get(choice).get(nextLevel)); armor[choice] = new ItemStack(ARMOR_PROGRESSION.get(choice).get(nextLevel));
player.getInventory().setArmorContents(armor); player.getInventory().setArmorContents(armor);
return; return true;
} }
} }
return false;
} }
} }

View File

@ -33,8 +33,12 @@ public class WeaponPowerUp extends PowerUp
int newSwordType = Math.min(SWORD_PROGRESSION.size() - 1, swordType + 1); int newSwordType = Math.min(SWORD_PROGRESSION.size() - 1, swordType + 1);
player.getInventory().setItem(swordSlot, new ItemStack(SWORD_PROGRESSION.get(newSwordType))); player.getInventory().setItem(swordSlot, new ItemStack(SWORD_PROGRESSION.get(newSwordType)));
player.sendMessage("You sword was upgraded!");
return; return;
} }
} }
player.sendMessage("Your sword is already fully upgraded!");
} }
} }

View File

@ -66,8 +66,48 @@ public class PerkRevealer extends Perk implements IThrown
Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 1d); Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 1d);
} }
@EventHandler
public void onUpdate(UpdateEvent event)
{
if(event.getType() == UpdateType.SEC)
{
for(Iterator<Map.Entry<Player, RevealedPlayerInfo>> it = getRevealedPlayers().entrySet().iterator(); it.hasNext();)
{
Map.Entry<Player, RevealedPlayerInfo> entry = it.next();
if(!entry.getKey().isOnline())
it.remove();
else if(entry.getValue()._expirationSeconds <= 0)
{
it.remove();
Manager.GetDisguise().disguise(entry.getValue()._disguise);
}
else
entry.getValue()._expirationSeconds--;
}
}
}
@Override @Override
public void Collide(LivingEntity target, Block block, ProjectileUser data) public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
explode(data);
}
@Override
public void Idle(ProjectileUser data)
{
explode(data);
}
@Override
public void Expire(ProjectileUser data)
{
explode(data);
}
private void explode(ProjectileUser data)
{ {
FireworkEffect effect = FireworkEffect FireworkEffect effect = FireworkEffect
.builder() .builder()
@ -103,41 +143,6 @@ public class PerkRevealer extends Perk implements IThrown
data.GetThrown().remove(); data.GetThrown().remove();
} }
@EventHandler
public void onUpdate(UpdateEvent event)
{
if(event.getType() == UpdateType.SEC)
{
for(Iterator<Map.Entry<Player, RevealedPlayerInfo>> it = getRevealedPlayers().entrySet().iterator(); it.hasNext();)
{
Map.Entry<Player, RevealedPlayerInfo> entry = it.next();
if(!entry.getKey().isOnline())
it.remove();
else if(entry.getValue()._expirationSeconds <= 0)
{
it.remove();
Manager.GetDisguise().disguise(entry.getValue()._disguise);
}
else
entry.getValue()._expirationSeconds--;
}
}
}
@Override
public void Idle(ProjectileUser data)
{
}
@Override
public void Expire(ProjectileUser data)
{
}
public Map<Player, RevealedPlayerInfo> getRevealedPlayers() public Map<Player, RevealedPlayerInfo> getRevealedPlayers()
{ {
return _revealedPlayers; return _revealedPlayers;