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

Binary file not shown.

View File

@ -1,6 +1,6 @@
name: MobArena
main: com.garbagemule.MobArena.MobArena
version: 0.92.2
version: 0.92.3
softdepend: [MultiVerse,XcraftGate]
commands:
ma:

View File

@ -74,6 +74,7 @@ public class Arena
protected Map<String,Integer> distDefault, distSpecial;
protected Map<Player,String> classMap;
protected Map<String,List<ItemStack>> classItems, classArmor;
protected Map<Integer,Map<Player,List<ItemStack>>> classBonuses;
protected Map<Player,List<ItemStack>> rewardMap;
// Arena sets/maps
@ -99,6 +100,9 @@ public class Arena
*/
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.world = world;
plugin = (MobArena) Bukkit.getServer().getPluginManager().getPlugin("MobArena");
@ -124,11 +128,6 @@ public class Arena
spawnMonsters = ((net.minecraft.server.World) ((CraftWorld) world).getHandle()).spawnMonsters;
}
public Arena(String name, World world, ArenaMaster am)
{
this(name, world);
}
public void startArena()
{
if (running)
@ -154,7 +153,10 @@ public class Arena
// Spawn pets.
for (Map.Entry<Player,Integer> entry : petMap.entrySet())
{
// Remove the bones from the inventory.
Player p = entry.getKey();
p.getInventory().removeItem(new ItemStack(Material.BONE, entry.getValue()));
for (int i = 0; i < entry.getValue(); i++)
{
Wolf wolf = (Wolf) world.spawnCreature(p.getLocation(), CreatureType.WOLF);
@ -303,7 +305,14 @@ public class Arena
{
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
// Only clear the inventory if the player has class items.
@ -350,6 +359,8 @@ public class Arena
}
}, 10);
MAUtils.tellAll(this, MAMessages.get(Msg.PLAYER_DIED, p.getName()));
// Notify listeners.
for (MobArenaListener listener : plugin.getAM().listeners)
listener.onPlayerDeath(p);
@ -431,8 +442,9 @@ public class Arena
private void removePets(Player p)
{
for (Wolf w : pets)
if (w.getOwner().equals(p))
if (((Player) w.getOwner()).getName().equals(p.getName()))
w.remove();
petMap.remove(p);
}
private void removeEntities()
@ -1207,8 +1219,14 @@ public class Arena
// Make sure to remove any dead/removed entities first.
List<Entity> tmp = new LinkedList<Entity>(monsters);
for (Entity e : tmp)
{
out(e.getClass().getSimpleName());
if (e.isDead())
{
out("Removing monster");
monsters.remove(e);
}
}
// Compare the current size with the previous size.
if (monsters.size() < spawnThread.previousSize || spawnThread.previousSize == 0)
@ -1249,4 +1267,9 @@ public class Arena
{
return ((enabled && setup) ? ChatColor.GREEN : ChatColor.GRAY) + configName();
}
private void out(String s)
{
System.out.println(s);
}
}

View File

@ -28,6 +28,7 @@ public class ArenaMaster
// Classes
protected List<String> classes;
protected Map<String,List<ItemStack>> classItems, classArmor;
protected Map<Integer,Map<Player,List<ItemStack>>> classBonuses;
protected Map<Player,Arena> arenaMap;
// Location map
@ -206,9 +207,9 @@ public class ArenaMaster
config.setProperty("classes.Chef.items", "stone_sword, bread:6, grilled_pork:4, mushroom_soup, cake:3, cookie:12");
config.setProperty("classes.Chef.armor", "314,315,316,317");
}
classes = config.getKeys("classes");
classItems = MAUtils.getClassItems(config, "items");
classArmor = MAUtils.getClassItems(config, "armor");
classes = config.getKeys("classes");
classItems = MAUtils.getClassItems(config, "items");
classArmor = MAUtils.getClassItems(config, "armor");
}
/**
@ -236,7 +237,7 @@ public class ArenaMaster
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);
arenas.add(arena);
}
@ -281,7 +282,7 @@ public class ArenaMaster
config.save();
config.load();
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world, this);
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world);
arena.load(config);
return arena;
}

View File

@ -6,7 +6,6 @@ import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.DyeColor;
import org.bukkit.Material;
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
*/
@ -299,8 +286,10 @@ public class MACommands implements CommandExecutor
else
{
StringBuffer buffy = new StringBuffer();
List<Player> players = new LinkedList<Player>();
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()));
}
return true;

View File

@ -2,6 +2,7 @@ package com.garbagemule.MobArena;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
@ -56,6 +57,7 @@ public class MASpawnThread implements Runnable
random = new Random();
// Set up the distribution variables for the random spawner.
// Note: Updating these means MAUtils.getArenaDistributions() must also be updated!
dZombies = arena.distDefault.get("zombies");
dSkeletons = dZombies + arena.distDefault.get("skeletons");
dSpiders = dSkeletons + arena.distDefault.get("spiders");
@ -72,16 +74,18 @@ public class MASpawnThread implements Runnable
}
public void run()
{
{
// Check if wave needs to be cleared first. If so, return!
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())
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.
for (Map.Entry<Integer,List<ItemStack>> entry : arena.everyWaveMap.entrySet())

View File

@ -97,6 +97,7 @@ public class MAUtils
HELMETS_TYPE.add(Material.CHAINMAIL_HELMET);
HELMETS_TYPE.add(Material.IRON_HELMET);
HELMETS_TYPE.add(Material.DIAMOND_HELMET);
HELMETS_TYPE.add(Material.PUMPKIN);
CHESTPLATES_TYPE.add(Material.LEATHER_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)
{
//config.load();
String arenaPath = "arenas." + arena + ".waves." + wave;
Map<String,Integer> result = new HashMap<String,Integer>();
List<String> dists = config.getKeys(arenaPath);
// If there are no distributions yet, add them.
if (dists == null)
boolean update = false;
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"))
{
config.setProperty(arenaPath + ".zombies", 10);
config.setProperty(arenaPath + ".skeletons", 10);
config.setProperty(arenaPath + ".spiders", 10);
config.setProperty(arenaPath + ".creepers", 10);
config.setProperty(arenaPath + ".wolves", 10);
}
else if (wave.equals("special"))
{
config.setProperty(arenaPath + ".powered-creepers", 10);
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();
if (dists.contains(monster))
continue;
//if (config.getInt(arenaPath + "." + m, -1) == -1)
config.setProperty(arenaPath + "." + monster, (monster.equals("giants") || monster.equals("ghasts")) ? 0 : 10);
update = true;
}
if (update)
{
config.save();
dists = config.getKeys(arenaPath);
}
@ -289,8 +284,8 @@ public class MAUtils
value = 0;
config.setProperty(arenaPath + "." + monster, value);
//config.save();
}
config.save();
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, "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, "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, "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));