From 76dc0c1df39d1d96df4c8d324e57c5346dda7d12 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 22 May 2012 02:04:26 -0400 Subject: [PATCH] allow Snow & Iron Golems to be made in the arena. Track them and display when they die --- src/com/garbagemule/MobArena/ArenaImpl.java | 3 ++- src/com/garbagemule/MobArena/ArenaListener.java | 12 ++++++++++-- .../garbagemule/MobArena/MonsterManager.java | 17 ++++++++++++++++- src/com/garbagemule/MobArena/Msg.java | 3 ++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/com/garbagemule/MobArena/ArenaImpl.java b/src/com/garbagemule/MobArena/ArenaImpl.java index d1e2638..dc8e221 100644 --- a/src/com/garbagemule/MobArena/ArenaImpl.java +++ b/src/com/garbagemule/MobArena/ArenaImpl.java @@ -605,7 +605,7 @@ public class ArenaImpl implements Arena arenaPlayers.remove(p); restoreInvAndExp(p); - if(inLobby(p) || inArena(p)) + if (inLobby(p) || inArena(p)) refund(p); movePlayerToEntry(p); @@ -661,6 +661,7 @@ public class ArenaImpl implements Arena movePlayerToSpec(p); //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.MISC_MA_LEAVE_REMINDER); //restoreInvAndExp(p); } else { restoreInvAndExp(p); diff --git a/src/com/garbagemule/MobArena/ArenaListener.java b/src/com/garbagemule/MobArena/ArenaListener.java index 49bbd1c..d5cd43d 100644 --- a/src/com/garbagemule/MobArena/ArenaListener.java +++ b/src/com/garbagemule/MobArena/ArenaListener.java @@ -272,8 +272,13 @@ public class ArenaListener } if (event.getSpawnReason() != SpawnReason.CUSTOM) { - event.setCancelled(true); - return; + if (event.getSpawnReason() == SpawnReason.BUILD_IRONGOLEM || event.getSpawnReason() == SpawnReason.BUILD_SNOWMAN) { + monsters.addGolem(event.getEntity()); + } + else { + event.setCancelled(true); + return; + } } LivingEntity entity = (LivingEntity) event.getEntity(); @@ -361,6 +366,9 @@ public class ArenaListener else if (monsters.removeMonster(event.getEntity())) { onMonsterDeath(event); } + else if (monsters.removeGolem(event.getEntity())) { + Messenger.tellAll(arena, Msg.GOLEM_DIED); + } } private void onPlayerDeath(PlayerDeathEvent event, Player player) { diff --git a/src/com/garbagemule/MobArena/MonsterManager.java b/src/com/garbagemule/MobArena/MonsterManager.java index 4f97228..4f2d41d 100644 --- a/src/com/garbagemule/MobArena/MonsterManager.java +++ b/src/com/garbagemule/MobArena/MonsterManager.java @@ -17,7 +17,7 @@ import com.garbagemule.MobArena.waves.MABoss; public class MonsterManager { - private Set monsters, sheep; + private Set monsters, sheep, golems; private Set pets; private Map bosses; private Map> suppliers; @@ -25,6 +25,7 @@ public class MonsterManager public MonsterManager() { this.monsters = new HashSet(); this.sheep = new HashSet(); + this.golems = new HashSet(); this.pets = new HashSet(); this.bosses = new HashMap(); this.suppliers = new HashMap>(); @@ -33,6 +34,7 @@ public class MonsterManager public void reset() { monsters.clear(); sheep.clear(); + golems.clear(); pets.clear(); bosses.clear(); suppliers.clear(); @@ -41,6 +43,7 @@ public class MonsterManager public void clear() { removeAll(monsters); removeAll(sheep); + removeAll(golems); removeAll(pets); removeAll(bosses.keySet()); removeAll(suppliers.keySet()); @@ -80,6 +83,18 @@ public class MonsterManager return sheep.remove(e); } + public Set getGolems() { + return golems; + } + + public void addGolem(LivingEntity e) { + golems.add(e); + } + + public boolean removeGolem(LivingEntity e) { + return golems.remove(e); + } + public Set getPets() { return pets; } diff --git a/src/com/garbagemule/MobArena/Msg.java b/src/com/garbagemule/MobArena/Msg.java index 05d3a41..928e18e 100644 --- a/src/com/garbagemule/MobArena/Msg.java +++ b/src/com/garbagemule/MobArena/Msg.java @@ -29,8 +29,9 @@ public enum Msg 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), 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_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_EMPTY_INV("Empty your inventory first!", "Empty your inventory.", Material.CHEST), SPEC_ALREADY_PLAYING("Can't spectate when in the arena!", "Already playing!"),