Return false on incorrect args in Command_rollback. Fixes #296

This commit is contained in:
unknown 2014-08-25 18:47:29 +02:00
parent eaa23985bd
commit af97481d11

View File

@ -14,6 +14,11 @@ public class Command_rollback extends TFM_Command
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
if (args.length == 0 || args.length > 2)
{
return false;
}
if (args.length == 1) if (args.length == 1)
{ {
if ("purgeall".equalsIgnoreCase(args[0])) if ("purgeall".equalsIgnoreCase(args[0]))
@ -40,8 +45,10 @@ public class Command_rollback extends TFM_Command
playerMsg("Rolled back " + TFM_RollbackManager.rollback(playerName) + " edits for " + playerName + "."); playerMsg("Rolled back " + TFM_RollbackManager.rollback(playerName) + " edits for " + playerName + ".");
playerMsg("If this rollback was a mistake, use /rollback undo " + playerName + " within 40 seconds to reverse the rollback."); playerMsg("If this rollback was a mistake, use /rollback undo " + playerName + " within 40 seconds to reverse the rollback.");
} }
return true;
} }
else if (args.length == 2)
if (args.length == 2)
{ {
if ("purge".equalsIgnoreCase(args[0])) if ("purge".equalsIgnoreCase(args[0]))
{ {
@ -54,8 +61,10 @@ public class Command_rollback extends TFM_Command
} }
playerMsg("Purged " + TFM_RollbackManager.purgeEntries(playerName) + " rollback history entries for " + playerName + "."); playerMsg("Purged " + TFM_RollbackManager.purgeEntries(playerName) + " rollback history entries for " + playerName + ".");
return true;
} }
else if ("undo".equalsIgnoreCase(args[0]))
if ("undo".equalsIgnoreCase(args[0]))
{ {
String playerName = getPlayerName(args[1]); String playerName = getPlayerName(args[1]);
@ -67,18 +76,11 @@ public class Command_rollback extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Reverting rollback for player: " + playerName, false); TFM_Util.adminAction(sender.getName(), "Reverting rollback for player: " + playerName, false);
playerMsg("Reverted " + TFM_RollbackManager.undoRollback(playerName) + " edits for " + playerName + "."); playerMsg("Reverted " + TFM_RollbackManager.undoRollback(playerName) + " edits for " + playerName + ".");
return true;
} }
else
{
return false;
}
}
else
{
return false;
} }
return true; return false;
} }
private String getPlayerName(String playerNameInput) private String getPlayerName(String playerNameInput)