2013-02-01 13:41:26 -05:00
|
|
|
package com.gmail.nossr50.commands.admin;
|
2012-01-09 11:00:13 -08:00
|
|
|
|
2012-04-19 17:21:55 -04: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;
|
|
|
|
|
2012-06-06 18:02:22 -04:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2012-04-19 17:21:55 -04:00
|
|
|
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 {
|
2012-04-19 17:21:55 -04:00
|
|
|
@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
|
|
|
|
2013-02-03 13:45:37 -08:00
|
|
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcrefresh")) {
|
2012-04-19 17:21:55 -04:00
|
|
|
return true;
|
|
|
|
}
|
2012-01-09 11:00:13 -08:00
|
|
|
|
2012-04-19 17:21:55 -04: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);
|
2012-04-19 17:21:55 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
sender.sendMessage(usage);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2012-01-09 11:00:13 -08:00
|
|
|
|
2012-04-19 17:21:55 -04:00
|
|
|
case 1:
|
2013-02-03 13:45:37 -08:00
|
|
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcrefresh.others")) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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);
|
2012-04-19 17:21:55 -04:00
|
|
|
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"));
|
2012-04-19 17:21:55 -04:00
|
|
|
return true;
|
|
|
|
}
|
2012-02-09 11:10:39 -08:00
|
|
|
|
2013-02-02 02:55:49 -05:00
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", playerName));
|
2012-01-09 11:00:13 -08:00
|
|
|
|
2012-04-19 17:21:55 -04:00
|
|
|
break;
|
2012-01-09 11:00:13 -08:00
|
|
|
|
2012-04-19 17:21:55 -04:00
|
|
|
default:
|
|
|
|
sender.sendMessage(usage);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-03 10:04:04 -04:00
|
|
|
profile.setRecentlyHurt(0);
|
|
|
|
profile.resetCooldowns();
|
|
|
|
profile.resetToolPrepMode();
|
|
|
|
profile.resetAbilityMode();
|
2012-04-19 17:21:55 -04:00
|
|
|
|
|
|
|
if (player.isOnline()) {
|
2012-04-27 02:47:11 -07:00
|
|
|
((Player) player).sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
2012-04-19 17:21:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2012-01-09 11:00:13 -08:00
|
|
|
}
|