diff --git a/src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java index da37b64de..a98b22214 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.commands.mc; import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -8,61 +9,67 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.mcPermissions; -import com.gmail.nossr50.datatypes.AbilityType; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.datatypes.ToolType; import com.gmail.nossr50.locale.mcLocale; public class McrefreshCommand implements CommandExecutor { - private final mcMMO plugin; + private final mcMMO plugin; - public McrefreshCommand(mcMMO instance) { - this.plugin = instance; - } + public McrefreshCommand(mcMMO instance) { + this.plugin = instance; + } - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + OfflinePlayer player; + PlayerProfile PP; + String usage = ChatColor.RED + "Proper usage is /mcrefresh [playername]"; //TODO: Needs more locale - if (!(sender instanceof Player)) { - sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale. - return true; - } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) { + return true; + } - Player player = (Player) sender; - PlayerProfile PP = Users.getProfile(player); + switch (args.length) { + case 0: + if (sender instanceof Player) { + player = (Player) sender; + PP = Users.getProfile(player); + } + else { + sender.sendMessage(usage); + return true; + } + break; - if (!mcPermissions.getInstance().mcrefresh(player)) { - player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); - return true; - } - if (args.length >= 1 && (plugin.getServer().getPlayer(args[0]) != null)) { - player.sendMessage("You have refreshed " + args[0] + "'s cooldowns!"); //TODO: Needs more locale. - player = plugin.getServer().getPlayer(args[0]); - } + case 1: + player = plugin.getServer().getOfflinePlayer(args[0]); + PP = Users.getProfile(player); + String playerName = player.getName(); - /* - * PREP MODES - */ - PP = Users.getProfile(player); - PP.setRecentlyHurt((long) 0); - PP.setToolPreparationMode(ToolType.AXE, false); - PP.setToolPreparationMode(ToolType.FISTS, false); - PP.setToolPreparationMode(ToolType.HOE, false); - PP.setToolPreparationMode(ToolType.PICKAXE, false); - PP.setToolPreparationMode(ToolType.SWORD, false); + if (!PP.isLoaded()) { + sender.sendMessage(mcLocale.getString("Commands.DoesNotExist")); + return true; + } - //RESET COOLDOWNS - PP.resetCooldowns(); - PP.setAbilityMode(AbilityType.GREEN_TERRA, false); - PP.setAbilityMode(AbilityType.GIGA_DRILL_BREAKER, false); - PP.setAbilityMode(AbilityType.SERRATED_STRIKES, false); - PP.setAbilityMode(AbilityType.SUPER_BREAKER, false); - PP.setAbilityMode(AbilityType.TREE_FELLER, false); - PP.setAbilityMode(AbilityType.BERSERK, false); + sender.sendMessage("You have refreshed " + playerName + "'s cooldowns!"); //TODO: Use locale - player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesRefreshed")); + break; - return true; - } + default: + sender.sendMessage(usage); + return true; + } + + PP.setRecentlyHurt((long) 0); + PP.resetCooldowns(); + PP.resetToolPrepMode(); + PP.resetAbilityMode(); + + if (player.isOnline()) { + ((Player) player).sendMessage(mcLocale.getString("Ability.Generic.Refresh")); + } + + return true; + } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index 17d14d8ed..5944d593a 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -648,6 +648,15 @@ public class PlayerProfile { * Tools */ + /** + * Reset the prep modes of all tools. + */ + public void resetToolPrepMode() { + for (ToolType tool : ToolType.values()) { + setToolPreparationMode(tool, false); + } + } + /** * Get the current prep mode of a tool. * @@ -741,6 +750,15 @@ public class PlayerProfile { * Abilities */ + /** + * Reset the prep modes of all tools. + */ + public void resetAbilityMode() { + for (AbilityType ability : AbilityType.values()) { + setAbilityMode(ability, false); + } + } + /** * Get the mode of an ability. * diff --git a/src/main/resources/locale/locale_en_us.properties b/src/main/resources/locale/locale_en_us.properties index fa8ff0924..8cbe3e18e 100644 --- a/src/main/resources/locale/locale_en_us.properties +++ b/src/main/resources/locale/locale_en_us.properties @@ -24,7 +24,7 @@ Acrobatics.Effect.1=Reduces or Negates fall damage Acrobatics.Effect.2=Graceful Roll Acrobatics.Effect.3=Twice as effective as a normal Roll Acrobatics.Effect.4=Dodge -Acrobatics.Effect.5=Reduce fall damage by half +Acrobatics.Effect.5=Reduce attack damage by half Acrobatics.Listener=Acrobatics: Acrobatics.Roll.Chance=[[RED]]Roll Chance: [[YELLOW]]{0}% Acrobatics.Roll.GraceChance=[[RED]]Graceful Roll Chance: [[YELLOW]]{0}% @@ -384,7 +384,7 @@ Commands.Invite.Accepted=[[GREEN]]Invite Accepted. You have joined party {0} Commands.Invite.Success=[[GREEN]]Invite sent successfully. Commands.Leaderboards= [[RED]]- Leaderboards Commands.mcgod=[[RED]]- Toggle GodMode -Commands.mmoedit= [[RED]] - Modify target +Commands.mmoedit=[playername] [[RED]] - Modify target Commands.ModDescription=[[RED]]- Read brief mod description Commands.NoConsole=This command does not support console usage. Commands.Other=[[GREEN]]--OTHER COMMANDS-- @@ -394,13 +394,13 @@ Commands.Party.Chat.On=Party Chat only [[GREEN]]On Commands.Party.Commands=[[GREEN]]--PARTY COMMANDS-- Commands.Party.Invite.0=[[RED]]ALERT: [[GREEN]]You have received a party invite for {0} from {1} Commands.Party.Invite.1=[[YELLOW]]Type [[GREEN]]/{0}[[YELLOW]] to accept the invite -Commands.Party.Invite= [[RED]]- Send party invite +Commands.Party.Invite= [[RED]]- Send party invite Commands.Party.Join=Joined Party: {0} Commands.Party.Leave=[[RED]]You have left that party Commands.Party.Members=[[GREEN]]Party Members Commands.Party.None=[[RED]]You are not in a party. Commands.Party.Quit=[[RED]]- Leave your current party -Commands.Party.Teleport= [[RED]]- Teleport to party member +Commands.Party.Teleport= [[RED]]- Teleport to party member Commands.Party.Toggle=[[RED]]- Toggle Party Chat Commands.Party= [[RED]]- Create/Join designated party Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard--