|
@@ -47,6 +47,7 @@ import java.util.stream.Collectors;
|
|
|
import org.bukkit.Material;
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
import org.bukkit.entity.Player;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
@CommandAlias("mw|missilewars")
|
|
|
@Subcommand("stats")
|
|
@@ -58,6 +59,28 @@ public class StatsCommands extends BaseCommand {
|
|
|
private final SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
|
|
|
private final SimpleDateFormat preciseFormat = new SimpleDateFormat("hh:mm dd.MM.yyyy");
|
|
|
|
|
|
+ @NotNull
|
|
|
+ private static List<String> generateRecommendations(StatsFetcher fetcher, SavedStats avgStatsWithoutDraws) {
|
|
|
+ List<String> recommendations = new ArrayList<>();
|
|
|
+ int gameCount = fetcher.getGameCount();
|
|
|
+
|
|
|
+ double avgWins = avgStatsWithoutDraws.getTeamWon();
|
|
|
+ if (Math.abs(avgWins - 1) > MAX_AVIATION_WIN) {
|
|
|
+ recommendations.add("It could be, that your map is biased to one team, as wins are not equally distributed");
|
|
|
+ }
|
|
|
+
|
|
|
+ int draws = fetcher.getDrawFights();
|
|
|
+ if ((((double) draws / (double) gameCount) * 100) > MAX_FIGHT_DRAW_PERCENTAGE) {
|
|
|
+ recommendations.add("Increase the game_length option. More than 15% of your games are draws");
|
|
|
+ }
|
|
|
+
|
|
|
+ Duration duration = Duration.ofMillis(avgStatsWithoutDraws.getTimeElapsed());
|
|
|
+ if (((double) duration.getSeconds() / 60.0) <= MIN_FIGHT_DURATION) {
|
|
|
+ recommendations.add("Remove some overpowered features. The average game length at won games is under 5 minutes");
|
|
|
+ }
|
|
|
+ return recommendations;
|
|
|
+ }
|
|
|
+
|
|
|
@Default
|
|
|
@CommandPermission("mw.stats")
|
|
|
public void onStats(CommandSender sender, String[] args) {
|
|
@@ -72,7 +95,7 @@ public class StatsCommands extends BaseCommand {
|
|
|
PreFetcher.PrePlayerFetchRunnable preFetchRunnable = PreFetcher.preFetchPlayers(fetcher);
|
|
|
|
|
|
CustomInv inv = new CustomInv("§eMissileWars statistics", 3);
|
|
|
- List<String> criteriaLore = Arrays.asList("§7Statistics since: §e" + format.format(fetcher.getFrom()), "§7Specified arena: §e" + (arena.equals("") ? "any" : arena));
|
|
|
+ List<String> criteriaLore = Arrays.asList("§7Statistics since: §e" + format.format(fetcher.getFrom()), "§7Specified arena: §e" + (arena.isEmpty() ? "any" : arena));
|
|
|
inv.addItem(4, new OrcItem(Material.FEATHER, "§aStatistics search criteria", criteriaLore));
|
|
|
|
|
|
int gameCount = fetcher.getGameCount();
|
|
@@ -121,23 +144,7 @@ public class StatsCommands extends BaseCommand {
|
|
|
if (fetcher == null) return;
|
|
|
SavedStats avgStatsWithDraws = fetcher.getAverageSavedStats(false);
|
|
|
SavedStats avgStatsWithoutDraws = fetcher.getAverageSavedStats(true);
|
|
|
- List<String> recommendations = new ArrayList<>();
|
|
|
- int gameCount = fetcher.getGameCount();
|
|
|
-
|
|
|
- double avgWins = avgStatsWithoutDraws.getTeamWon();
|
|
|
- if (Math.abs(avgWins - 1) > MAX_AVIATION_WIN) {
|
|
|
- recommendations.add("It could be, that your map is biased to one team, as wins are not equally distributed");
|
|
|
- }
|
|
|
-
|
|
|
- int draws = fetcher.getDrawFights();
|
|
|
- if ((((double) draws / (double) gameCount) * 100) > MAX_FIGHT_DRAW_PERCENTAGE) {
|
|
|
- recommendations.add("Increase the game_length option. More than 15% of your games are draws");
|
|
|
- }
|
|
|
-
|
|
|
- Duration duration = Duration.ofMillis(avgStatsWithoutDraws.getTimeElapsed());
|
|
|
- if (((double) duration.getSeconds() / 60.0) <= MIN_FIGHT_DURATION) {
|
|
|
- recommendations.add("Remove some overpowered features. The average game length at won games is under 5 minutes");
|
|
|
- }
|
|
|
+ List<String> recommendations = generateRecommendations(fetcher, avgStatsWithoutDraws);
|
|
|
// TODO implement more features
|
|
|
|
|
|
if (recommendations.isEmpty()) {
|