Skip to content

Commit

Permalink
Fix that usage is shown on correct execution of /tictactoe
Browse files Browse the repository at this point in the history
  • Loading branch information
lscgh committed Feb 9, 2024
1 parent 61c3b49 commit ec84466
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if(args.length < CommandTicTacToe.MIN_VALID_ARG_COUNT) {
return false;
}

boolean playerIsCurrentlyInAGame = Game.runningGames.containsKey((Player)sender);
boolean playerProvidedCancelKeyword = args[CommandTicTacToe.OPPONENT_ARG_INDEX].equals(CommandTicTacToe.CANCEL_KEYWORD);
if(playerIsCurrentlyInAGame && playerProvidedCancelKeyword) {
Game gameToCancel = Game.runningGames.get((Player)sender);
gameToCancel.end(GameEndCause.CANCEL);
return true;
}

if(args.length > CommandTicTacToe.MAX_VALID_ARG_COUNT) {
sender.sendMessage(ChatColor.RED + "Too many arguments for command '/" + label + "'!" + ChatColor.RESET);
Expand All @@ -77,6 +69,14 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if(CommandTicTacToe.isNoAvailablePlayersPlaceholder(args)) {
return true;
}

boolean playerIsCurrentlyInAGame = Game.runningGames.containsKey((Player)sender);
boolean playerProvidedCancelKeyword = args[CommandTicTacToe.OPPONENT_ARG_INDEX].equals(CommandTicTacToe.CANCEL_KEYWORD);
if(playerIsCurrentlyInAGame && playerProvidedCancelKeyword) {
Game gameToCancel = Game.runningGames.get((Player)sender);
gameToCancel.end(GameEndCause.CANCEL);
return true;
}

if(args[CommandTicTacToe.OPPONENT_ARG_INDEX].equals(CommandTicTacToe.REQUEST_RETURN_MATCH_KEYWORD)) {

Expand Down Expand Up @@ -130,7 +130,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

new Game(config, this.plugin, false);

return false;
return true;
}

private static boolean isNoAvailablePlayersPlaceholder(String[] args) {
Expand Down

0 comments on commit ec84466

Please sign in to comment.