Changing how command permission is checked.

This commit is contained in:
cerevisiae 2010-12-09 15:06:51 -06:00
parent ccee3b5d5c
commit c1790a32b4
3 changed files with 52 additions and 8 deletions

View File

@ -352,7 +352,7 @@ public class vMinecraftChat {
} }
//So you can read adminchat from the server console //So you can read adminchat from the server console
log.log(Level.INFO, "@" + "<" + getName(player) log.log(Level.INFO, "@" + "<" + player.getName()
+ Colors.White +"> " + message); + Colors.White +"> " + message);
return true; return true;
} }

View File

@ -71,8 +71,10 @@ public class vMinecraftCommands{
cl.registerAlias("/playerlist", "/who"); cl.registerAlias("/playerlist", "/who");
cl.registerAlias("/vhelp", "/vminecraft"); cl.registerAlias("/vhelp", "/vminecraft");
cl.registerAlias("/r", "/reply"); cl.registerAlias("/r", "/reply");
cl.registerAlias("/w", "/msg"); cl.registerAlias("/t", "/msg");
cl.registerAlias("/tell", "/msg");
cl.registerAlias("/wrists", "/suicide"); cl.registerAlias("/wrists", "/suicide");
cl.registerAlias("/kill", "/suicide");
cl.registerAlias("/ci", "/clearinventory"); cl.registerAlias("/ci", "/clearinventory");
//registerMessage //registerMessage
@ -328,6 +330,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int adminChatToggle(Player player, String[] args) public static int adminChatToggle(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/a")) {
return EXIT_FAIL;
}
if(vMinecraftSettings.getInstance().adminChatToggle()) if(vMinecraftSettings.getInstance().adminChatToggle())
{ {
//If the player is already toggled for admin chat, remove them //If the player is already toggled for admin chat, remove them
@ -353,6 +359,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int heal(Player player, String[] args) public static int heal(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/heal")) {
return EXIT_FAIL;
}
if(vMinecraftSettings.getInstance().cmdHeal()) if(vMinecraftSettings.getInstance().cmdHeal())
{ {
//If a target wasn't specified, heal the user. //If a target wasn't specified, heal the user.
@ -387,6 +397,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int suicide(Player player, String[] args) public static int suicide(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/suicide")) {
return EXIT_FAIL;
}
if(vMinecraftSettings.getInstance().cmdSuicide()) if(vMinecraftSettings.getInstance().cmdSuicide())
{ {
//Set your health to 0. Not much to it. //Set your health to 0. Not much to it.
@ -406,6 +420,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int teleport(Player player, String[] args) public static int teleport(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/tp")) {
return EXIT_FAIL;
}
//Get if the command is enabled //Get if the command is enabled
if(vMinecraftSettings.getInstance().cmdTp()) if(vMinecraftSettings.getInstance().cmdTp())
{ {
@ -453,6 +471,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int masstp(Player player, String[] args) public static int masstp(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/masstp")) {
return EXIT_FAIL;
}
//If the command is enabled //If the command is enabled
if(vMinecraftSettings.getInstance().cmdMasstp()) { if(vMinecraftSettings.getInstance().cmdMasstp()) {
//Go through all players and move them to the user //Go through all players and move them to the user
@ -479,6 +501,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int tphere(Player player, String[] args) public static int tphere(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/tphere")) {
return EXIT_FAIL;
}
//Check if the command is enabled. //Check if the command is enabled.
if (vMinecraftSettings.getInstance().cmdTphere()) { if (vMinecraftSettings.getInstance().cmdTphere()) {
//Make sure a player is specified //Make sure a player is specified
@ -517,6 +543,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int reload(Player player, String[] args) public static int reload(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/reload")) {
return EXIT_FAIL;
}
vMinecraftSettings.getInstance().loadSettings(); vMinecraftSettings.getInstance().loadSettings();
return EXIT_FAIL; return EXIT_FAIL;
} }
@ -591,6 +621,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int whois(Player player, String[] args) public static int whois(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/whois")) {
return EXIT_FAIL;
}
//If the command is enabled //If the command is enabled
if (vMinecraftSettings.getInstance().cmdWhoIs()) { if (vMinecraftSettings.getInstance().cmdWhoIs()) {
//If a player is specified //If a player is specified
@ -679,6 +713,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int say(Player player, String[] args) public static int say(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/say")) {
return EXIT_FAIL;
}
//If the command is enabled //If the command is enabled
if (vMinecraftSettings.getInstance().cmdSay()) { if (vMinecraftSettings.getInstance().cmdSay()) {
//Make sure a message is supplied or output an error //Make sure a message is supplied or output an error
@ -701,6 +739,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int slay(Player player, String[] args) public static int slay(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/slay")) {
return EXIT_FAIL;
}
//Check if the command is enabled //Check if the command is enabled
if(vMinecraftSettings.getInstance().cmdEzModo()) { if(vMinecraftSettings.getInstance().cmdEzModo()) {
//Get the player by name //Get the player by name
@ -732,6 +774,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int invuln(Player player, String[] args) public static int invuln(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/ezmodo")) {
return EXIT_FAIL;
}
//If the command is enabled //If the command is enabled
if (vMinecraftSettings.getInstance().cmdEzModo()) { if (vMinecraftSettings.getInstance().cmdEzModo()) {
//If the player is already invulnerable, turn ezmodo off. //If the player is already invulnerable, turn ezmodo off.
@ -760,6 +806,10 @@ public class vMinecraftCommands{
//===================================================================== //=====================================================================
public static int ezlist(Player player, String[] args) public static int ezlist(Player player, String[] args)
{ {
//Make sure the user has access to the command
if(!player.canUseCommand("/ezmodo")) {
return EXIT_FAIL;
}
//If the feature is enabled list the players //If the feature is enabled list the players
if(vMinecraftSettings.getInstance().cmdEzModo()) { if(vMinecraftSettings.getInstance().cmdEzModo()) {
player.sendMessage("Ezmodo: " + vMinecraftSettings.getInstance().ezModoList()); player.sendMessage("Ezmodo: " + vMinecraftSettings.getInstance().ezModoList());
@ -907,10 +957,6 @@ class commandList {
//Use: Attempts to call a command //Use: Attempts to call a command
//===================================================================== //=====================================================================
public int call(String name, Player player, String[] arg){ public int call(String name, Player player, String[] arg){
//Make sure the user has access to the command
if(!player.canUseCommand(name)) {
return EXIT_FAIL;
}
//Search for the command //Search for the command
for(command cmd : commands) for(command cmd : commands)
{ {

View File

@ -282,8 +282,6 @@ class PlayerList
//Use: Finds if the specified player is in the ignore list //Use: Finds if the specified player is in the ignore list
//===================================================================== //=====================================================================
public boolean isIgnored(Player player){ public boolean isIgnored(Player player){
for(String pl : ignoreList)
log.log(Level.INFO, pl);
return ignoreList.contains(player.getName()); return ignoreList.contains(player.getName());
} }