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

74 lines
2.3 KiB
Java
Raw Normal View History

package com.gmail.nossr50.commands.admin;
2012-01-09 11:00:13 -08:00
import org.bukkit.OfflinePlayer;
2012-01-09 11:00:13 -08: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 11:00:13 -08:00
import com.gmail.nossr50.datatypes.PlayerProfile;
2012-04-27 02:47:11 -07:00
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
2012-01-09 11:00:13 -08:00
public class McrefreshCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
OfflinePlayer player;
2012-07-03 10:04:04 -04:00
PlayerProfile profile;
2013-02-02 02:55:49 -05:00
String usage = LocaleLoader.getString("Commands.Usage.1", "mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]");
2012-01-09 11:00:13 -08:00
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) {
return true;
}
2012-01-09 11:00:13 -08:00
switch (args.length) {
case 0:
if (sender instanceof Player) {
player = (Player) sender;
2012-07-03 10:04:04 -04:00
profile = Users.getProfile(player);
}
else {
sender.sendMessage(usage);
return true;
}
break;
2012-01-09 11:00:13 -08:00
case 1:
2013-01-26 23:01:55 +01:00
player = mcMMO.p.getServer().getOfflinePlayer(args[0]);
2012-07-03 10:04:04 -04:00
profile = Users.getProfile(player);
String playerName = player.getName();
2012-01-09 11:00:13 -08:00
2012-10-30 17:59:58 -07:00
if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
2012-07-03 10:04:04 -04:00
if (!profile.isLoaded()) {
2012-04-27 02:47:11 -07:00
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
2013-02-02 02:55:49 -05:00
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", playerName));
2012-01-09 11:00:13 -08:00
break;
2012-01-09 11:00:13 -08:00
default:
sender.sendMessage(usage);
return true;
}
2012-07-03 10:04:04 -04:00
profile.setRecentlyHurt(0);
profile.resetCooldowns();
profile.resetToolPrepMode();
profile.resetAbilityMode();
if (player.isOnline()) {
2012-04-27 02:47:11 -07:00
((Player) player).sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
}
return true;
}
2012-01-09 11:00:13 -08:00
}