More command cleaning.

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

View File

@ -1,44 +1,37 @@
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) { return true;
player = (Player) sender;
} }
if (player != null && !mcPermissions.getInstance().mcAbility(player)) { if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); return true;
return true; }
}
if (!(sender instanceof Player)) { PlayerProfile PP = Users.getProfile((Player) sender);
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
return true;
}
PlayerProfile PP = Users.getProfile(player); if (PP.getAbilityUse()) {
sender.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOff"));
}
else {
sender.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOn"));
}
if (PP.getAbilityUse()) { PP.toggleAbilityUse();
player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOff"));
PP.toggleAbilityUse();
} else {
player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOn"));
PP.toggleAbilityUse();
}
return true; return true;
} }
} }