use of au.com.mineauz.minigames.managers.MinigamePlayerManager in project Minigames by AddstarMC.
the class Minigames method setupMinigames.
private void setupMinigames() {
this.minigameManager = new MinigameManager();
this.playerManager = new MinigamePlayerManager();
this.display = new DisplayManager();
this.resourceManager = new ResourcePackManager();
final MinigameSave resources = new MinigameSave("resources");
this.minigameManager.addConfigurationFile("resources", resources.getConfig());
this.resourceManager.initialize(resources);
this.minigameManager.addMinigameType(new SingleplayerType());
this.minigameManager.addMinigameType(new MultiplayerType());
final MinigameSave completion = new MinigameSave("completion");
this.minigameManager.addConfigurationFile("completion", completion.getConfig());
this.getServer().getPluginManager().registerEvents(new Events(), this);
this.getServer().getPluginManager().registerEvents(new BasicRecorder(), this);
try {
this.getConfig().load(this.getDataFolder() + "/config.yml");
List<String> mgs = new ArrayList<>();
if (this.getConfig().contains("minigames")) {
mgs = this.getConfig().getStringList("minigames");
}
this.debug = this.getConfig().getBoolean("debug", false);
final List<String> allMGS = new ArrayList<>(mgs);
if (!mgs.isEmpty()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
for (final String minigame : allMGS) {
final Minigame game = new Minigame(minigame);
try {
game.loadMinigame();
this.minigameManager.addMinigame(game);
} catch (final Exception e) {
this.getLogger().severe(ChatColor.RED + "Failed to load \"" + minigame + "\"! The configuration file may be corrupt or missing!");
e.printStackTrace();
}
}
}, 1L);
}
} catch (final FileNotFoundException ex) {
log().info("Failed to load config, creating one.");
try {
this.getConfig().save(this.getDataFolder() + "/config.yml");
} catch (final IOException e) {
log().log(Level.SEVERE, "Could not save config.yml!");
e.printStackTrace();
}
} catch (final Exception e) {
log().log(Level.SEVERE, "Failed to load config!");
e.printStackTrace();
}
}
Aggregations