diff --git a/Tourney/src/net/anxuiz/tourney/ClassificationManager.java b/Tourney/src/net/anxuiz/tourney/ClassificationManager.java index 1a64afd..33124e7 100644 --- a/Tourney/src/net/anxuiz/tourney/ClassificationManager.java +++ b/Tourney/src/net/anxuiz/tourney/ClassificationManager.java @@ -1,6 +1,7 @@ package net.anxuiz.tourney; import java.util.Set; +import java.util.logging.Logger; import javax.annotation.Nullable; import javax.inject.Inject; @@ -17,15 +18,24 @@ public class ClassificationManager { private final Set classifications; - @Inject ClassificationManager(Tournament tournament, MapLibrary mapLibrary) { - this.classifications = tournament.map_classifications() - .stream() - .map(cl -> new MapClassification(cl.name(), - cl.map_ids() - .stream() - .map(mapLibrary::getMapById) - .collect(Collectors.toImmutableSet()))) - .collect(Collectors.toImmutableSet()); + @Inject ClassificationManager(Tournament tournament, MapLibrary mapLibrary, Logger logger) { + this.classifications = + tournament.map_classifications().stream() + .map( + cl -> + new MapClassification( + cl.name(), + cl.map_ids().stream() + .map( + id -> { + PGMMap map = mapLibrary.getMapById(id); + if (map == null) { + logger.severe("Unable to find map matching ID: " + id); + return null; + } else return map; + }) + .collect(Collectors.toImmutableSet()))) + .collect(Collectors.toImmutableSet()); } public @Nullable MapClassification firstClassificationForMap(PGMMap map) { diff --git a/Tourney/src/net/anxuiz/tourney/Tourney.java b/Tourney/src/net/anxuiz/tourney/Tourney.java index 603ffee..59a54e9 100644 --- a/Tourney/src/net/anxuiz/tourney/Tourney.java +++ b/Tourney/src/net/anxuiz/tourney/Tourney.java @@ -1,5 +1,6 @@ package net.anxuiz.tourney; +import java.util.stream.Collectors; import javax.annotation.Nullable; import javax.inject.Inject; import javax.inject.Provider; @@ -18,8 +19,10 @@ import tc.oc.commons.bukkit.chat.ListComponent; import tc.oc.commons.bukkit.inject.BukkitPluginManifest; import tc.oc.commons.core.chat.Component; import tc.oc.commons.core.concurrent.Flexecutor; +import tc.oc.commons.core.formatting.StringUtils; import tc.oc.inject.ProtectedBinder; import tc.oc.minecraft.scheduler.Sync; +import tc.oc.pgm.map.PGMMap; import static com.google.common.base.Preconditions.checkNotNull; @@ -37,6 +40,7 @@ public class Tourney extends JavaPlugin { @Inject private Provider tournamentProvider; @Inject private Provider matchManagerProvider; @Inject private Provider kdmSessionProvider; + @Inject private Provider classificationManagerProvider; public static Tourney get() { return checkNotNull(inst); @@ -146,5 +150,17 @@ public class Tourney extends JavaPlugin { ChatColor.RED + "Please re-connect without BetterSprint enabled." )); } + + ClassificationManager classificationManager = classificationManagerProvider.get(); + if (!classificationManager.getClassifications().isEmpty()) { + getLogger().info("Map Classifications: "); + classificationManager + .getClassifications() + .forEach( + classification -> getLogger().info(classification.name() + " - " + + StringUtils.listToEnglishCompound(classification.maps().stream() + .map(map -> map.getId().toString()) + .collect(Collectors.toList())))); + } } }