v0.88 - Fixed players dropping items if they actually die, added wolves to default waves, added world-node to config-file

This commit is contained in:
Garbage Mule
2011-06-03 12:02:51 +02:00
parent 7ff9e1b251
commit a48859be6b
7 changed files with 56 additions and 28 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.87.3 version: 0.88
commands: commands:
mobarena: mobarena:
description: Base command for MobArena description: Base command for MobArena
@@ -44,7 +44,7 @@ public class ArenaManager
// Spawn locations list and monster distribution fields. // Spawn locations list and monster distribution fields.
protected static List<Location> spawnpoints = new ArrayList<Location>(); protected static List<Location> spawnpoints = new ArrayList<Location>();
protected static int dZombies, dSkeletons, dSpiders, dCreepers; protected static int dZombies, dSkeletons, dSpiders, dCreepers, dWolves;
// Set and Maps for storing players, their locations, items, armor, etc. // Set and Maps for storing players, their locations, items, armor, etc.
protected static Set<Player> playerSet = new HashSet<Player>(); protected static Set<Player> playerSet = new HashSet<Player>();
@@ -102,6 +102,7 @@ public class ArenaManager
dSkeletons = MAUtils.getDistribution("skeletons"); dSkeletons = MAUtils.getDistribution("skeletons");
dSpiders = MAUtils.getDistribution("spiders"); dSpiders = MAUtils.getDistribution("spiders");
dCreepers = MAUtils.getDistribution("creepers"); dCreepers = MAUtils.getDistribution("creepers");
dWolves = MAUtils.getDistribution("wolves");
} }
// Convenience variables. // Convenience variables.
@@ -3,6 +3,7 @@ package com.garbagemule.MobArena;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityListener; import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
/** /**
* This listener acts as a type of death-listener. * This listener acts as a type of death-listener.
@@ -42,4 +43,24 @@ public class MADamageListener extends EntityListener
p.setFireTicks(0); p.setFireTicks(0);
ArenaManager.playerDeath(p); ArenaManager.playerDeath(p);
} }
/**
* Clears all player drops on death.
*/
public void onEntityDeath(EntityDeathEvent event)
{
if (!ArenaManager.isRunning)
return;
if (!(event.getEntity() instanceof Player))
return;
Player p = (Player) event.getEntity();
if (!ArenaManager.playerSet.contains(p))
return;
event.getDrops().clear();
ArenaManager.playerDeath(p);
}
} }
@@ -28,7 +28,7 @@ import org.bukkit.inventory.PlayerInventory;
public class MASpawnThread implements Runnable public class MASpawnThread implements Runnable
{ {
private int wave, noOfSpawnPoints, noOfPlayers; private int wave, noOfSpawnPoints, noOfPlayers;
private int dZombies, dSkeletons, dSpiders, dCreepers; private int dZombies, dSkeletons, dSpiders, dCreepers, dWolves;
private Random random; private Random random;
private String reward, currentRewards; private String reward, currentRewards;
@@ -44,6 +44,7 @@ public class MASpawnThread implements Runnable
dSkeletons = dZombies + ArenaManager.dSkeletons; dSkeletons = dZombies + ArenaManager.dSkeletons;
dSpiders = dSkeletons + ArenaManager.dSpiders; dSpiders = dSkeletons + ArenaManager.dSpiders;
dCreepers = dSpiders + ArenaManager.dCreepers; dCreepers = dSpiders + ArenaManager.dCreepers;
dWolves = dCreepers + ArenaManager.dWolves;
} }
public void run() public void run()
@@ -104,7 +105,7 @@ public class MASpawnThread implements Runnable
for (int i = 0; i < wave + noOfPlayers; i++) for (int i = 0; i < wave + noOfPlayers; i++)
{ {
loc = ArenaManager.spawnpoints.get(i % noOfSpawnPoints); loc = ArenaManager.spawnpoints.get(i % noOfSpawnPoints);
ran = random.nextInt(dCreepers); ran = random.nextInt(dWolves);
CreatureType mob; CreatureType mob;
/* Because of the nature of the if-elseif-else statement, /* Because of the nature of the if-elseif-else statement,
@@ -116,11 +117,15 @@ public class MASpawnThread implements Runnable
else if (ran < dSkeletons) mob = CreatureType.SKELETON; else if (ran < dSkeletons) mob = CreatureType.SKELETON;
else if (ran < dSpiders) mob = CreatureType.SPIDER; else if (ran < dSpiders) mob = CreatureType.SPIDER;
else if (ran < dCreepers) mob = CreatureType.CREEPER; else if (ran < dCreepers) mob = CreatureType.CREEPER;
else if (ran < dWolves) mob = CreatureType.WOLF;
else continue; else continue;
LivingEntity e = ArenaManager.world.spawnCreature(loc,mob); LivingEntity e = ArenaManager.world.spawnCreature(loc,mob);
ArenaManager.monsterSet.add(e); ArenaManager.monsterSet.add(e);
//if (mob == CreatureType.WOLF)
// ((Wolf)e).setAngry(true);
// Grab a random target. // Grab a random target.
Creature c = (Creature) e; Creature c = (Creature) e;
c.setTarget(getClosestPlayer(e)); c.setTarget(getClosestPlayer(e));
@@ -161,7 +166,7 @@ public class MASpawnThread implements Runnable
break; break;
case 4: case 4:
mob = CreatureType.WOLF; mob = CreatureType.WOLF;
count = noOfPlayers * 2; count = noOfPlayers * 3;
wolf = true; wolf = true;
break; break;
case 5: case 5:
+23 -23
View File
@@ -210,6 +210,7 @@ public class MAUtils
} }
} }
*/ */
/** /**
* Creates a Configuration object from the config.yml file. * Creates a Configuration object from the config.yml file.
*/ */
@@ -243,11 +244,10 @@ public class MAUtils
Configuration c = ArenaManager.config; Configuration c = ArenaManager.config;
c.load(); c.load();
String world = c.getString("world"); String world = c.getString("world", ArenaManager.server.getWorlds().get(0).getName());
c.setProperty("world", world);
if (world == null)
return ArenaManager.server.getWorlds().get(0);
c.save();
return ArenaManager.server.getWorld(world); return ArenaManager.server.getWorld(world);
} }
@@ -410,6 +410,25 @@ public class MAUtils
return true; return true;
} }
/**
* Grabs coordinate information from the config-file.
*/
public static Location getCoords(String name)
{
Configuration c = ArenaManager.config;
c.load();
// Return null if coords aren't in the config file.
if (c.getKeys("coords." + name) == null)
return null;
double x = c.getDouble("coords." + name + ".x", 0);
double y = c.getDouble("coords." + name + ".y", 0);
double z = c.getDouble("coords." + name + ".z", 0);
return new Location(ArenaManager.world, x, y, z);
}
/** /**
* Writes coordinate information to the config-file. * Writes coordinate information to the config-file.
*/ */
@@ -443,25 +462,6 @@ public class MAUtils
ArenaManager.updateVariables(); ArenaManager.updateVariables();
} }
/**
* Grabs coordinate information from the config-file.
*/
public static Location getCoords(String name)
{
Configuration c = ArenaManager.config;
c.load();
// Return null if coords aren't in the config file.
if (c.getKeys("coords." + name) == null)
return null;
double x = c.getDouble("coords." + name + ".x", 0);
double y = c.getDouble("coords." + name + ".y", 0);
double z = c.getDouble("coords." + name + ".z", 0);
return new Location(ArenaManager.world, x, y, z);
}
/** /**
* Maintains the invariant that p1's coordinates are of lower * Maintains the invariant that p1's coordinates are of lower
* values than their respective counter-parts of p2. Makes the * values than their respective counter-parts of p2. Makes the
@@ -63,6 +63,7 @@ public class MobArena extends JavaPlugin
pm.registerEvent(Event.Type.BLOCK_DAMAGE, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_DAMAGE, blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, damageListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_DAMAGE, damageListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DEATH, damageListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_EXPLODE, monsterListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_EXPLODE, monsterListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_COMBUST, monsterListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_COMBUST, monsterListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_TARGET, monsterListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_TARGET, monsterListener, Priority.Normal, this);