Minor command fixes

This commit is contained in:
Sauilitired 2015-07-27 21:24:04 +02:00
parent aa735f8073
commit 5a6847a039

View File

@ -37,6 +37,7 @@ import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandHandlingOutput; import com.plotsquared.general.commands.CommandHandlingOutput;
import com.plotsquared.general.commands.CommandManager; import com.plotsquared.general.commands.CommandManager;
import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
@ -209,7 +210,9 @@ public class MainCommand extends CommandManager<PlotPlayer> {
try { try {
help_index = Integer.parseInt(args[2]); help_index = Integer.parseInt(args[2]);
} }
catch (NumberFormatException e) {} catch (NumberFormatException e) {
help_index = 1;
}
} }
break; break;
} }
@ -218,10 +221,11 @@ public class MainCommand extends CommandManager<PlotPlayer> {
category = null; category = null;
try { try {
help_index = Integer.parseInt(args[1]); help_index = Integer.parseInt(args[1]);
} catch(NumberFormatException e) {
help_index = 1;
} }
catch (NumberFormatException e) {} } else {
} help_index = 1;
if (category == null) {
category = args[1]; category = args[1];
} }
break; break;
@ -294,12 +298,12 @@ public class MainCommand extends CommandManager<PlotPlayer> {
MainUtil.sendMessage(plr, C.NOT_VALID_SUBCOMMAND); MainUtil.sendMessage(plr, C.NOT_VALID_SUBCOMMAND);
{ {
ArrayList<Command<PlotPlayer>> cmds = getCommands(); ArrayList<Command<PlotPlayer>> cmds = getCommands();
cmd = new StringComparison<Command<PlotPlayer>>(label, cmds).getMatchObject(); cmd = new StringComparison<>(label, cmds).getMatchObject();
if (cmd == null) { if (cmd == null) {
MainUtil.sendMessage(plr, C.DID_YOU_MEAN, "/plot help"); MainUtil.sendMessage(plr, C.DID_YOU_MEAN, "/plot help");
} }
else { else {
MainUtil.sendMessage(plr, C.DID_YOU_MEAN, cmd.getUsage().replaceAll("{label}", label)); MainUtil.sendMessage(plr, C.DID_YOU_MEAN, cmd.getUsage().replaceAll("\\{label\\}", label));
} }
} }
return CommandHandlingOutput.NOT_FOUND; return CommandHandlingOutput.NOT_FOUND;