2012-01-09 20:00:13 +01:00
|
|
|
package com.gmail.nossr50.commands.mc;
|
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
2012-04-19 23:21:55 +02:00
|
|
|
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;
|
|
|
|
|
2012-06-07 00:02:22 +02:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2012-04-19 23:21:55 +02:00
|
|
|
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 {
|
2012-06-07 00:02:22 +02:00
|
|
|
private final mcMMO plugin;
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-06-07 00:02:22 +02:00
|
|
|
public McrefreshCommand(mcMMO instance) {
|
2012-04-19 23:21:55 +02:00
|
|
|
this.plugin = instance;
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-19 23:21:55 +02:00
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
OfflinePlayer player;
|
2012-07-03 16:04:04 +02:00
|
|
|
PlayerProfile profile;
|
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
|
|
|
|
2012-04-19 23:21:55 +02:00
|
|
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) {
|
|
|
|
return true;
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-19 23:21:55 +02:00
|
|
|
switch (args.length) {
|
|
|
|
case 0:
|
|
|
|
if (sender instanceof Player) {
|
|
|
|
player = (Player) sender;
|
2012-07-03 16:04:04 +02:00
|
|
|
profile = Users.getProfile(player);
|
2012-04-19 23:21:55 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
sender.sendMessage(usage);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-19 23:21:55 +02:00
|
|
|
case 1:
|
|
|
|
player = plugin.getServer().getOfflinePlayer(args[0]);
|
2012-07-03 16:04:04 +02:00
|
|
|
profile = Users.getProfile(player);
|
2012-04-19 23:21:55 +02:00
|
|
|
String playerName = player.getName();
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-10-31 01:59:58 +01:00
|
|
|
if (profile == null) {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-03 16:04:04 +02:00
|
|
|
if (!profile.isLoaded()) {
|
2012-04-27 11:47:11 +02:00
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
2012-04-19 23:21:55 +02:00
|
|
|
return true;
|
|
|
|
}
|
2012-02-09 20:10:39 +01:00
|
|
|
|
2012-04-19 23:21:55 +02:00
|
|
|
sender.sendMessage("You have refreshed " + playerName + "'s cooldowns!"); //TODO: Use locale
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-19 23:21:55 +02:00
|
|
|
break;
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-19 23:21:55 +02:00
|
|
|
default:
|
|
|
|
sender.sendMessage(usage);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-03 16:04:04 +02:00
|
|
|
profile.setRecentlyHurt(0);
|
|
|
|
profile.resetCooldowns();
|
|
|
|
profile.resetToolPrepMode();
|
|
|
|
profile.resetAbilityMode();
|
2012-04-19 23:21:55 +02:00
|
|
|
|
|
|
|
if (player.isOnline()) {
|
2012-04-27 11:47:11 +02:00
|
|
|
((Player) player).sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
2012-04-19 23:21:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|