diff --git a/src/main/java/com/gmail/nossr50/commands/general/AddlevelsCommand.java b/src/main/java/com/gmail/nossr50/commands/general/AddlevelsCommand.java index bf802cf2c..f0202409c 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/AddlevelsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/AddlevelsCommand.java @@ -30,7 +30,7 @@ public class AddlevelsCommand implements CommandExecutor{ int levels; SkillType skill; String skillName; - String usage = ChatColor.RED + "Proper usage is /addlevels [playername] "; //TODO: Needs more locale. + String usage = ChatColor.RED + "Proper usage is /addlevels [player] "; //TODO: Needs more locale. if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) { return true; @@ -39,7 +39,12 @@ public class AddlevelsCommand implements CommandExecutor{ switch (args.length) { case 2: if (sender instanceof Player) { - if (m.isInt(args[1]) && Skills.isSkill(args[0])) { + if (!Skills.isSkill(args[0])) { + sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid")); + return true; + } + + if (m.isInt(args[1])) { modifiedPlayer = (Player) sender; levels = Integer.valueOf(args[1]); skill = Skills.getSkillType(args[0]); @@ -72,7 +77,12 @@ public class AddlevelsCommand implements CommandExecutor{ return true; } - if (m.isInt(args[2]) && Skills.isSkill(args[1])) { + if (!Skills.isSkill(args[1])) { + sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid")); + return true; + } + + if (m.isInt(args[2])) { levels = Integer.valueOf(args[2]); skill = Skills.getSkillType(args[1]); String message; diff --git a/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java index a23bb1b4c..7df7ede71 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java @@ -11,6 +11,7 @@ import com.gmail.nossr50.m; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.SkillType; +import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.skills.Skills; //TODO: Any way we can make this work for offline use? @@ -36,7 +37,12 @@ public class AddxpCommand implements CommandExecutor { switch (args.length) { case 2: if (sender instanceof Player) { - if (m.isInt(args[1]) && Skills.isSkill(args[0])) { + if (!Skills.isSkill(args[1])) { + sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid")); + return true; + } + + if (m.isInt(args[1])) { modifiedPlayer = (Player) sender; xp = Integer.valueOf(args[1]); skill = Skills.getSkillType(args[0]); @@ -59,6 +65,9 @@ public class AddxpCommand implements CommandExecutor { Skills.XpCheckSkill(skill, modifiedPlayer); } } + else { + sender.sendMessage(usage); + } } else { sender.sendMessage(usage); @@ -70,7 +79,17 @@ public class AddxpCommand implements CommandExecutor { modifiedPlayer = plugin.getServer().getPlayer(args[0]); String playerName = modifiedPlayer.getName(); - if (modifiedPlayer != null && m.isInt(args[2]) && Skills.isSkill(args[1])) { + if (!Users.getProfile(modifiedPlayer).isLoaded()) { + sender.sendMessage(mcLocale.getString("Commands.DoesNotExist")); + return true; + } + + if (!Skills.isSkill(args[1])) { + sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid")); + return true; + } + + if (m.isInt(args[2])) { xp = Integer.valueOf(args[2]); skill = Skills.getSkillType(args[1]); String message; diff --git a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java index 213d96d11..3d1242818 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java @@ -25,7 +25,7 @@ public class InspectCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { OfflinePlayer target; PlayerProfile PP; - String usage = "Proper usage is /inspect "; //TODO: Needs more locale. + String usage = "Proper usage is /inspect "; //TODO: Needs more locale. if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) { return true; diff --git a/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java index e5456faf9..258579d35 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java @@ -30,7 +30,7 @@ public class MmoeditCommand implements CommandExecutor { int newValue; SkillType skill; String skillName; - String usage = ChatColor.RED + "Proper usage is /mmoedit [playername] "; //TODO: Needs more locale. + String usage = ChatColor.RED + "Proper usage is /mmoedit [player] "; //TODO: Needs more locale. if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) { return true; @@ -39,7 +39,12 @@ public class MmoeditCommand implements CommandExecutor { switch (args.length) { case 2: if (sender instanceof Player) { - if (m.isInt(args[1]) && Skills.isSkill(args[0])) { + if (!Skills.isSkill(args[0])) { + sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid")); + return true; + } + + if (m.isInt(args[1])) { modifiedPlayer = (Player) sender; newValue = Integer.valueOf(args[1]); skill = Skills.getSkillType(args[0]); @@ -55,6 +60,9 @@ public class MmoeditCommand implements CommandExecutor { PP.modifySkill(skill, newValue); sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale. } + else { + sender.sendMessage(usage); + } } else { sender.sendMessage(usage); @@ -72,7 +80,12 @@ public class MmoeditCommand implements CommandExecutor { return true; } - if (m.isInt(args[2]) && Skills.isSkill(args[1])) { + if (!Skills.isSkill(args[1])) { + sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid")); + return true; + } + + if (m.isInt(args[2])) { newValue = Integer.valueOf(args[2]); skill = Skills.getSkillType(args[1]); String message; 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 a98b22214..606c10d84 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java @@ -24,7 +24,7 @@ public class McrefreshCommand implements CommandExecutor { 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 + String usage = ChatColor.RED + "Proper usage is /mcrefresh [player]"; //TODO: Needs more locale if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) { return true; diff --git a/src/main/java/com/gmail/nossr50/commands/mc/McremoveCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/McremoveCommand.java index 02784c3f0..5c7ba0277 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/McremoveCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/McremoveCommand.java @@ -27,7 +27,7 @@ public class McremoveCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { String playerName; - String usage = ChatColor.RED + "Proper usage is /mcremove "; //TODO: Needs more locale. + String usage = ChatColor.RED + "Proper usage is /mcremove "; //TODO: Needs more locale. String success; if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) { diff --git a/src/main/java/com/gmail/nossr50/commands/mc/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/MctopCommand.java index d833fdb57..8105ff0d6 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/MctopCommand.java @@ -18,7 +18,7 @@ public class MctopCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - String usage = ChatColor.RED + "Proper usage is /mctop [skillname] [page]"; //TODO: Needs more locale. + String usage = ChatColor.RED + "Proper usage is /mctop [skill] [page]"; //TODO: Needs more locale. if (!LoadProperties.useMySQL) { switch (args.length) { @@ -34,13 +34,18 @@ public class MctopCommand implements CommandExecutor { flatfileDisplay(1, args[0].toUpperCase(), sender); } else { - sender.sendMessage(usage); + sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid")); } return true; case 2: - if (Skills.isSkill(args[0]) && m.isInt(args[1])) { + if (!Skills.isSkill(args[0])) { + sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid")); + return true; + } + + if (m.isInt(args[1])) { flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender); } else { @@ -70,19 +75,26 @@ public class MctopCommand implements CommandExecutor { sqlDisplay(1, args[0].toLowerCase(), sender); } else { - sender.sendMessage(usage); + sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid")); } return true; case 2: - if (Skills.isSkill(args[0]) && m.isInt(args[1])) { + if (!Skills.isSkill(args[0])) { + sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid")); + return true; + } + + if (m.isInt(args[1])) { sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender); } else { sender.sendMessage(usage); } + return true; + default: sender.sendMessage(usage); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java index 847424e95..c0665ef22 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java @@ -13,6 +13,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.party.Party; +//TODO: Make this work from console. public class InviteCommand implements CommandExecutor { private final mcMMO plugin; @@ -22,7 +23,7 @@ public class InviteCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - String usage = ChatColor.RED + "Proper usage is /invite "; //TODO: Needs more locale. + String usage = ChatColor.RED + "Proper usage is /invite "; //TODO: Needs more locale. if (CommandHelper.noConsoleUsage(sender)) { return true; @@ -52,14 +53,20 @@ public class InviteCommand implements CommandExecutor { PPt.modifyInvite(PP.getParty()); player.sendMessage(mcLocale.getString("Commands.Invite.Success")); + target.sendMessage(mcLocale.getString("Commands.Party.Invite.0", new Object[] { PPt.getInvite(), player.getName() })); target.sendMessage(mcLocale.getString("Commands.Party.Invite.1")); + return true; } else { player.sendMessage(mcLocale.getString("Party.Locked")); return true; } } + else { + player.sendMessage(mcLocale.getString("Party.Player.Invalid")); + return true; + } default: sender.sendMessage(usage); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PCommand.java index c9a20d25b..211d0756f 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PCommand.java @@ -24,7 +24,7 @@ public class PCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { PlayerProfile PP; - String usage = ChatColor.RED + "Proper usage is /p "; //TODO: Needs more locale. + String usage = ChatColor.RED + "Proper usage is /p "; //TODO: Needs more locale. if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) { return true; @@ -81,7 +81,7 @@ public class PCommand implements CommandExecutor { return true; } - if (!Party.getInstance().getParties().contains(args[0])) { + if (!Party.getInstance().isParty(args[0])) { sender.sendMessage(mcLocale.getString("Party.InvalidName")); return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index ea0fe4fa8..a02489f45 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -78,6 +78,11 @@ public class PartyCommand implements CommandExecutor { return true; case 1: + if (!partyInstance.isParty(args[0])) { + sender.sendMessage(mcLocale.getString("Party.InvalidName")); + return true; + } + if (args[0].equalsIgnoreCase("q")) { if (inParty) { McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.LEFT_PARTY); @@ -166,6 +171,11 @@ public class PartyCommand implements CommandExecutor { return true; case 2: + if (!partyInstance.isParty(args[0])) { + sender.sendMessage(mcLocale.getString("Party.InvalidName")); + return true; + } + if (PP.inParty()) { if (args[0].equalsIgnoreCase("password")) { if (isLeader) { @@ -185,7 +195,7 @@ public class PartyCommand implements CommandExecutor { Player target = plugin.getServer().getPlayer(args[1]); if (target == null) { - player.sendMessage(mcLocale.getString("Party.CouldNotKick", new Object[] { args[1] })); + player.sendMessage(mcLocale.getString("Party.Player.Invalid")); return true; } @@ -218,7 +228,7 @@ public class PartyCommand implements CommandExecutor { Player target = plugin.getServer().getPlayer(args[1]); if (target == null) { - player.sendMessage(mcLocale.getString("Party.CouldNotSetOwner")); + player.sendMessage(mcLocale.getString("Party.Player.Invalid")); return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java index d3e0332c1..9eee81314 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent; @@ -16,72 +16,73 @@ import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.party.Party; public class PtpCommand implements CommandExecutor { - private final mcMMO plugin; + private final mcMMO plugin; - public PtpCommand(mcMMO instance) { - this.plugin = instance; - } + public PtpCommand(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) { + String usage = ChatColor.RED + "Proper usage is /ptp "; //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.noConsoleUsage(sender)) { + return true; + } - Player player = (Player) sender; - PlayerProfile PP = Users.getProfile(player); + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ptp")) { + return true; + } - if (!mcPermissions.getInstance().partyTeleport(player)) { - player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); - return true; - } - - if(!Party.getInstance().isParty(PP.getParty())) - { - player.sendMessage(ChatColor.RED+"You are not in a party!"); //TODO: Needs more locale. - return true; - } - - if(PP.getRecentlyHurt()+(LoadProperties.ptpCommandCooldown*1000) > System.currentTimeMillis()) - { - player.sendMessage(ChatColor.RED+"You've been hurt in the last " + LoadProperties.ptpCommandCooldown + " seconds and cannnot teleport."); //TODO: Needs more locale. - return true; - } - - if (args.length < 1) { - player.sendMessage(ChatColor.RED + "Usage is /ptp "); //TODO: Needs more locale. - return true; - } - - if (plugin.getServer().getPlayer(args[0]) == null) { - player.sendMessage("That is not a valid player"); //TODO: Needs more locale. - } + switch (args.length) { + case 1: + Player player = (Player) sender; + PlayerProfile PP = Users.getProfile(player); - if (plugin.getServer().getPlayer(args[0]) != null) { - Player target = plugin.getServer().getPlayer(args[0]); - PlayerProfile PPt = Users.getProfile(target); - - if (target.isDead()) { - player.sendMessage(ChatColor.RED + "You can't teleport to dead players."); //TODO: Needs more locale. - return true; - } - - if (PP.getParty().equals(PPt.getParty())) { - McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty()); - plugin.getServer().getPluginManager().callEvent(event); + if (!Party.getInstance().isInParty(player, PP)) { + player.sendMessage(mcLocale.getString("Commands.Party.None")); + return true; + } - if (!event.isCancelled()) { - player.teleport(target); - player.sendMessage(ChatColor.GREEN + "You have teleported to " + target.getName()); //TODO: Needs more locale. - target.sendMessage(ChatColor.GREEN + player.getName() + " has teleported to you."); //TODO: Needs more locale. - } - } else { - player.sendMessage(ChatColor.RED + "That player is in a different party than you."); //TODO: Needs more locale. - } - } + if (PP.getRecentlyHurt() + (LoadProperties.ptpCommandCooldown * 1000) > System.currentTimeMillis()) { + player.sendMessage(mcLocale.getString("Party.Teleport.Hurt", new Object[] { LoadProperties.ptpCommandCooldown })); + return true; + } - return true; - } + Player target = plugin.getServer().getPlayer(args[0]); + + if (target == null) { + player.sendMessage(mcLocale.getString("Party.Teleport.Invalid")); + return true; + } + + if (target.isDead()) { + player.sendMessage(mcLocale.getString("Party.Teleport.Dead")); + return true; + } + + if (Party.getInstance().inSameParty(player, target)) { + McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty()); + plugin.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return true; + } + + player.teleport(target); + player.sendMessage(mcLocale.getString("Party.Teleport.Player", new Object[] { target.getName() })); + target.sendMessage(mcLocale.getString("Party.Teleport.Target", new Object[] { player.getName() })); + } + else { + player.sendMessage(mcLocale.getString("Party.NotInYourParty", new Object[] { target.getName() })); + return true; + } + + return true; + + default: + sender.sendMessage(usage); + return true; + } + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/commands/spout/MchudCommand.java b/src/main/java/com/gmail/nossr50/commands/spout/MchudCommand.java index 0302fb474..ba7ce7c6f 100644 --- a/src/main/java/com/gmail/nossr50/commands/spout/MchudCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/spout/MchudCommand.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.commands.spout; +import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -7,10 +8,12 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.HUDType; import com.gmail.nossr50.datatypes.HUDmmo; import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.spout.SpoutStuff; public class MchudCommand implements CommandExecutor { @@ -20,38 +23,55 @@ public class MchudCommand implements CommandExecutor { this.plugin = plugin; } - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!LoadProperties.spoutEnabled) { - sender.sendMessage("This command is not enabled."); //TODO: Needs more locale. - return true; - } + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + String usage = ChatColor.RED + "Proper usage is /mchud "; //TODO: Locale + String invalid = ChatColor.RED + "That is not a valid HUD type."; //TODO: Locale - if (!(sender instanceof Player)) { - sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale. - return true; - } + if (CommandHelper.noConsoleUsage(sender)) { + return true; + } - Player player = (Player) sender; - PlayerProfile PP = Users.getProfile(player); - - if(args.length >= 1) - { - for(HUDType x : HUDType.values()) - { - if(x.toString().toLowerCase().equals(args[0].toLowerCase())) - { - if(SpoutStuff.playerHUDs.containsKey(player)) - { - SpoutStuff.playerHUDs.get(player).resetHUD(); - SpoutStuff.playerHUDs.remove(player); - PP.setHUDType(x); - SpoutStuff.playerHUDs.put(player, new HUDmmo(player, plugin)); - } - } - } - } - - return true; - } + if (!LoadProperties.spoutEnabled || !LoadProperties.xpbar) { + sender.sendMessage(mcLocale.getString("Commands.Disabled")); + return true; + } + + switch (args.length) { + case 1: + Player player = (Player) sender; + PlayerProfile PP = Users.getProfile(player); + HUDType hud; + + if (args[0].equalsIgnoreCase("disabled")) { + hud = HUDType.DISABLED; + } + else if (args[0].equalsIgnoreCase("standard")) { + hud = HUDType.STANDARD; + } + else if (args[0].equalsIgnoreCase("small")) { + hud = HUDType.SMALL; + } + else if (args[0].equalsIgnoreCase("retro")) { + hud = HUDType.RETRO; + } + else { + player.sendMessage(invalid); + return true; + } + + if (SpoutStuff.playerHUDs.containsKey(player)) { + SpoutStuff.playerHUDs.get(player).resetHUD(); + SpoutStuff.playerHUDs.remove(player); + PP.setHUDType(hud); + SpoutStuff.playerHUDs.put(player, new HUDmmo(player, plugin)); + } + + return true; + + default: + sender.sendMessage(usage); + return true; + } + } } diff --git a/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java b/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java index 05de9271f..ab4a3e3ba 100644 --- a/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/spout/XplockCommand.java @@ -9,54 +9,71 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.m; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.skills.Skills; import com.gmail.nossr50.spout.SpoutStuff; public class XplockCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!LoadProperties.spoutEnabled || !LoadProperties.xpbar || !LoadProperties.xplockEnable) { - sender.sendMessage("This command is not enabled."); //TODO: Needs more locale. - return true; - } + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + String usage = ChatColor.RED + "Proper usage is /xplock [skill]"; - if (!(sender instanceof Player)) { - sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale. - return true; - } + if (CommandHelper.noConsoleUsage(sender)) { + return true; + } - Player player = (Player) sender; - PlayerProfile PP = Users.getProfile(player); + if (!LoadProperties.spoutEnabled || !LoadProperties.xpbar || !LoadProperties.xplockEnable) { + sender.sendMessage(mcLocale.getString("Commands.Disabled")); + return true; + } - if (args.length >= 1 && Skills.isSkill(args[0]) && mcPermissions.getInstance().permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) { - if (PP.getXpBarLocked()) { - PP.setSkillLock(Skills.getSkillType(args[0])); - player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(PP.getSkillLock().toString()) })); - } else { - PP.setSkillLock(Skills.getSkillType(args[0])); - PP.toggleXpBarLocked(); - player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(PP.getSkillLock().toString()) })); - } - SpoutStuff.updateXpBar(player); - } else if (args.length < 1) { - if (PP.getXpBarLocked()) { - PP.toggleXpBarLocked(); - player.sendMessage(mcLocale.getString("Commands.xplock.unlocked")); - } else if (PP.getLastGained() != null) { - PP.toggleXpBarLocked(); - PP.setSkillLock(PP.getLastGained()); - player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(PP.getSkillLock().toString()) })); - } - } else if (args.length >= 1 && !Skills.isSkill(args[0])) { - player.sendMessage("Commands.xplock.invalid"); - } else if (args.length >= 2 && Skills.isSkill(args[0]) && !mcPermissions.getInstance().permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) { - player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); - return true; - } + Player player = (Player) sender; + PlayerProfile PP = Users.getProfile(player); - return true; - } + switch (args.length) { + case 0: + if (PP.getXpBarLocked()) { + PP.toggleXpBarLocked(); + player.sendMessage(mcLocale.getString("Commands.xplock.unlocked")); + return true; + } + + SkillType lastGained = PP.getLastGained(); + + if (lastGained != null) { + PP.toggleXpBarLocked(); + PP.setSkillLock(lastGained); + player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(lastGained.toString()) })); + return true; + } + + case 1: + if (Skills.isSkill(args[0])) { + if (mcPermissions.getInstance().permission(player, "mcmmo.skills." + args[0].toLowerCase())) { + PP.setXpBarLocked(true); + PP.setSkillLock(Skills.getSkillType(args[0])); + SpoutStuff.updateXpBar(player); + + player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(args[0]) })); + return true; + } + else { + player.sendMessage(mcLocale.getString("mcMMO.NoPermission")); + return true; + } + } + else { + player.sendMessage(mcLocale.getString("Commands.Skill.Invalid")); + return true; + } + + default: + player.sendMessage(usage); + 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 c20dfd7fa..89418d04c 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -555,6 +555,10 @@ public class PlayerProfile { save(); } + public void setXpBarLocked(boolean locked) { + xpbarlocked = locked; + } + public boolean getXpBarLocked() { return xpbarlocked; } diff --git a/src/main/resources/locale/locale_en_us.properties b/src/main/resources/locale/locale_en_us.properties index 320403741..24329ff4e 100644 --- a/src/main/resources/locale/locale_en_us.properties +++ b/src/main/resources/locale/locale_en_us.properties @@ -375,6 +375,7 @@ Commands.Ability.On=Ability use toggled [[GREEN]]on Commands.AdminChat.Off=Admin Chat only [[RED]]Off Commands.AdminChat.On=Admin Chat only [[GREEN]]On Commands.AdminToggle=[[RED]]- Toggle admin chat +Commands.Disabled=[[RED]]This command is disabled. Commands.DoesNotExist= [[RED]]Player does not exist in the database! Commands.GodMode.Disabled=[[YELLOW]]mcMMO Godmode Disabled Commands.GodMode.Enabled=[[YELLOW]]mcMMO Godmode Enabled @@ -382,9 +383,9 @@ Commands.GodMode.Forbidden=[mcMMO] God Mode not permitted on this world (See Per Commands.Inspect= [[RED]]- View detailed player info Commands.Invite.Accepted=[[GREEN]]Invite Accepted. You have joined party {0} Commands.Invite.Success=[[GREEN]]Invite sent successfully. -Commands.Leaderboards= [[RED]]- Leaderboards +Commands.Leaderboards= [[RED]]- Leaderboards Commands.mcgod=[[RED]]- Toggle GodMode -Commands.mmoedit=[playername] [[RED]] - Modify target +Commands.mmoedit=[player] [[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,20 +395,21 @@ 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]]/accept[[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.Kick=[[RED]]You were kicked from party {0}! Commands.Party.Leave=[[RED]]You have left that party Commands.Party.Members=[[GREEN]]Party Members: {0} 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.Party= [[RED]]- Create/Join designated party Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard-- Commands.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0} +Commands.Skill.Invalid=[[RED]]That is not a valid skillname! Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard-- -Commands.SkillInfo=/ [[RED]]- View detailed information about a skill +Commands.SkillInfo=/ [[RED]]- View detailed information about a skill Commands.Stats.Self=YOUR STATS Commands.Stats=[[RED]]- View your mcMMO stats Commands.ToggleAbility=[[RED]]- Toggle ability activation with right click @@ -419,26 +421,29 @@ mcMMO.Wiki=[[GREEN]]http://mcmmo.wikia.com[[BLUE]] - mcMMO Wiki ##party Commands.Party.InParty=[[GREEN]]Party: {0} -Party.CouldNotKick=[[DARK_RED]]Could not kick player {0} from the party -Party.CouldNotSetOwner=[[DARK_RED]]Could not set owner to {0} Party.Forbidden=[mcMMO] Parties not permitted on this world (See Permissions) -Party.Help.0=[[RED]]Proper usage is /party to join or /party q to quit -Party.Help.1=[[RED]]To join a passworded party, use /party +Party.Help.0=[[RED]]Proper usage is /party to join or /party q to quit +Party.Help.1=[[RED]]To join a passworded party, use /party Party.Help.2=[[RED]]Consult /party ? for more information -Party.Help.3=[[RED]]Use /party to join or /party q to quit +Party.Help.3=[[RED]]Use /party to join or /party q to quit Party.Help.4=[[RED]]To lock or unlock your party, use /party Party.Help.5=[[RED]]To password protect your party, use /party password Party.Help.6=[[RED]]To kick a player from your party, use /party kick Party.Help.7=[[RED]]To transfer ownership of your party, use /party owner Party.InformedOnJoin={0} [[GREEN]] has joined your party Party.InformedOnQuit={0} [[GREEN]] has left your party -Party.InvalidName=[[DARK_RED]]That is not a valid party name +Party.InvalidName=[[DARK_RED]]That is not a valid party name. Party.IsLocked=[[RED]]This party is already locked! Party.IsntLocked=[[RED]]This party is not locked! Party.Locked=[[RED]]Party is locked, only party leader may invite. Party.NotInYourParty=[[DARK_RED]]{0} is not in your party Party.NotOwner=[[DARK_RED]]You are not the party owner Party.PasswordSet=[[GREEN]]Party password set to {0} +Party.Player.Invalid=[[RED]]That is not a valid player. +Party.Teleport.Dead=[[RED]]You can't teleport to a dead player. +Party.Teleport.Hurt=[[RED]]You've been hurt in the last {0} seconds and cannnot teleport. +Party.Teleport.Player=[[GREEN]]You have teleported to {0}. +Party.Teleport.Target=[[GREEN]]{0} has teleported to you. Party.Unlocked=[[GRAY]]Party is unlocked ##xp @@ -455,7 +460,6 @@ Commands.XPGain.Taming=Animal Taming, or combat w/ your wolves Commands.XPGain.Unarmed=Attacking Monsters Commands.XPGain.WoodCutting=Chopping down trees Commands.XPGain=[[DARK_GRAY]]XP GAIN: [[WHITE]]{0} -Commands.xplock.invalid=[[RED]]That is not a valid skillname! Try /xplock mining Commands.xplock.locked=[[GOLD]]Your XP BAR is now locked to {0}! Commands.xplock.unlocked=[[GOLD]]Your XP BAR is now [[GREEN]]UNLOCKED[[GOLD]]! Commands.xprate.over=[[RED]]mcMMO XP Rate Event is OVER!!