diff --git a/lib/craftbukkit-0.0.1-SNAPSHOT.jar b/lib/craftbukkit-0.0.1-SNAPSHOT.jar index 10f9f5b3..6929a83d 100644 Binary files a/lib/craftbukkit-0.0.1-SNAPSHOT.jar and b/lib/craftbukkit-0.0.1-SNAPSHOT.jar differ diff --git a/src/com/onarandombox/MultiverseCore/MVPermissions.java b/src/com/onarandombox/MultiverseCore/MVPermissions.java index 8c89fc3e..8b3d1d40 100644 --- a/src/com/onarandombox/MultiverseCore/MVPermissions.java +++ b/src/com/onarandombox/MultiverseCore/MVPermissions.java @@ -73,36 +73,32 @@ public class MVPermissions { */ public Boolean canEnterWorld(Player p, World w) { - List whiteList = this.plugin.worlds.get(w.getName()).joinWhitelist; - List blackList = this.plugin.worlds.get(w.getName()).joinBlacklist; + List whiteList = this.plugin.worlds.get(w.getName()).playerWhitelist; + List blackList = this.plugin.worlds.get(w.getName()).playerBlacklist; boolean returnValue = true; - // TODO: Not sure if I want this. - // I don't think so, I just reprioritized the whitelist after the blacklist in general --FF - // if (whiteList.size() > 0) { - // returnValue = false; - // } + // I lied. You definitely want this. Sorry Rigby :( You were right. --FF + // If there's anyone in the whitelist, then the whitelist is ACTIVE, anyone not in it is blacklisted. + if (whiteList.size() > 0) { + returnValue = false; + } for (String bls : blackList) { - if (bls.contains("g:") && inGroup(p, w.getName(), bls.split(":")[1])) { - // System.out.print(p.getName() + " Is on the BLACKlist for " + w.getName()); + if (bls.toLowerCase().contains("g:") && this.inGroup(p, w.getName(), bls.split(":")[1])) { returnValue = false; break; } if (bls.equalsIgnoreCase(p.getName())) { - // System.out.print(p.getName() + " Is on the BLACKlist for " + w.getName()); returnValue = false; break; } } for (String wls : whiteList) { - if (wls.contains("g:") && inGroup(p, w.getName(), wls.split(":")[1])) { - // System.out.print(p.getName() + " Is on the WHITElist for " + w.getName()); + if (wls.toLowerCase().contains("g:") && this.inGroup(p, w.getName(), wls.split(":")[1])) { returnValue = true; break; } if (wls.equalsIgnoreCase(p.getName())) { - // System.out.print(p.getName() + " Is on the WHITElist for " + w.getName()); returnValue = true; break; } diff --git a/src/com/onarandombox/MultiverseCore/MVWorld.java b/src/com/onarandombox/MultiverseCore/MVWorld.java index dab97f59..b8f156e3 100644 --- a/src/com/onarandombox/MultiverseCore/MVWorld.java +++ b/src/com/onarandombox/MultiverseCore/MVWorld.java @@ -29,8 +29,8 @@ public class MVWorld { public Boolean pvp; // Does this World allow PVP? public List blockBlacklist; // Contain a list of Blocks which we won't allow on this World. - public List joinWhitelist; // Contain a list of Players/Groups which can join this World. - public List joinBlacklist; // Contain a list of Players/Groups which cannot join this World. + public List playerWhitelist; // Contain a list of Players/Groups which can join this World. + public List playerBlacklist; // Contain a list of Players/Groups which cannot join this World. public List editWhitelist; // Contain a list of Players/Groups which can edit this World. (Place/Destroy Blocks) public List editBlacklist; // Contain a list of Players/Groups which cannot edit this World. (Place/Destroy Blocks) public List worldBlacklist; // Contain a list of Worlds which Players cannot use to Portal to this World. @@ -59,8 +59,8 @@ public class MVWorld { this.scaling = 1.0; } - this.joinWhitelist = config.getStringList("worlds." + name + ".playerWhitelist", joinWhitelist); - this.joinBlacklist = config.getStringList("worlds." + name + ".playerBlacklist", joinBlacklist); + this.playerWhitelist = config.getStringList("worlds." + name + ".playerWhitelist", playerWhitelist); + this.playerBlacklist = config.getStringList("worlds." + name + ".playerBlacklist", playerBlacklist); this.worldBlacklist = config.getStringList("worlds." + name + ".worldBlacklist", worldBlacklist); this.blockBlacklist = config.getIntList("worlds." + name + ".blockBlacklist", blockBlacklist); this.editWhitelist = config.getStringList("worlds." + name + ".editWhitelist", editWhitelist); @@ -94,8 +94,8 @@ public class MVWorld { private void initLists() { blockBlacklist = new ArrayList(); - joinWhitelist = new ArrayList(); - joinBlacklist = new ArrayList(); + playerWhitelist = new ArrayList(); + playerBlacklist = new ArrayList(); editWhitelist = new ArrayList(); editBlacklist = new ArrayList(); worldBlacklist = new ArrayList(); @@ -108,11 +108,11 @@ public class MVWorld { this.blockBlacklist.add(49); - this.joinWhitelist.add("fernferret"); - this.joinWhitelist.add("g:Admins"); + this.playerWhitelist.add("fernferret"); + this.playerWhitelist.add("g:Admins"); - this.joinBlacklist.add("Rigby90"); - this.joinBlacklist.add("g:Banned"); + this.playerBlacklist.add("Rigby90"); + this.playerBlacklist.add("g:Banned"); this.editWhitelist.add("fernferret"); this.editWhitelist.add("g:Admins"); @@ -126,8 +126,8 @@ public class MVWorld { this.config.setProperty("worlds." + name + ".animals.exceptions", animalList); this.config.setProperty("worlds." + name + ".monsters.exceptions", monsterList); this.config.setProperty("worlds." + name + ".blockBlacklist", blockBlacklist); - this.config.setProperty("worlds." + name + ".playerWhitelist", joinWhitelist); - this.config.setProperty("worlds." + name + ".playerBlacklist", joinBlacklist); + this.config.setProperty("worlds." + name + ".playerWhitelist", playerWhitelist); + this.config.setProperty("worlds." + name + ".playerBlacklist", playerBlacklist); this.config.setProperty("worlds." + name + ".editWhitelist", editWhitelist); this.config.setProperty("worlds." + name + ".editBlacklist", editBlacklist); this.config.setProperty("worlds." + name + ".worldBlacklist", worldBlacklist); diff --git a/src/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/com/onarandombox/MultiverseCore/MultiverseCore.java index cececef6..df56bc91 100644 --- a/src/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -112,8 +112,6 @@ public class MultiverseCore extends JavaPlugin { // Setup & Load our Configuration files. loadConfigs(); - // Call the Function to load all the Worlds and setup the HashMap - loadWorlds(); } @Override @@ -134,6 +132,9 @@ public class MultiverseCore extends JavaPlugin { // Start the Update Checker // updateCheck = new UpdateChecker(this.getDescription().getName(), this.getDescription().getVersion()); + // Call the Function to load all the Worlds and setup the HashMap + loadWorlds(); + // Purge Worlds of old Monsters/Animals which don't adhere to the setup. purgeWorlds(); } @@ -300,6 +301,7 @@ public class MultiverseCore extends JavaPlugin { commandManager.addCommand(new DeleteCommand(this)); commandManager.addCommand(new UnloadCommand(this)); commandManager.addCommand(new ConfirmCommand(this)); + commandManager.addCommand(new InfoCommand(this)); } /** diff --git a/src/com/onarandombox/MultiverseCore/command/commands/InfoCommand.java b/src/com/onarandombox/MultiverseCore/command/commands/InfoCommand.java new file mode 100644 index 00000000..ad8bf869 --- /dev/null +++ b/src/com/onarandombox/MultiverseCore/command/commands/InfoCommand.java @@ -0,0 +1,104 @@ +package com.onarandombox.MultiverseCore.command.commands; + +import java.util.ArrayList; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.onarandombox.MultiverseCore.MVWorld; +import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.command.BaseCommand; + +public class InfoCommand extends BaseCommand { + + public InfoCommand(MultiverseCore plugin) { + super(plugin); + this.name = "World Information"; + this.description = "Returns detailed information on the world."; + this.usage = "/mvinfo" + ChatColor.GOLD + "[WORLD]" + ChatColor.DARK_PURPLE + ""; + this.minArgs = 0; + this.maxArgs = 2; + this.identifiers.add("mvinfo"); + this.permission = "multiverse.world.info"; + this.requiresOp = false; + } + + @Override + public void execute(CommandSender sender, String[] args) { + // Check if the command was sent from a Player. + String worldName = ""; + if (sender instanceof Player && args.length == 0) { + worldName = ((Player) sender).getWorld().getName(); + } else if (args.length == 0) { + sender.sendMessage("You must enter a" + ChatColor.GOLD + " world" + ChatColor.WHITE + " from the console!"); + return; + } else { + worldName = args[0]; + } + if (plugin.worlds.containsKey(worldName)) { + for (String s : buildEntireCommand(plugin.worlds.get(worldName))) { + sender.sendMessage(s); + } + } + } + + private String[] buildEntireCommand(MVWorld world) { + StringBuilder sb = new StringBuilder(); + ArrayList pagedInfo = new ArrayList(); + String[] aPage = new String[3]; + // World Name: 1 + aPage[0] = "World: " + world.name; + + // World Scale: 1 + aPage[1] = "World Scale: " + world.scaling; + + // PVP: 1 + aPage[2] = "PVP: " + world.pvp; + + // This feature is not mission critical and I am spending too much time on it... + // Stopping work on it for now --FF 20110623 + // // Animal Spawning: X + // sb.append("Animals can spawn: "); + // sb.append(world.animals?"Yes":"No"); + // sb.append("\n"); + // if (!world.animalList.isEmpty()) { + // sb.append("Except: \n"); + // for (String s : world.animalList) { + // sb.append(" - " + s + "\n"); + // } + // } + // + // // Monster Spawning + // sb.append("Monsters can spawn: "); + // sb.append(world.monsters?"Yes":"No"); + // sb.append("\n"); + // if (!world.monsterList.isEmpty()) { + // sb.append("Except: \n"); + // for (String s : world.monsterList) { + // sb.append(" - " + s + "\n"); + // } + // } + // + // // Whitelist + // if (!world.playerWhitelist.isEmpty()) { + // sb.append("Whitelisted Players: \n"); + // for (String s : world.playerWhitelist) { + // if (!s.matches("[gG]:.+")) { + // sb.append(" - " + s + "\n"); + // } + // } + // sb.append("Whitelisted Groups: \n"); + // for (String s : world.playerWhitelist) { + // if (s.matches("[gG]:")) { + // sb.append(" - " + s.split("[g]:")[1] + "\n"); + // } + // } + // } + return aPage; + } + + private ChatColor getChatColor(boolean positive) { + return positive ? ChatColor.GREEN : ChatColor.RED; + } +} diff --git a/src/plugin.yml b/src/plugin.yml index 519abaeb..7aa70fd7 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -78,4 +78,8 @@ commands: mvconfirm: description: Confirms sensitive decisions like deleting a world. usage: | - / [Yes|No] + / + mvinfo: + description: Gets world info. + usage: | + / [world]