Add Crippled info command, update compatability with 920

This commit is contained in:
Eric Stokes 2011-06-23 06:57:47 -06:00
parent 086c96bf9b
commit e24dc7f83a
6 changed files with 134 additions and 28 deletions

Binary file not shown.

View File

@ -73,36 +73,32 @@ public class MVPermissions {
*/
public Boolean canEnterWorld(Player p, World w) {
List<String> whiteList = this.plugin.worlds.get(w.getName()).joinWhitelist;
List<String> blackList = this.plugin.worlds.get(w.getName()).joinBlacklist;
List<String> whiteList = this.plugin.worlds.get(w.getName()).playerWhitelist;
List<String> 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;
}

View File

@ -29,8 +29,8 @@ public class MVWorld {
public Boolean pvp; // Does this World allow PVP?
public List<Integer> blockBlacklist; // Contain a list of Blocks which we won't allow on this World.
public List<String> joinWhitelist; // Contain a list of Players/Groups which can join this World.
public List<String> joinBlacklist; // Contain a list of Players/Groups which cannot join this World.
public List<String> playerWhitelist; // Contain a list of Players/Groups which can join this World.
public List<String> playerBlacklist; // Contain a list of Players/Groups which cannot join this World.
public List<String> editWhitelist; // Contain a list of Players/Groups which can edit this World. (Place/Destroy Blocks)
public List<String> editBlacklist; // Contain a list of Players/Groups which cannot edit this World. (Place/Destroy Blocks)
public List<String> 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<Integer>();
joinWhitelist = new ArrayList<String>();
joinBlacklist = new ArrayList<String>();
playerWhitelist = new ArrayList<String>();
playerBlacklist = new ArrayList<String>();
editWhitelist = new ArrayList<String>();
editBlacklist = new ArrayList<String>();
worldBlacklist = new ArrayList<String>();
@ -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);

View File

@ -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));
}
/**

View File

@ -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 + "<Page #>";
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<String[]> pagedInfo = new ArrayList<String[]>();
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;
}
}

View File

@ -78,4 +78,8 @@ commands:
mvconfirm:
description: Confirms sensitive decisions like deleting a world.
usage: |
/<command> [Yes|No]
/<command>
mvinfo:
description: Gets world info.
usage: |
/<command> [world]