Added Support for EnderDragon purging now Supports Dragon or EnderDragon as the keyword (No changes needed to this file if this functionality is not desired) Ie: With the old code player must enter the correct "enderdragon" entering "dragon" on any other invalid keyword will report "0 - mobs purged". NOTE: This change would break for a player has a mod that has an entity called "Dragon".

This commit is contained in:
sthycb 2011-11-24 14:56:43 -04:00 committed by Eric Stokes
parent 0c847eefdf
commit c9a33350ac
2 changed files with 19 additions and 4 deletions

View File

@ -80,7 +80,14 @@ public class PurgeCommand extends MultiverseCommand {
if (deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
thingsToKill.add(deathName.toUpperCase());
} else {
Collections.addAll(thingsToKill, deathName.toUpperCase().split(","));
for (String d :deathName.toUpperCase().split(",")) {
if(d.equalsIgnoreCase("dragon")){ //could be replaced with a Map(Hash?) to allow for all mobs to have multiple keywords
thingsToKill.add("ENDERDRAGON");// note UpperCase needed on this literal
}
else{
thingsToKill.add(d);
}
}
}
for (MultiverseWorld w : worldsToRemoveEntitiesFrom) {
purger.purgeWorld(sender, w, thingsToKill, false, false);

View File

@ -59,7 +59,8 @@ public class PurgeWorlds {
return;
}
int entitiesKilled = 0;
for (Entity e : world.getEntities()) {
for (Entity e : world.getEntities()){
this.plugin.log(Level.FINEST, "Entity list (aval for purge) from WORLD < " + mvworld.getName() + " >: " + e.toString());
// Check against Monsters
if (killMonster(mvworld, e, thingsToKill, negateMonsters)) {
@ -106,8 +107,15 @@ public class PurgeWorlds {
* @return
*/
private boolean killMonster(MultiverseWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
String entityName = e.toString().replaceAll("Craft", "").toUpperCase();
if (e instanceof Slime || e instanceof Monster || e instanceof Ghast) {
String entityName = "";
if (e instanceof EnderDragon) {
this.plugin.log(Level.FINEST, "Found an enderdragon: " + e);
entityName = "ENDERDRAGON"; // Assumes that creaturesToKill contains the ENDERDRAGON keyword
}
else{
entityName = e.toString().replaceAll("Craft", "").toUpperCase();
}
if (e instanceof Slime || e instanceof Monster || e instanceof Ghast || e instanceof EnderDragon) {
this.plugin.log(Level.FINER, "Looking at a monster: " + e);
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("MONSTERS")) {
if (!negate) {