v0.93.3 - Bunch of bug fixes...

This commit is contained in:
Andreas Troelsen 2011-07-19 23:13:09 +02:00
commit 9f39977048
6 changed files with 27 additions and 33 deletions

View File

@ -1,7 +1,7 @@
name: MobArena
main: com.garbagemule.MobArena.MobArena
version: 0.93.2
softdepend: [MultiVerse,XcraftGate]
version: 0.93.3
softdepend: [MultiVerse,XcraftGate,Towny]
commands:
ma:
description: Base command for MobArena

View File

@ -59,7 +59,7 @@ public class Arena
protected List<ItemStack> entryFee;
// Arena sets/maps
protected Set<Player> arenaPlayers, lobbyPlayers, readyPlayers, specPlayers, waitPlayers, hasPaid, rewardedPlayers, notifyPlayers, randoms;
protected Set<Player> arenaPlayers, lobbyPlayers, readyPlayers, specPlayers, hasPaid, rewardedPlayers, notifyPlayers, randoms;
protected Set<LivingEntity> monsters;
protected Set<Block> blocks;
protected Set<Wolf> pets;
@ -103,7 +103,6 @@ public class Arena
notifyPlayers = new HashSet<Player>();
readyPlayers = new HashSet<Player>();
specPlayers = new HashSet<Player>();
waitPlayers = new HashSet<Player>();
rewardedPlayers = new HashSet<Player>();
hasPaid = new HashSet<Player>();
monsters = new HashSet<LivingEntity>();
@ -181,9 +180,6 @@ public class Arena
if (!running || !arenaPlayers.isEmpty())
return false;
// Stop spawning.
stopSpawning();
// Set the boolean.
running = false;
@ -194,6 +190,9 @@ public class Arena
log.serialize();
log.clear();
}
// Stop spawning.
stopSpawning();
// Clean arena floor.
cleanup();
@ -214,6 +213,7 @@ public class Arena
rewardMap.clear();
waveMap.clear();
killMap.clear();
spawnThread = null;
// Notify listeners.
for (MobArenaListener listener : plugin.getAM().listeners)
@ -286,7 +286,7 @@ public class Arena
public void playerLeave(Player p)
{
// Clear class inventory, restore old inventory and fork over rewards.
restoreInvAndGiveRewards(p, arenaPlayers.contains(p));
restoreInvAndGiveRewards(p, (arenaPlayers.contains(p) || lobbyPlayers.contains(p)));
// Grab the player's entry location, and warp them there.
Location entry = locations.get(p);
@ -361,12 +361,6 @@ public class Arena
specPlayers.remove(p);
arenaPlayers.remove(p);
lobbyPlayers.remove(p);
// arenaPlayers is empty if lobbyPlayers isnt, and vice versa
/*if (arenaPlayers.remove(p))
endArena2();
if (lobbyPlayers.remove(p))
startArena2();*/
}
private void spawnPets()
@ -408,8 +402,8 @@ public class Arena
{
Bukkit.getServer().getScheduler().cancelTask(spawnThread.taskId);
Bukkit.getServer().getScheduler().cancelTask(spawnTaskId);
spawnThread = null;
spawnTaskId = -1;
spawnThread = null;
}
// Restore spawn flags.
@ -441,13 +435,15 @@ public class Arena
final List<ItemStack> rewards = rewardMap.get(p);
final boolean hadRewards = rewardedPlayers.contains(p);
if (clear) MAUtils.clearInventory(p);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
new Runnable()
{
public void run()
{
if (clear)
MAUtils.clearInventory(p);
//if (clear)
// MAUtils.clearInventory(p);
if (!emptyInvJoin)
MAUtils.restoreInventory(p);
@ -474,6 +470,7 @@ public class Arena
public void assignClass(Player p, String className)
{
petMap.remove(p);
randoms.remove(p);
classMap.put(p, className);
MAUtils.clearInventory(p);

View File

@ -152,7 +152,7 @@ public class MACommands implements CommandExecutor
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_ENABLED));
else if (!arena.setup || arena.edit)
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_SETUP));
else if (arena.running && arena.waitPlayers.add(p))
else if (arena.running && (arena.notifyPlayers.contains(p) || arena.notifyPlayers.add(p)))
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_IS_RUNNING));
else if (arena.arenaPlayers.contains(p))
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ALREADY_PLAYING));
@ -851,7 +851,7 @@ public class MACommands implements CommandExecutor
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
return true;
}
if (args.length != 3 || !arg1.matches("[0-9]+"))
if (args.length != 3 || !arg1.matches("(-)?[0-9]+"))
{
MAUtils.tellPlayer(sender, "Usage: /ma expandregion <amount> [up|down|out]");
return true;
@ -883,6 +883,9 @@ public class MACommands implements CommandExecutor
return true;
}
// In case of a "negative" region, fix it!
MAUtils.fixRegion(plugin.getConfig(), am.selectedArena.world, am.selectedArena);
MAUtils.tellPlayer(sender, "Region for '" + am.selectedArena.configName() + "' expanded " + arg2 + " by " + arg1 + " blocks.");
am.selectedArena.serializeConfig();
am.selectedArena.load(plugin.getConfig());

View File

@ -16,6 +16,7 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
@ -79,7 +80,6 @@ public class MAListener implements ArenaListener
return;
Block b = event.getBlock();
//if (running && livePlayers.contains(event.getPlayer()))
if (arena.running && arena.arenaPlayers.contains(event.getPlayer()))
{
arena.blocks.add(b);
@ -96,7 +96,7 @@ public class MAListener implements ArenaListener
public void onCreatureSpawn(CreatureSpawnEvent event)
{
if (!arena.inRegion(event.getLocation()))
if (!arena.inRegion(event.getLocation()) || event.getSpawnReason() == SpawnReason.CUSTOM)
return;
// If running == true, setCancelled(false), and vice versa.
@ -226,7 +226,6 @@ public class MAListener implements ArenaListener
}
if (event.getReason() == TargetReason.CLOSEST_PLAYER)
//if (!livePlayers.contains(event.getTarget()))
if (!arena.arenaPlayers.contains(event.getTarget()))
event.setCancelled(true);
return;
@ -237,7 +236,6 @@ public class MAListener implements ArenaListener
{
if (!arena.running) return;
//if (!(event.getEntity() instanceof Player) || !livePlayers.contains((Player)event.getEntity()))
if (!(event.getEntity() instanceof Player) || !arena.arenaPlayers.contains((Player)event.getEntity()))
return;
@ -251,7 +249,6 @@ public class MAListener implements ArenaListener
{
Player p = (Player) event.getEntity();
//if (!livePlayers.contains(p))
if (!arena.arenaPlayers.contains(p))
return;
@ -309,7 +306,6 @@ public class MAListener implements ArenaListener
// Damagee & Damager - Player - cancel if pvp disabled
if (damagee instanceof Player && damager instanceof Player)
{
//if (livePlayers.contains(damagee) && !pvp)
if (arena.arenaPlayers.contains(damagee) && !arena.pvp)
event.setCancelled(true);
@ -328,7 +324,6 @@ public class MAListener implements ArenaListener
// Creeper detonations
if (arena.inRegion(damagee.getLocation()))
{
//if (!detDamage || !(damagee instanceof Player) || !livePlayers.contains((Player) damagee))
if (!arena.detDamage || !(damagee instanceof Player) || !arena.arenaPlayers.contains((Player) damagee))
return;
@ -344,7 +339,6 @@ public class MAListener implements ArenaListener
if (arena.running && arena.shareInArena) return;
Player p = event.getPlayer();
//if (!livePlayers.contains(p))
if (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p))
return;

View File

@ -391,11 +391,11 @@ public class MASpawnThread implements Runnable
{
if (!(e instanceof Creature))
continue;
// TODO: Remove the try-catch when Bukkit API is fixed.
c = (Creature) e;
target = c.getTarget();
try { target = c.getTarget(); } catch (ClassCastException cce) { continue; }
//if (target instanceof Player && arena.livePlayers.contains(target))
if (target instanceof Player && arena.arenaPlayers.contains(target))
continue;

View File

@ -755,7 +755,7 @@ public class MAUtils
return true;
}
private static void fixRegion(Configuration config, World world, Arena arena)
public static void fixRegion(Configuration config, World world, Arena arena)
{
if (arena.p1 == null || arena.p2 == null)
return;
@ -901,7 +901,7 @@ public class MAUtils
* Sends a message to all players in and around the arena.
*/
public static void tellAll(Arena arena, String msg) { tellAll(arena, msg, false); }
public static void tellAll(Arena arena, String msg, boolean waitPlayers)
public static void tellAll(Arena arena, String msg, boolean notifyPlayers)
{
Set<Player> tmp = new HashSet<Player>();
tmp.addAll(arena.arenaPlayers);
@ -909,7 +909,7 @@ public class MAUtils
tmp.addAll(arena.readyPlayers);
tmp.addAll(arena.notifyPlayers);
tmp.addAll(arena.specPlayers);
if (waitPlayers) tmp.addAll(arena.waitPlayers);
if (notifyPlayers) tmp.addAll(arena.notifyPlayers);
for (Player p : tmp)
tellPlayer(p, msg);
}