From bf361f6824b225d1ec21153d1759fde4a7977109 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 4 Apr 2012 18:35:39 -0400 Subject: [PATCH] More command cleaning. --- .../nossr50/commands/mc/McabilityCommand.java | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/mc/McabilityCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/McabilityCommand.java index a4efcbc30..85f3f3637 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/McabilityCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/McabilityCommand.java @@ -1,44 +1,37 @@ package com.gmail.nossr50.commands.mc; -import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.Users; -import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.mcLocale; public class McabilityCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - Player player = null; - if (sender instanceof Player) { - player = (Player) sender; + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (CommandHelper.noConsoleUsage(sender)) { + return true; } - if (player != null && !mcPermissions.getInstance().mcAbility(player)) { - player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); - return true; - } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) { + return true; + } - if (!(sender instanceof Player)) { - sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale. - return true; - } + PlayerProfile PP = Users.getProfile((Player) sender); - PlayerProfile PP = Users.getProfile(player); + if (PP.getAbilityUse()) { + sender.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOff")); + } + else { + sender.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOn")); + } - if (PP.getAbilityUse()) { - player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOff")); - PP.toggleAbilityUse(); - } else { - player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOn")); - PP.toggleAbilityUse(); - } + PP.toggleAbilityUse(); - return true; - } + return true; + } }