mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-26 02:28:03 +01:00
Fixed some possible errors if bad command arguments were used.
This commit is contained in:
parent
2b7f21fee4
commit
74ee210514
@ -30,7 +30,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
int levels;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
String usage = ChatColor.RED + "Proper usage is /addlevels <playername> <skillname> <levels>"; //TODO: Needs more locale.
|
||||
String usage = ChatColor.RED + "Proper usage is /addlevels [playername] <skill> <level>"; //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);
|
||||
|
@ -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 <playername> <skillname> <xp>"; //TODO: Needs more locale.
|
||||
String usage = ChatColor.RED + "Proper usage is /addxp [player] <skill> <xp>"; //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);
|
||||
|
@ -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 <playername>"; //TODO: Needs more locale.
|
||||
String usage = "Proper usage is /inspect <player>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
|
||||
return true;
|
||||
|
@ -30,7 +30,7 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
int newValue;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
String usage = ChatColor.RED + "Proper usage is /mmoedit <playername> <skillname> <newvalue>"; //TODO: Needs more locale.
|
||||
String usage = ChatColor.RED + "Proper usage is /mmoedit [player] <skill> <newvalue>"; //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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class mcPermissions {
|
||||
}
|
||||
|
||||
public boolean arcaneBypass(Player player) {
|
||||
return player.hasPermission(("mcmmo.bypass.arcanebypass"));
|
||||
return player.hasPermission("mcmmo.bypass.arcanebypass");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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 <integer> <true/false>
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user