Search in sources :

Example 1 with ResourcePackManager

use of au.com.mineauz.minigames.managers.ResourcePackManager 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();
    }
}
Also used : MinigamePlayerManager(au.com.mineauz.minigames.managers.MinigamePlayerManager) SingleplayerType(au.com.mineauz.minigames.gametypes.SingleplayerType) BasicRecorder(au.com.mineauz.minigames.blockRecorder.BasicRecorder) MinigameSave(au.com.mineauz.minigames.config.MinigameSave) MultiplayerType(au.com.mineauz.minigames.gametypes.MultiplayerType) MinigameManager(au.com.mineauz.minigames.managers.MinigameManager) DisplayManager(au.com.mineauz.minigames.display.DisplayManager) ResourcePackManager(au.com.mineauz.minigames.managers.ResourcePackManager) Minigame(au.com.mineauz.minigames.minigame.Minigame)

Aggregations

BasicRecorder (au.com.mineauz.minigames.blockRecorder.BasicRecorder)1 MinigameSave (au.com.mineauz.minigames.config.MinigameSave)1 DisplayManager (au.com.mineauz.minigames.display.DisplayManager)1 MultiplayerType (au.com.mineauz.minigames.gametypes.MultiplayerType)1 SingleplayerType (au.com.mineauz.minigames.gametypes.SingleplayerType)1 MinigameManager (au.com.mineauz.minigames.managers.MinigameManager)1 MinigamePlayerManager (au.com.mineauz.minigames.managers.MinigamePlayerManager)1 ResourcePackManager (au.com.mineauz.minigames.managers.ResourcePackManager)1 Minigame (au.com.mineauz.minigames.minigame.Minigame)1