2013-02-01 13:41:26 -05:00
|
|
|
package com.gmail.nossr50.commands.admin;
|
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;
|
|
|
|
|
2013-02-04 00:54:31 -05:00
|
|
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
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;
|
2013-02-04 00:54:31 -05:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
2012-04-27 02:47:11 -07:00
|
|
|
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) {
|
2012-07-03 10:04:04 -04:00
|
|
|
PlayerProfile profile;
|
2012-01-09 11:00:13 -08:00
|
|
|
|
2012-04-19 17:21:55 -04:00
|
|
|
switch (args.length) {
|
|
|
|
case 0:
|
2013-02-04 15:10:07 -05:00
|
|
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcrefresh")) {
|
|
|
|
sender.sendMessage(command.getPermissionMessage());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-02-04 00:54:31 -05:00
|
|
|
if (!(sender instanceof Player)) {
|
|
|
|
return false;
|
2012-04-19 17:21:55 -04:00
|
|
|
}
|
2013-02-04 00:54:31 -05:00
|
|
|
|
|
|
|
profile = Users.getPlayer(sender.getName()).getProfile();
|
2013-02-05 08:23:03 -05:00
|
|
|
|
|
|
|
profile.setRecentlyHurt(0);
|
|
|
|
profile.resetCooldowns();
|
|
|
|
profile.resetToolPrepMode();
|
|
|
|
profile.resetAbilityMode();
|
|
|
|
|
2013-02-04 00:54:31 -05:00
|
|
|
sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
2013-02-05 08:23:03 -05:00
|
|
|
return true;
|
2012-01-09 11:00:13 -08:00
|
|
|
|
2012-04-19 17:21:55 -04:00
|
|
|
case 1:
|
2013-02-04 00:54:31 -05:00
|
|
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcrefresh.others")) {
|
|
|
|
sender.sendMessage(command.getPermissionMessage());
|
2013-02-04 15:10:07 -05:00
|
|
|
return true;
|
2013-02-03 13:45:37 -08:00
|
|
|
}
|
|
|
|
|
2013-02-04 00:54:31 -05:00
|
|
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
2012-01-09 11:00:13 -08:00
|
|
|
|
2013-02-04 00:54:31 -05:00
|
|
|
if (mcMMOPlayer == null) {
|
|
|
|
profile = new PlayerProfile(args[0], false);
|
2012-10-30 17:59:58 -07:00
|
|
|
|
2013-02-04 00:54:31 -05:00
|
|
|
if (!profile.isLoaded()) {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
|
|
return true;
|
|
|
|
}
|
2013-02-05 08:23:03 -05:00
|
|
|
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
|
|
return true;
|
2012-04-19 17:21:55 -04:00
|
|
|
}
|
2013-02-05 08:23:03 -05:00
|
|
|
profile = mcMMOPlayer.getProfile();
|
|
|
|
Player player = mcMMOPlayer.getPlayer();
|
2012-02-09 11:10:39 -08:00
|
|
|
|
2013-02-05 08:23:03 -05:00
|
|
|
if (!player.isOnline()) {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
|
|
|
return true;
|
2013-02-04 00:54:31 -05:00
|
|
|
}
|
2012-01-09 11:00:13 -08:00
|
|
|
|
2013-02-05 08:23:03 -05:00
|
|
|
profile.setRecentlyHurt(0);
|
|
|
|
profile.resetCooldowns();
|
|
|
|
profile.resetToolPrepMode();
|
|
|
|
profile.resetAbilityMode();
|
|
|
|
|
|
|
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
2013-02-04 00:54:31 -05:00
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0]));
|
2013-02-05 08:23:03 -05:00
|
|
|
return true;
|
2012-01-09 11:00:13 -08:00
|
|
|
|
2012-04-19 17:21:55 -04:00
|
|
|
default:
|
2013-02-04 00:54:31 -05:00
|
|
|
return false;
|
2012-04-19 17:21:55 -04:00
|
|
|
}
|
|
|
|
}
|
2012-01-09 11:00:13 -08:00
|
|
|
}
|