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 22e2bdad0..76f5ae612 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 "; //TODO: Needs more locale. + String usage = ChatColor.RED + "Proper usage is /addlevels [playername] "; //TODO: Needs more locale. if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) { return true; @@ -54,10 +54,13 @@ public class AddlevelsCommand implements CommandExecutor{ PP.addLevels(skill, levels); sender.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale. - - return true; } } + else { + sender.sendMessage(usage); + } + + return true; case 3: modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]); @@ -90,9 +93,12 @@ public class AddlevelsCommand implements CommandExecutor{ if (modifiedPlayer.isOnline()) { ((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale. } - - return true; } + else { + sender.sendMessage(usage); + } + + return true; default: sender.sendMessage(usage); 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 83a1b5d57..f81bac05f 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java @@ -13,6 +13,7 @@ import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.skills.Skills; +//TODO: Any way we can make this work for offline use? public class AddxpCommand implements CommandExecutor { private final mcMMO plugin; @@ -26,7 +27,7 @@ public class AddxpCommand implements CommandExecutor { int xp; SkillType skill; String skillName; - String usage = ChatColor.RED + "Proper usage is /addxp "; //TODO: Needs more locale. + String usage = ChatColor.RED + "Proper usage is /addxp [player] "; //TODO: Needs more locale. if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) { return true; @@ -57,10 +58,13 @@ public class AddxpCommand implements CommandExecutor { else { Skills.XpCheckSkill(skill, modifiedPlayer); } - - return true; } } + else { + sender.sendMessage(usage); + } + + return true; case 3: modifiedPlayer = plugin.getServer().getPlayer(args[0]); @@ -91,9 +95,12 @@ public class AddxpCommand implements CommandExecutor { else { Skills.XpCheckSkill(skill, modifiedPlayer); } - - return true; } + else { + sender.sendMessage(usage); + } + + return true; default: sender.sendMessage(usage); 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 f4f6c1c61..a7c00033b 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 4375a1336..d8e00aada 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 "; //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; @@ -54,10 +54,13 @@ 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. - - return true; } } + else { + sender.sendMessage(usage); + } + + return true; case 3: modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]); @@ -90,9 +93,12 @@ public class MmoeditCommand implements CommandExecutor { if (modifiedPlayer.isOnline()) { ((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale. } - - return true; } + else { + sender.sendMessage(usage); + } + + return true; default: sender.sendMessage(usage); diff --git a/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java index d5a341522..f53f4b000 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java @@ -1,124 +1,88 @@ package com.gmail.nossr50.commands.general; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; 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.locale.mcLocale; public class XprateCommand implements CommandExecutor { - private static int oldrate = LoadProperties.xpGainMultiplier; - - public static boolean xpevent = false; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + private static int oldrate = LoadProperties.xpGainMultiplier; + public static boolean xpevent = false; - if (!(sender instanceof Player)) { - if(args.length <= 0) - { - System.out.println(mcLocale.getString("Commands.xprate.proper", new Object[] {"xprate"})); - System.out.println(mcLocale.getString("Commands.xprate.proper2", new Object[] {"xprate"})); - } - - if(args.length == 1 && args[0].equalsIgnoreCase("reset")) - { - if(xpevent) - { - for(Player x : Bukkit.getServer().getOnlinePlayers()) - x.sendMessage(mcLocale.getString("Commands.xprate.over")); - xpevent = !xpevent; - LoadProperties.xpGainMultiplier = oldrate; - } else - { - LoadProperties.xpGainMultiplier = oldrate; - } - } - - if(args.length >= 1 && m.isInt(args[0])) - { - oldrate = LoadProperties.xpGainMultiplier; - - if(args.length >= 2 && (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false"))) - { - if(args[1].equalsIgnoreCase("true")) - xpevent = true; - else - xpevent = false; - } else - { - System.out.println(mcLocale.getString("Commands.xprate.proper3")); - return true; - } - LoadProperties.xpGainMultiplier = m.getInt(args[0]); - if(xpevent = true) - for(Player x : Bukkit.getServer().getOnlinePlayers()) - { - x.sendMessage(ChatColor.GOLD+"XP EVENT FOR mcMMO HAS STARTED!"); //TODO: Needs more locale. - x.sendMessage(ChatColor.GOLD+"mcMMO XP RATE IS NOW "+LoadProperties.xpGainMultiplier+"x!!"); //TODO: Needs more locale. - } - - System.out.println("The XP RATE was modified to "+LoadProperties.xpGainMultiplier); //TODO: Needs more locale. - } - - return true; - } - - Player player = (Player) sender; - - if(!mcPermissions.getInstance().admin(player)) - { - player.sendMessage(ChatColor.YELLOW+"[mcMMO] "+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission")); - return true; - } - if(args.length <= 0) - { - player.sendMessage(mcLocale.getString("Commands.xprate.proper", new Object[] {"xprate"})); - player.sendMessage(mcLocale.getString("Commands.xprate.proper2", new Object[] {"xprate"})); - } - if(args.length == 1 && args[0].equalsIgnoreCase("reset")) - { - if(xpevent) - { - for(Player x : Bukkit.getServer().getOnlinePlayers()) - x.sendMessage(mcLocale.getString("Commands.xprate.over")); - xpevent = !xpevent; - LoadProperties.xpGainMultiplier = oldrate; - } else - { - LoadProperties.xpGainMultiplier = oldrate; - } - } - if(args.length >= 1 && m.isInt(args[0])) - { - oldrate = LoadProperties.xpGainMultiplier; - - if(args.length >= 2 && (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false"))) - { - if(args[1].equalsIgnoreCase("true")) - xpevent = true; - else - xpevent = false; - } else - { - player.sendMessage(mcLocale.getString("Commands.xprate.proper3")); - return true; - } - LoadProperties.xpGainMultiplier = m.getInt(args[0]); - if(xpevent = true) - for(Player x : Bukkit.getServer().getOnlinePlayers()) - { - x.sendMessage(mcLocale.getString("Commands.xprate.started")); - x.sendMessage(mcLocale.getString("Commands.xprate.started2", new Object[] {LoadProperties.xpGainMultiplier})); - } - } - - return true; - } + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + String usage1 = mcLocale.getString("Commands.xprate.proper"); + String usage2 = mcLocale.getString("Commands.xprate.proper2"); + String usage3 = mcLocale.getString("Commands.xprate.proper3"); + + if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) { + return true; + } + + switch (args.length) { + case 1: + if (args[0].equalsIgnoreCase("reset")) { + if (xpevent) { + for (Player x : Bukkit.getServer().getOnlinePlayers()) { + x.sendMessage(mcLocale.getString("Commands.xprate.over")); + } + + xpevent = !xpevent; + LoadProperties.xpGainMultiplier = oldrate; + } + else { + LoadProperties.xpGainMultiplier = oldrate; + } + } + else if (m.isInt(args[0])) { + sender.sendMessage(usage3); + } + else { + sender.sendMessage(usage2); + } + + return true; + + case 2: + if (m.isInt(args[0])) { + oldrate = LoadProperties.xpGainMultiplier; + + if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) { + xpevent = Boolean.valueOf(args[1]); + } + else { + sender.sendMessage(usage3); + } + + LoadProperties.xpGainMultiplier = m.getInt(args[0]); + + if (xpevent) { + for (Player x : Bukkit.getServer().getOnlinePlayers()) { + x.sendMessage(mcLocale.getString("Commands.xprate.started")); + x.sendMessage(mcLocale.getString("Commands.xprate.started2", new Object[] {LoadProperties.xpGainMultiplier})); + } + } + else { + sender.sendMessage("The XP RATE was modified to " + LoadProperties.xpGainMultiplier); //TODO: Locale + } + } + else { + sender.sendMessage(usage1); + sender.sendMessage(usage2); + } + + return true; + + default: + sender.sendMessage(usage1); + sender.sendMessage(usage2); + return true; + } + } } diff --git a/src/main/java/com/gmail/nossr50/mcPermissions.java b/src/main/java/com/gmail/nossr50/mcPermissions.java index 12f295936..61ea27a29 100644 --- a/src/main/java/com/gmail/nossr50/mcPermissions.java +++ b/src/main/java/com/gmail/nossr50/mcPermissions.java @@ -30,7 +30,7 @@ public class mcPermissions { } public boolean arcaneBypass(Player player) { - return player.hasPermission(("mcmmo.bypass.arcanebypass")); + return player.hasPermission("mcmmo.bypass.arcanebypass"); } /* diff --git a/src/main/resources/locale/locale_en_us.properties b/src/main/resources/locale/locale_en_us.properties index 05bfffc0f..245f8f265 100644 --- a/src/main/resources/locale/locale_en_us.properties +++ b/src/main/resources/locale/locale_en_us.properties @@ -321,12 +321,12 @@ Party.PasswordSet=[[GREEN]]Party password set to {0} Party.CouldNotKick=[[DARK_RED]]Could not kick player {0} Party.NotInYourParty=[[DARK_RED]]{0} is not in your party Party.CouldNotSetOwner=[[DARK_RED]]Could not set owner to {0} -Commands.xprate.proper=[[DARK_AQUA]]Proper usage is /{0} [integer] [true:false] -Commands.xprate.proper2=[[DARK_AQUA]]Also you can type /{0} reset to turn everything back to normal -Commands.xprate.proper3=[[RED]]Enter true or false for the second value +Commands.xprate.proper=[[RED]]Proper usage to change the XP rate is /xprate +Commands.xprate.proper2=[[RED]]Proper usage to reset the XP rate to default is /xprate reset +Commands.xprate.proper3=[[RED]]Please specify true or false to indicate if this is an xp event or not Commands.xprate.over=[[RED]]mcMMO XP Rate Event is OVER!! Commands.xprate.started=[[GOLD]]XP EVENT FOR mcMMO HAS STARTED! -Commands.xprate.started2=[[GOLD]]mcMMO XP RATE IS NOW {0}x!! +Commands.xprate.started2=[[GOLD]]mcMMO XP RATE IS NOW {0}x! 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.xplock.invalid=[[RED]]That is not a valid skillname! Try /xplock mining