mcMMO/src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java

76 lines
2.2 KiB
Java
Raw Normal View History

2012-01-09 20:00:13 +01:00
package com.gmail.nossr50.commands.mc;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
2012-01-09 20:00:13 +01:00
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
2012-01-09 20:00:13 +01:00
import com.gmail.nossr50.datatypes.PlayerProfile;
2012-04-27 11:47:11 +02:00
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
2012-01-09 20:00:13 +01:00
public class McrefreshCommand implements CommandExecutor {
private final mcMMO plugin;
2012-01-09 20:00:13 +01:00
public McrefreshCommand(mcMMO instance) {
this.plugin = instance;
}
2012-01-09 20:00:13 +01:00
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
OfflinePlayer player;
PlayerProfile PP;
2012-04-23 01:34:34 +02:00
String usage = ChatColor.RED + "Proper usage is /mcrefresh [player]"; //TODO: Needs more locale
2012-01-09 20:00:13 +01:00
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) {
return true;
}
2012-01-09 20:00:13 +01:00
switch (args.length) {
case 0:
if (sender instanceof Player) {
player = (Player) sender;
PP = Users.getProfile(player);
}
else {
sender.sendMessage(usage);
return true;
}
break;
2012-01-09 20:00:13 +01:00
case 1:
player = plugin.getServer().getOfflinePlayer(args[0]);
PP = Users.getProfile(player);
String playerName = player.getName();
2012-01-09 20:00:13 +01:00
if (!PP.isLoaded()) {
2012-04-27 11:47:11 +02:00
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
sender.sendMessage("You have refreshed " + playerName + "'s cooldowns!"); //TODO: Use locale
2012-01-09 20:00:13 +01:00
break;
2012-01-09 20:00:13 +01:00
default:
sender.sendMessage(usage);
return true;
}
2012-06-05 15:57:10 +02:00
PP.setRecentlyHurt(0);
PP.resetCooldowns();
PP.resetToolPrepMode();
PP.resetAbilityMode();
if (player.isOnline()) {
2012-04-27 11:47:11 +02:00
((Player) player).sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
}
return true;
}
2012-01-09 20:00:13 +01:00
}