Fixes to several commands & console usage. Fixes Issue #150

This commit is contained in:
GJ 2012-02-11 09:01:46 -05:00
parent 9278ca4d27
commit 105b8b5a91
6 changed files with 45 additions and 25 deletions

View File

@ -16,7 +16,6 @@ Hearing that people enjoy mcMMO and seeing the daily youtube videos about my mod
=== Compiling === Compiling
Required Libraries: Required Libraries:
* CraftBukkit
* Spout API * Spout API
Required to Run: Required to Run:

View File

@ -24,7 +24,12 @@ public class MmoeditCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!mcPermissions.getInstance().mmoedit((Player) sender)) { Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
sender.sendMessage("This command requires permissions."); sender.sendMessage("This command requires permissions.");
return true; return true;
} }
@ -51,7 +56,6 @@ public class MmoeditCommand implements CommandExecutor {
return true; return true;
} }
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
if (!mcPermissions.getInstance().mmoedit(player)) { if (!mcPermissions.getInstance().mmoedit(player)) {

View File

@ -30,7 +30,10 @@ public class StatsCommand implements CommandExecutor {
return true; return true;
} }
Player player = (Player) sender; Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
if(args.length != 1) { if(args.length != 1) {

View File

@ -30,13 +30,21 @@ public class WhoisCommand implements CommandExecutor {
return true; return true;
} }
Player player = (Player) sender; Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (!mcPermissions.getInstance().whois(player)) { if (player != null && !mcPermissions.getInstance().whois(player)) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true; return true;
} }
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
return true;
}
if (args.length < 1) { if (args.length < 1) {
player.sendMessage(ChatColor.RED + "Proper usage is /whois <playername>"); player.sendMessage(ChatColor.RED + "Proper usage is /whois <playername>");
return true; return true;

View File

@ -27,8 +27,8 @@ public class XprateCommand implements CommandExecutor {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
if(args.length <= 0) if(args.length <= 0)
{ {
System.out.println(mcLocale.getString("Commands.xprate.proper", new Object[] {"/xprate"})); System.out.println(mcLocale.getString("Commands.xprate.proper", new Object[] {"xprate"}));
System.out.println(mcLocale.getString("Commands.xprate.proper2", new Object[] {"/xprate"})); System.out.println(mcLocale.getString("Commands.xprate.proper2", new Object[] {"xprate"}));
} }
if(args.length == 1 && args[0].equalsIgnoreCase("reset")) if(args.length == 1 && args[0].equalsIgnoreCase("reset"))
@ -81,8 +81,8 @@ public class XprateCommand implements CommandExecutor {
} }
if(args.length <= 0) if(args.length <= 0)
{ {
player.sendMessage(mcLocale.getString("Commands.xprate.proper", new Object[] {"/xprate"})); player.sendMessage(mcLocale.getString("Commands.xprate.proper", new Object[] {"xprate"}));
player.sendMessage(mcLocale.getString("Commands.xprate.proper2", new Object[] {"/xprate"})); player.sendMessage(mcLocale.getString("Commands.xprate.proper2", new Object[] {"xprate"}));
} }
if(args.length == 1 && args[0].equalsIgnoreCase("reset")) if(args.length == 1 && args[0].equalsIgnoreCase("reset"))
{ {

View File

@ -44,10 +44,12 @@ public class ACommand implements CommandExecutor {
return true; return true;
} }
Player player = (Player) sender; Player player = null;
PlayerProfile PP = Users.getProfile(player); if (sender instanceof Player) {
player = (Player) sender;
}
if (!mcPermissions.getInstance().adminChat(player) && !player.isOp()) { if (player != null && !mcPermissions.getInstance().adminChat(player) && !player.isOp()) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true; return true;
} }
@ -70,6 +72,10 @@ public class ACommand implements CommandExecutor {
return true; return true;
} }
if(player != null)
{
PlayerProfile PP = Users.getProfile(player);
if (PP.getPartyChatMode()) if (PP.getPartyChatMode())
PP.togglePartyChat(); PP.togglePartyChat();
@ -82,7 +88,7 @@ public class ACommand implements CommandExecutor {
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff")); player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff"));
// player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off"); // player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off");
} }
}
return true; return true;
} }
} }