Still a few bugs with Purge

This commit is contained in:
Eric Stokes 2011-06-28 21:22:28 -06:00
parent ce3e203bc1
commit ed5dfd08ae
5 changed files with 42 additions and 18 deletions

View File

@ -227,27 +227,26 @@ public class MVWorld {
private void syncMobs() { private void syncMobs() {
if (this.getAnimalList().isEmpty()) { if (this.getAnimalList().isEmpty()) {
this.world.setSpawnFlags(this.world.getAllowMonsters(), this.allowAnimals); this.world.setSpawnFlags(this.world.getAllowMonsters(), this.allowAnimals);
if (!this.allowAnimals) {
// TODO: Purge
}
} else { } else {
this.world.setSpawnFlags(this.world.getAllowMonsters(), true); this.world.setSpawnFlags(this.world.getAllowMonsters(), true);
} }
if (this.getMonsterList().isEmpty()) { if (this.getMonsterList().isEmpty()) {
this.world.setSpawnFlags(this.allowMonsters, this.world.getAllowAnimals()); this.world.setSpawnFlags(this.allowMonsters, this.world.getAllowAnimals());
if (!this.allowMonsters) {
// TODO: Purge
}
} else { } else {
this.world.setSpawnFlags(true, this.world.getAllowAnimals()); this.world.setSpawnFlags(true, this.world.getAllowAnimals());
} }
System.out.print("Animals: " + this.world.getAllowAnimals());
System.out.print("Monsters: " + this.world.getAllowMonsters());
System.out.print("Animal List: " + this.getAnimalList());
System.out.print("Monster List: " + this.getMonsterList());
this.plugin.getWorldPurger().purgeWorld(null, this);
} }
private boolean addToList(String list, Integer value) { private boolean addToList(String list, Integer value) {
if (list.equalsIgnoreCase("blockblacklist")) { if (list.equalsIgnoreCase("blockblacklist")) {
this.blockBlacklist.add(value); this.blockBlacklist.add(value);
this.config.setProperty("worlds." + this.name + ".blockblacklist", this.blockBlacklist); this.config.setProperty("worlds." + this.name + ".blockblacklist", this.blockBlacklist);
this.config.save();
} }
return false; return false;
@ -257,6 +256,7 @@ public class MVWorld {
if (list.equalsIgnoreCase("blockblacklist")) { if (list.equalsIgnoreCase("blockblacklist")) {
this.blockBlacklist.remove(value); this.blockBlacklist.remove(value);
this.config.setProperty("worlds." + this.name + ".blockblacklist", this.blockBlacklist); this.config.setProperty("worlds." + this.name + ".blockblacklist", this.blockBlacklist);
this.config.save();
} }
return false; return false;
@ -266,8 +266,10 @@ public class MVWorld {
if (name.equalsIgnoreCase("pvp")) { if (name.equalsIgnoreCase("pvp")) {
this.setPvp(value); this.setPvp(value);
} else if (name.equalsIgnoreCase("animals")) { } else if (name.equalsIgnoreCase("animals")) {
this.setAnimals(value); this.setAnimals(value);
} else if (name.equalsIgnoreCase("monsters")) { } else if (name.equalsIgnoreCase("monsters")) {
System.out.print("Trying to set monsters to: " + value);
this.setMonsters(value); this.setMonsters(value);
} else { } else {
return false; return false;
@ -350,7 +352,6 @@ public class MVWorld {
this.allowAnimals = animals; this.allowAnimals = animals;
// If animals are a boolean, then we can turn them on or off on the server // If animals are a boolean, then we can turn them on or off on the server
// If there are ANY exceptions, there will be something spawning, so turn them on // If there are ANY exceptions, there will be something spawning, so turn them on
this.config.setProperty("worlds." + this.name + ".animals.spawn", animals); this.config.setProperty("worlds." + this.name + ".animals.spawn", animals);
this.config.save(); this.config.save();
this.syncMobs(); this.syncMobs();
@ -368,7 +369,6 @@ public class MVWorld {
this.allowMonsters = monsters; this.allowMonsters = monsters;
// If monsters are a boolean, then we can turn them on or off on the server // If monsters are a boolean, then we can turn them on or off on the server
// If there are ANY exceptions, there will be something spawning, so turn them on // If there are ANY exceptions, there will be something spawning, so turn them on
this.config.setProperty("worlds." + this.name + ".monsters.spawn", monsters); this.config.setProperty("worlds." + this.name + ".monsters.spawn", monsters);
this.config.save(); this.config.save();
this.syncMobs(); this.syncMobs();
@ -481,4 +481,19 @@ public class MVWorld {
return ChatColor.WHITE; return ChatColor.WHITE;
return null; return null;
} }
public boolean clearList(String property) {
if(property.equalsIgnoreCase("blockblacklist")) {
this.blockBlacklist.clear();
this.config.setProperty("worlds." + this.name + ".blockblacklist", this.blockBlacklist);
this.config.save();
return true;
} else if(this.masterList.containsKey(property)) {
this.masterList.get(property).clear();
this.config.setProperty("worlds." + this.masterList.get(property) + "." + property.toLowerCase(), this.blockBlacklist);
this.config.save();
return true;
}
return false;
}
} }

View File

@ -46,7 +46,7 @@ public class InfoCommand extends BaseCommand {
private String[] buildEntireCommand(MVWorld world) { private String[] buildEntireCommand(MVWorld world) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
ArrayList<String[]> pagedInfo = new ArrayList<String[]>(); ArrayList<String[]> pagedInfo = new ArrayList<String[]>();
String[] aPage = new String[3]; String[] aPage = new String[5];
// World Name: 1 // World Name: 1
aPage[0] = "World: " + world.getName(); aPage[0] = "World: " + world.getName();
@ -55,6 +55,8 @@ public class InfoCommand extends BaseCommand {
// PVP: 1 // PVP: 1
aPage[2] = "PVP: " + world.getPvp(); aPage[2] = "PVP: " + world.getPvp();
aPage[3] = "Animals: " + world.allowAnimalSpawning();
aPage[4] = "Monsters: " + world.allowMonsterSpawning();
// This feature is not mission critical and I am spending too much time on it... // This feature is not mission critical and I am spending too much time on it...
// Stopping work on it for now --FF 20110623 // Stopping work on it for now --FF 20110623

View File

@ -24,13 +24,12 @@ enum SetProperties {
public class ModifyCommand extends BaseCommand { public class ModifyCommand extends BaseCommand {
public ModifyCommand(MultiverseCore plugin) { public ModifyCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.name = "Modify a World"; this.name = "Modify a World";
this.description = "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used"; this.description = "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used";
this.usage = "/mvmodify" + ChatColor.GOLD + " [WORLD] " + ChatColor.GREEN + "{SET|ADD|REMOVE|CLEAR} {PROPERTY} {VALUE}"; this.usage = "/mvmodify" + ChatColor.GOLD + " [WORLD] " + ChatColor.GREEN + "{SET|ADD|REMOVE|CLEAR} {PROPERTY} {VALUE|all}";
this.minArgs = 3; this.minArgs = 2;
this.maxArgs = 4; this.maxArgs = 4;
this.identifiers.add("mvmodify"); this.identifiers.add("mvmodify");
this.permission = "multiverse.world.modify"; this.permission = "multiverse.world.modify";
@ -51,6 +50,7 @@ public class ModifyCommand extends BaseCommand {
String value; String value;
String property; String property;
Player p; Player p;
// Handle special CLEAR case
if (args.length == 3) { if (args.length == 3) {
p = (Player) sender; p = (Player) sender;
world = this.plugin.getMVWorld(p.getWorld().getName()); world = this.plugin.getMVWorld(p.getWorld().getName());
@ -98,8 +98,12 @@ public class ModifyCommand extends BaseCommand {
} else { } else {
sender.sendMessage(value + " could not be removed from " + property); sender.sendMessage(value + " could not be removed from " + property);
} }
} else if(action == Action.Clear) { } else if (action == Action.Clear) {
if (world.clearList(property)) {
sender.sendMessage(property + " was cleared. It contains 0 values now.");
} else {
sender.sendMessage(property + " was NOT cleared.");
}
} }
} }
@ -132,6 +136,9 @@ public class ModifyCommand extends BaseCommand {
if (action.equalsIgnoreCase("remove") || action.equalsIgnoreCase("-")) { if (action.equalsIgnoreCase("remove") || action.equalsIgnoreCase("-")) {
return Action.Remove; return Action.Remove;
} }
if (action.equalsIgnoreCase("clear")) {
return Action.Clear;
}
return null; return null;
} }

View File

@ -7,8 +7,6 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import sun.tools.tree.ArrayAccessExpression;
import com.onarandombox.MultiverseCore.MVWorld; import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.command.BaseCommand; import com.onarandombox.MultiverseCore.command.BaseCommand;
@ -60,6 +58,8 @@ public class PurgeCommand extends BaseCommand {
PurgeWorlds purger = this.plugin.getWorldPurger(); PurgeWorlds purger = this.plugin.getWorldPurger();
ArrayList<String> thingsToKill = new ArrayList<String>(); ArrayList<String> thingsToKill = new ArrayList<String>();
if(deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) { if(deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
System.out.print("Found a special case: ");
System.out.print(deathName.toUpperCase());
thingsToKill.add(deathName.toUpperCase()); thingsToKill.add(deathName.toUpperCase());
} else { } else {
Collections.addAll(thingsToKill, deathName.split(",")); Collections.addAll(thingsToKill, deathName.split(","));

View File

@ -73,7 +73,7 @@ public class PurgeWorlds {
private boolean killCreature(MVWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) { private boolean killCreature(MVWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
String entityName = e.toString().replaceAll("Craft", "").toUpperCase(); String entityName = e.toString().replaceAll("Craft", "").toUpperCase();
if (e instanceof Squid || e instanceof Animals) { if (e instanceof Squid || e instanceof Animals) {
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("CREATURES")) { if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("ANIMALS")) {
if (!negate) { if (!negate) {
System.out.print(entityName + " - Removed"); System.out.print(entityName + " - Removed");
e.remove(); e.remove();