allow Snow & Iron Golems to be made in the arena. Track them and display when they die

This commit is contained in:
Brian
2012-05-22 02:04:26 -04:00
parent e473c72743
commit 76dc0c1df3
4 changed files with 30 additions and 5 deletions
+2 -1
View File
@@ -605,7 +605,7 @@ public class ArenaImpl implements Arena
arenaPlayers.remove(p); arenaPlayers.remove(p);
restoreInvAndExp(p); restoreInvAndExp(p);
if(inLobby(p) || inArena(p)) if (inLobby(p) || inArena(p))
refund(p); refund(p);
movePlayerToEntry(p); movePlayerToEntry(p);
@@ -661,6 +661,7 @@ public class ArenaImpl implements Arena
movePlayerToSpec(p); movePlayerToSpec(p);
//TODO revert if people throw a fit. Should help deter removing valuables from the arena //TODO revert if people throw a fit. Should help deter removing valuables from the arena
Messenger.tellPlayer(p, Msg.SPEC_FROM_ARENA); Messenger.tellPlayer(p, Msg.SPEC_FROM_ARENA);
Messenger.tellPlayer(p, Msg.MISC_MA_LEAVE_REMINDER);
//restoreInvAndExp(p); //restoreInvAndExp(p);
} else { } else {
restoreInvAndExp(p); restoreInvAndExp(p);
@@ -272,8 +272,13 @@ public class ArenaListener
} }
if (event.getSpawnReason() != SpawnReason.CUSTOM) { if (event.getSpawnReason() != SpawnReason.CUSTOM) {
event.setCancelled(true); if (event.getSpawnReason() == SpawnReason.BUILD_IRONGOLEM || event.getSpawnReason() == SpawnReason.BUILD_SNOWMAN) {
return; monsters.addGolem(event.getEntity());
}
else {
event.setCancelled(true);
return;
}
} }
LivingEntity entity = (LivingEntity) event.getEntity(); LivingEntity entity = (LivingEntity) event.getEntity();
@@ -361,6 +366,9 @@ public class ArenaListener
else if (monsters.removeMonster(event.getEntity())) { else if (monsters.removeMonster(event.getEntity())) {
onMonsterDeath(event); onMonsterDeath(event);
} }
else if (monsters.removeGolem(event.getEntity())) {
Messenger.tellAll(arena, Msg.GOLEM_DIED);
}
} }
private void onPlayerDeath(PlayerDeathEvent event, Player player) { private void onPlayerDeath(PlayerDeathEvent event, Player player) {
@@ -17,7 +17,7 @@ import com.garbagemule.MobArena.waves.MABoss;
public class MonsterManager public class MonsterManager
{ {
private Set<LivingEntity> monsters, sheep; private Set<LivingEntity> monsters, sheep, golems;
private Set<Wolf> pets; private Set<Wolf> pets;
private Map<LivingEntity,MABoss> bosses; private Map<LivingEntity,MABoss> bosses;
private Map<LivingEntity,List<ItemStack>> suppliers; private Map<LivingEntity,List<ItemStack>> suppliers;
@@ -25,6 +25,7 @@ public class MonsterManager
public MonsterManager() { public MonsterManager() {
this.monsters = new HashSet<LivingEntity>(); this.monsters = new HashSet<LivingEntity>();
this.sheep = new HashSet<LivingEntity>(); this.sheep = new HashSet<LivingEntity>();
this.golems = new HashSet<LivingEntity>();
this.pets = new HashSet<Wolf>(); this.pets = new HashSet<Wolf>();
this.bosses = new HashMap<LivingEntity,MABoss>(); this.bosses = new HashMap<LivingEntity,MABoss>();
this.suppliers = new HashMap<LivingEntity,List<ItemStack>>(); this.suppliers = new HashMap<LivingEntity,List<ItemStack>>();
@@ -33,6 +34,7 @@ public class MonsterManager
public void reset() { public void reset() {
monsters.clear(); monsters.clear();
sheep.clear(); sheep.clear();
golems.clear();
pets.clear(); pets.clear();
bosses.clear(); bosses.clear();
suppliers.clear(); suppliers.clear();
@@ -41,6 +43,7 @@ public class MonsterManager
public void clear() { public void clear() {
removeAll(monsters); removeAll(monsters);
removeAll(sheep); removeAll(sheep);
removeAll(golems);
removeAll(pets); removeAll(pets);
removeAll(bosses.keySet()); removeAll(bosses.keySet());
removeAll(suppliers.keySet()); removeAll(suppliers.keySet());
@@ -80,6 +83,18 @@ public class MonsterManager
return sheep.remove(e); return sheep.remove(e);
} }
public Set<LivingEntity> getGolems() {
return golems;
}
public void addGolem(LivingEntity e) {
golems.add(e);
}
public boolean removeGolem(LivingEntity e) {
return golems.remove(e);
}
public Set<Wolf> getPets() { public Set<Wolf> getPets() {
return pets; return pets;
} }
+2 -1
View File
@@ -29,8 +29,9 @@ public enum Msg
LEAVE_NOT_PLAYING("You are not in the arena.", "Not in arena."), LEAVE_NOT_PLAYING("You are not in the arena.", "Not in arena."),
LEAVE_PLAYER_LEFT("You left the arena. Thanks for playing!", "Left arena.", Material.WOOD_DOOR), LEAVE_PLAYER_LEFT("You left the arena. Thanks for playing!", "Left arena.", Material.WOOD_DOOR),
PLAYER_DIED("% died!", "% died!", Material.BONE), PLAYER_DIED("% died!", "% died!", Material.BONE),
GOLEM_DIED("A friendly Golem has died!", "A Golem has died!", Material.PUMPKIN),
SPEC_PLAYER_SPECTATE("Enjoy the show!", "Enjoy the show!"), SPEC_PLAYER_SPECTATE("Enjoy the show!", "Enjoy the show!"),
SPEC_FROM_ARENA("Enjoy the rest of the show! Make sure to '/ma leave' when you're finished watching!", "Enjoy the show!"), SPEC_FROM_ARENA("Enjoy the rest of the show!", "Enjoy the show!"),
SPEC_NOT_RUNNING("This arena isn't running.", "Arena not running.", Material.REDSTONE_TORCH_OFF), SPEC_NOT_RUNNING("This arena isn't running.", "Arena not running.", Material.REDSTONE_TORCH_OFF),
SPEC_EMPTY_INV("Empty your inventory first!", "Empty your inventory.", Material.CHEST), SPEC_EMPTY_INV("Empty your inventory first!", "Empty your inventory.", Material.CHEST),
SPEC_ALREADY_PLAYING("Can't spectate when in the arena!", "Already playing!"), SPEC_ALREADY_PLAYING("Can't spectate when in the arena!", "Already playing!"),