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
Required Libraries:
* CraftBukkit
* Spout API
Required to Run:

View File

@ -24,7 +24,12 @@ public class MmoeditCommand implements CommandExecutor {
@Override
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.");
return true;
}
@ -51,7 +56,6 @@ public class MmoeditCommand implements CommandExecutor {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
if (!mcPermissions.getInstance().mmoedit(player)) {

View File

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

View File

@ -30,13 +30,21 @@ public class WhoisCommand implements CommandExecutor {
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"));
return true;
}
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
return true;
}
if (args.length < 1) {
player.sendMessage(ChatColor.RED + "Proper usage is /whois <playername>");
return true;

View File

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

View File

@ -44,10 +44,12 @@ public class ACommand implements CommandExecutor {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
Player player = null;
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"));
return true;
}
@ -70,19 +72,23 @@ public class ACommand implements CommandExecutor {
return true;
}
if (PP.getPartyChatMode())
PP.togglePartyChat();
if(player != null)
{
PlayerProfile PP = Users.getProfile(player);
PP.toggleAdminChat();
if (PP.getPartyChatMode())
PP.togglePartyChat();
if (PP.getAdminChatMode()) {
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOn"));
// player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.GREEN + "On");
} else {
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff"));
// player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off");
PP.toggleAdminChat();
if (PP.getAdminChatMode()) {
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOn"));
// player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.GREEN + "On");
} else {
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff"));
// player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off");
}
}
return true;
}
}