diff --git a/src/main/java/de/fanta/challengesjoinentities/commands/ChallengesCommand/ChallengesStatsCommand.java b/src/main/java/de/fanta/challengesjoinentities/commands/ChallengesCommand/ChallengesStatsCommand.java index ce702d9..de2d9a0 100644 --- a/src/main/java/de/fanta/challengesjoinentities/commands/ChallengesCommand/ChallengesStatsCommand.java +++ b/src/main/java/de/fanta/challengesjoinentities/commands/ChallengesCommand/ChallengesStatsCommand.java @@ -24,18 +24,27 @@ @Override public boolean onCommand(CommandSender sender, Command command, String alias, String commandString, ArgsParser args) { - Statistics.StatType statType = Statistics.StatType.valueOf(args.getNext("SOLO").toUpperCase()); + String statTypeString = args.getNext("SOLO").toUpperCase(); + Statistics.StatType statType; + + try { + statType = Statistics.StatType.valueOf(statTypeString); + } catch (IllegalArgumentException ex) { + statType = Statistics.StatType.SOLO; + } + String playerName = args.getNext(null); + Statistics.StatType finalStatType = statType; Consumer callback = data -> { if (data == null) { ChatUtil.sendErrorMessage(sender, "Für Spieler '" + playerName + "' existieren keine Daten."); return; } if (playerName == null) { - ChatUtil.sendNormalMessage(sender, "Deine Speedrun-Statistik " + "(" + statType.getPrefix() + ")"); + ChatUtil.sendNormalMessage(sender, "Deine Speedrun-Statistik " + "(" + finalStatType.getPrefix() + ")"); } else { - ChatUtil.sendNormalMessage(sender, "Speedrun-Statistik von " + data.getPlayerName() + " (" + statType.getPrefix() + ")"); + ChatUtil.sendNormalMessage(sender, "Speedrun-Statistik von " + data.getPlayerName() + " (" + finalStatType.getPrefix() + ")"); } @@ -43,28 +52,28 @@ if (bestTimeThisMonth < 0) { ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Beste Zeit: " + ChatUtil.GREEN + formatTime(data.getBestTime())); } else { - ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Beste Zeit: " + ChatUtil.GREEN + (data.getBestTime() < 0 ? "-" : formatTime(data.getBestTime())) + " (Dieser Monat: " + formatTime(bestTimeThisMonth) + ")"); + ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Beste Zeit: " + ChatUtil.GREEN + (data.getBestTime() == 0 ? "--:--" : formatTime(data.getBestTime())) + " (Dieser Monat: " + (bestTimeThisMonth == 0 ? "--:--" : formatTime(bestTimeThisMonth)) + ")"); } int runsPlayerThisMonth = data.getRunsPlayedMonth(); if (bestTimeThisMonth < 0) { ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Speedruns gespielt: " + ChatUtil.GREEN + data.getRunsPlayed()); } else { - ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Speedruns gespielt: " + ChatUtil.GREEN + (data.getRunsPlayed() < 0 ? "-" : data.getRunsPlayed()) + " (Dieser Monat: " + runsPlayerThisMonth + ")"); + ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Speedruns gespielt: " + ChatUtil.GREEN + data.getRunsPlayed() + " (Dieser Monat: " + runsPlayerThisMonth + ")"); } int runsWonThisMonth = data.getRunsWonMonth(); if (bestTimeThisMonth < 0) { ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Speedruns gewonnen: " + ChatUtil.GREEN + data.getRunsWon()); } else { - ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Speedruns gewonnen: " + ChatUtil.GREEN + (data.getRunsWon() < 0 ? "-" : data.getRunsWon()) + " (Dieser Monat: " + runsWonThisMonth + ")"); + ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Speedruns gewonnen: " + ChatUtil.GREEN + data.getRunsWon() + " (Dieser Monat: " + runsWonThisMonth + ")"); } int positionThisMonth = data.getPositionMonth(); if (bestTimeThisMonth < 0) { ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Position: " + ChatUtil.GREEN + data.getPosition()); } else { - ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Position: " + ChatUtil.GREEN + (data.getPosition() < 0 ? "-" : data.getPosition()) + " (Dieser Monat: " + positionThisMonth + ")"); + ChatUtil.sendNormalMessage(sender, ChatUtil.ORANGE + " Position: " + ChatUtil.GREEN + data.getPosition() + " (Dieser Monat: " + positionThisMonth + ")"); } }; if (playerName == null) {