v0.92.3 - Bugfixes, etc. Pets should be fixed, monsters should be removed by /butcher and purge spell, death announcements re-added, pumpkin hats!

This commit is contained in:
Garbage Mule
2011-07-10 20:05:54 +02:00
parent 24f4146010
commit 397a17a185
7 changed files with 67 additions and 55 deletions
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
name: MobArena name: MobArena
main: com.garbagemule.MobArena.MobArena main: com.garbagemule.MobArena.MobArena
version: 0.92.2 version: 0.92.3
softdepend: [MultiVerse,XcraftGate] softdepend: [MultiVerse,XcraftGate]
commands: commands:
ma: ma:
+30 -7
View File
@@ -74,6 +74,7 @@ public class Arena
protected Map<String,Integer> distDefault, distSpecial; protected Map<String,Integer> distDefault, distSpecial;
protected Map<Player,String> classMap; protected Map<Player,String> classMap;
protected Map<String,List<ItemStack>> classItems, classArmor; protected Map<String,List<ItemStack>> classItems, classArmor;
protected Map<Integer,Map<Player,List<ItemStack>>> classBonuses;
protected Map<Player,List<ItemStack>> rewardMap; protected Map<Player,List<ItemStack>> rewardMap;
// Arena sets/maps // Arena sets/maps
@@ -99,6 +100,9 @@ public class Arena
*/ */
public Arena(String name, World world) public Arena(String name, World world)
{ {
if (world == null)
throw new NullPointerException("[MobArena] ERROR! World for arena '" + name + "' does not exist!");
this.name = name; this.name = name;
this.world = world; this.world = world;
plugin = (MobArena) Bukkit.getServer().getPluginManager().getPlugin("MobArena"); plugin = (MobArena) Bukkit.getServer().getPluginManager().getPlugin("MobArena");
@@ -124,11 +128,6 @@ public class Arena
spawnMonsters = ((net.minecraft.server.World) ((CraftWorld) world).getHandle()).spawnMonsters; spawnMonsters = ((net.minecraft.server.World) ((CraftWorld) world).getHandle()).spawnMonsters;
} }
public Arena(String name, World world, ArenaMaster am)
{
this(name, world);
}
public void startArena() public void startArena()
{ {
if (running) if (running)
@@ -154,7 +153,10 @@ public class Arena
// Spawn pets. // Spawn pets.
for (Map.Entry<Player,Integer> entry : petMap.entrySet()) for (Map.Entry<Player,Integer> entry : petMap.entrySet())
{ {
// Remove the bones from the inventory.
Player p = entry.getKey(); Player p = entry.getKey();
p.getInventory().removeItem(new ItemStack(Material.BONE, entry.getValue()));
for (int i = 0; i < entry.getValue(); i++) for (int i = 0; i < entry.getValue(); i++)
{ {
Wolf wolf = (Wolf) world.spawnCreature(p.getLocation(), CreatureType.WOLF); Wolf wolf = (Wolf) world.spawnCreature(p.getLocation(), CreatureType.WOLF);
@@ -303,7 +305,14 @@ public class Arena
{ {
boolean clear = false; boolean clear = false;
p.teleport(locations.get(p)); Location old = locations.get(p);
Chunk chunk = old.getWorld().getChunkAt(old);
if (!old.getWorld().isChunkLoaded(chunk))
old.getWorld().loadChunk(chunk);
else
old.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
p.teleport(old);
locations.remove(p); // get, then remove, because of Teleport Event locations.remove(p); // get, then remove, because of Teleport Event
// Only clear the inventory if the player has class items. // Only clear the inventory if the player has class items.
@@ -350,6 +359,8 @@ public class Arena
} }
}, 10); }, 10);
MAUtils.tellAll(this, MAMessages.get(Msg.PLAYER_DIED, p.getName()));
// Notify listeners. // Notify listeners.
for (MobArenaListener listener : plugin.getAM().listeners) for (MobArenaListener listener : plugin.getAM().listeners)
listener.onPlayerDeath(p); listener.onPlayerDeath(p);
@@ -431,8 +442,9 @@ public class Arena
private void removePets(Player p) private void removePets(Player p)
{ {
for (Wolf w : pets) for (Wolf w : pets)
if (w.getOwner().equals(p)) if (((Player) w.getOwner()).getName().equals(p.getName()))
w.remove(); w.remove();
petMap.remove(p);
} }
private void removeEntities() private void removeEntities()
@@ -1207,8 +1219,14 @@ public class Arena
// Make sure to remove any dead/removed entities first. // Make sure to remove any dead/removed entities first.
List<Entity> tmp = new LinkedList<Entity>(monsters); List<Entity> tmp = new LinkedList<Entity>(monsters);
for (Entity e : tmp) for (Entity e : tmp)
{
out(e.getClass().getSimpleName());
if (e.isDead()) if (e.isDead())
{
out("Removing monster");
monsters.remove(e); monsters.remove(e);
}
}
// Compare the current size with the previous size. // Compare the current size with the previous size.
if (monsters.size() < spawnThread.previousSize || spawnThread.previousSize == 0) if (monsters.size() < spawnThread.previousSize || spawnThread.previousSize == 0)
@@ -1249,4 +1267,9 @@ public class Arena
{ {
return ((enabled && setup) ? ChatColor.GREEN : ChatColor.GRAY) + configName(); return ((enabled && setup) ? ChatColor.GREEN : ChatColor.GRAY) + configName();
} }
private void out(String s)
{
System.out.println(s);
}
} }
@@ -28,6 +28,7 @@ public class ArenaMaster
// Classes // Classes
protected List<String> classes; protected List<String> classes;
protected Map<String,List<ItemStack>> classItems, classArmor; protected Map<String,List<ItemStack>> classItems, classArmor;
protected Map<Integer,Map<Player,List<ItemStack>>> classBonuses;
protected Map<Player,Arena> arenaMap; protected Map<Player,Arena> arenaMap;
// Location map // Location map
@@ -236,7 +237,7 @@ public class ArenaMaster
world = Bukkit.getServer().getWorld(worldName); world = Bukkit.getServer().getWorld(worldName);
} }
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world, this); Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world);
arena.load(config); arena.load(config);
arenas.add(arena); arenas.add(arena);
} }
@@ -281,7 +282,7 @@ public class ArenaMaster
config.save(); config.save();
config.load(); config.load();
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world, this); Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world);
arena.load(config); arena.load(config);
return arena; return arena;
} }
+3 -14
View File
@@ -6,7 +6,6 @@ import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
@@ -112,18 +111,6 @@ public class MACommands implements CommandExecutor
// //
////////////////////////////////////////////////////////////////*/ ////////////////////////////////////////////////////////////////*/
if (base.equals("unchunk"))
{
Arena arena = am.getArenaWithName(arg1);
Chunk chunk = arena.world.getChunkAt(arena.lobbyLoc);
//arena.world.unloadChunk(chunk.getX(), chunk.getZ(), false, false);
arena.world.unloadChunk(arena.lobbyLoc.getBlockX(), arena.lobbyLoc.getBlockZ());
arena.world.unloadChunk(chunk.getX(), chunk.getZ());
System.out.println("Chunk: " + chunk.getX() + "," + chunk.getZ());
System.out.println("Lobby: " + arena.lobbyLoc.getBlockX() + "," + arena.lobbyLoc.getBlockZ());
return true;
}
/* /*
* Player join * Player join
*/ */
@@ -299,8 +286,10 @@ public class MACommands implements CommandExecutor
else else
{ {
StringBuffer buffy = new StringBuffer(); StringBuffer buffy = new StringBuffer();
List<Player> players = new LinkedList<Player>();
for (Arena arena : am.arenas) for (Arena arena : am.arenas)
buffy.append(MAUtils.listToString(arena.getLivingPlayers())); players.addAll(arena.getLivingPlayers());
buffy.append(MAUtils.listToString(players));
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_PLAYERS, buffy.toString())); MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_PLAYERS, buffy.toString()));
} }
return true; return true;
@@ -2,6 +2,7 @@ package com.garbagemule.MobArena;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
@@ -56,6 +57,7 @@ public class MASpawnThread implements Runnable
random = new Random(); random = new Random();
// Set up the distribution variables for the random spawner. // Set up the distribution variables for the random spawner.
// Note: Updating these means MAUtils.getArenaDistributions() must also be updated!
dZombies = arena.distDefault.get("zombies"); dZombies = arena.distDefault.get("zombies");
dSkeletons = dZombies + arena.distDefault.get("skeletons"); dSkeletons = dZombies + arena.distDefault.get("skeletons");
dSpiders = dSkeletons + arena.distDefault.get("spiders"); dSpiders = dSkeletons + arena.distDefault.get("spiders");
@@ -76,13 +78,15 @@ public class MASpawnThread implements Runnable
// Check if wave needs to be cleared first. If so, return! // Check if wave needs to be cleared first. If so, return!
if (arena.waveClear && wave > 1) if (arena.waveClear && wave > 1)
{ {
List<Entity> tmp = new LinkedList<Entity>(arena.monsters);
for (Entity e : tmp)
if (e.isDead())
arena.monsters.remove(e);
if (!arena.monsters.isEmpty()) if (!arena.monsters.isEmpty())
return; return;
} }
// If maxIdleTime is defined, reset the timer.
//if (arena.maxIdleTime > 0) arena.resetIdleTimer();
// Check if we need to grant more rewards with the recurrent waves. // Check if we need to grant more rewards with the recurrent waves.
for (Map.Entry<Integer,List<ItemStack>> entry : arena.everyWaveMap.entrySet()) for (Map.Entry<Integer,List<ItemStack>> entry : arena.everyWaveMap.entrySet())
if (wave % entry.getKey() == 0) if (wave % entry.getKey() == 0)
+17 -22
View File
@@ -97,6 +97,7 @@ public class MAUtils
HELMETS_TYPE.add(Material.CHAINMAIL_HELMET); HELMETS_TYPE.add(Material.CHAINMAIL_HELMET);
HELMETS_TYPE.add(Material.IRON_HELMET); HELMETS_TYPE.add(Material.IRON_HELMET);
HELMETS_TYPE.add(Material.DIAMOND_HELMET); HELMETS_TYPE.add(Material.DIAMOND_HELMET);
HELMETS_TYPE.add(Material.PUMPKIN);
CHESTPLATES_TYPE.add(Material.LEATHER_CHESTPLATE); CHESTPLATES_TYPE.add(Material.LEATHER_CHESTPLATE);
CHESTPLATES_TYPE.add(Material.GOLD_CHESTPLATE); CHESTPLATES_TYPE.add(Material.GOLD_CHESTPLATE);
@@ -247,33 +248,27 @@ public class MAUtils
*/ */
public static Map<String,Integer> getArenaDistributions(Configuration config, String arena, String wave) public static Map<String,Integer> getArenaDistributions(Configuration config, String arena, String wave)
{ {
//config.load();
String arenaPath = "arenas." + arena + ".waves." + wave; String arenaPath = "arenas." + arena + ".waves." + wave;
Map<String,Integer> result = new HashMap<String,Integer>(); Map<String,Integer> result = new HashMap<String,Integer>();
List<String> dists = config.getKeys(arenaPath); List<String> dists = config.getKeys(arenaPath);
// If there are no distributions yet, add them. boolean update = false;
if (dists == null) String[] monsters = (wave.equals("default")) ? new String[]{"zombies", "skeletons", "spiders", "creepers", "wolves"}
: new String[]{"powered-creepers", "zombie-pigmen", "slimes", "humans", "angry-wolves", "giants", "ghasts"};
for (String monster : monsters)
{ {
if (wave.equals("default")) if (dists.contains(monster))
{ continue;
config.setProperty(arenaPath + ".zombies", 10);
config.setProperty(arenaPath + ".skeletons", 10); //if (config.getInt(arenaPath + "." + m, -1) == -1)
config.setProperty(arenaPath + ".spiders", 10); config.setProperty(arenaPath + "." + monster, (monster.equals("giants") || monster.equals("ghasts")) ? 0 : 10);
config.setProperty(arenaPath + ".creepers", 10); update = true;
config.setProperty(arenaPath + ".wolves", 10);
} }
else if (wave.equals("special"))
if (update)
{ {
config.setProperty(arenaPath + ".powered-creepers", 10); config.save();
config.setProperty(arenaPath + ".zombie-pigmen", 10);
config.setProperty(arenaPath + ".slimes", 10);
config.setProperty(arenaPath + ".humans", 10);
config.setProperty(arenaPath + ".angry-wolves", 10);
config.setProperty(arenaPath + ".giants", 0);
config.setProperty(arenaPath + ".ghasts", 0);
}
//config.save();
dists = config.getKeys(arenaPath); dists = config.getKeys(arenaPath);
} }
@@ -289,8 +284,8 @@ public class MAUtils
value = 0; value = 0;
config.setProperty(arenaPath + "." + monster, value); config.setProperty(arenaPath + "." + monster, value);
//config.save();
} }
config.save();
result.put(monster, value); result.put(monster, value);
} }
@@ -1268,7 +1263,7 @@ public class MAUtils
MAUtils.setArenaCoord(plugin.getConfig(), arena, "p1", new Location(world, x1, ly1, z1)); MAUtils.setArenaCoord(plugin.getConfig(), arena, "p1", new Location(world, x1, ly1, z1));
MAUtils.setArenaCoord(plugin.getConfig(), arena, "p2", new Location(world, x2, y2+1, z2)); MAUtils.setArenaCoord(plugin.getConfig(), arena, "p2", new Location(world, x2, y2+1, z2));
MAUtils.setArenaCoord(plugin.getConfig(), arena, "arena", new Location(world, loc.getX(), y1+1, loc.getZ())); MAUtils.setArenaCoord(plugin.getConfig(), arena, "arena", new Location(world, loc.getX(), y1+1, loc.getZ()));
MAUtils.setArenaCoord(plugin.getConfig(), arena, "lobby", new Location(world, x1+2, y1-3, z1+2)); MAUtils.setArenaCoord(plugin.getConfig(), arena, "lobby", new Location(world, x1+2, ly1+1, z1+2));
MAUtils.setArenaCoord(plugin.getConfig(), arena, "spectator", new Location(world, loc.getX(), y2+1, loc.getZ())); MAUtils.setArenaCoord(plugin.getConfig(), arena, "spectator", new Location(world, loc.getX(), y2+1, loc.getZ()));
MAUtils.setArenaCoord(plugin.getConfig(), arena, "spawnpoints.s1", new Location(world, x1+3, y1+2, z1+3)); MAUtils.setArenaCoord(plugin.getConfig(), arena, "spawnpoints.s1", new Location(world, x1+3, y1+2, z1+3));
MAUtils.setArenaCoord(plugin.getConfig(), arena, "spawnpoints.s2", new Location(world, x1+3, y1+2, z2-3)); MAUtils.setArenaCoord(plugin.getConfig(), arena, "spawnpoints.s2", new Location(world, x1+3, y1+2, z2-3));