More command cleaning.

This commit is contained in:
GJ 2012-04-04 18:35:39 -04:00
parent 74ee210514
commit bf361f6824

View File

@ -1,43 +1,36 @@
package com.gmail.nossr50.commands.mc; package com.gmail.nossr50.commands.mc;
import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.Users; 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.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
public class McabilityCommand implements CommandExecutor { public class McabilityCommand 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) {
Player player = null; if (CommandHelper.noConsoleUsage(sender)) {
if (sender instanceof Player) {
player = (Player) sender;
}
if (player != null && !mcPermissions.getInstance().mcAbility(player)) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true; return true;
} }
if (!(sender instanceof Player)) { if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true; return true;
} }
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile((Player) sender);
if (PP.getAbilityUse()) { if (PP.getAbilityUse()) {
player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOff")); sender.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOff"));
PP.toggleAbilityUse();
} else {
player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOn"));
PP.toggleAbilityUse();
} }
else {
sender.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOn"));
}
PP.toggleAbilityUse();
return true; return true;
} }