Search in sources :

Example 1 with StartGlobalMinigameEvent

use of au.com.mineauz.minigames.events.StartGlobalMinigameEvent in project Minigames by AddstarMC.

the class MinigameData method startGlobalMinigame.

public void startGlobalMinigame(Minigame minigame, MinigamePlayer caller) {
    boolean canStart = minigame.getMechanic().checkCanStart(minigame, caller);
    if (minigame.getType() == MinigameType.GLOBAL && minigame.getMechanic().validTypes().contains(MinigameType.GLOBAL) && canStart) {
        StartGlobalMinigameEvent ev = new StartGlobalMinigameEvent(minigame, caller);
        Bukkit.getPluginManager().callEvent(ev);
        minigame.getMechanic().startMinigame(minigame, caller);
        minigame.setEnabled(true);
        minigame.saveMinigame();
    } else if (!minigame.getMechanic().validTypes().contains(MinigameType.GLOBAL)) {
        if (caller == null)
            Bukkit.getLogger().info(MinigameUtils.getLang("minigame.error.invalidMechanic"));
        else
            caller.sendMessage(MinigameUtils.getLang("minigame.error.invalidMechanic"), "error");
    } else if (!canStart) {
        if (caller == null)
            Bukkit.getLogger().info(MinigameUtils.getLang("minigame.error.mechanicStartFail"));
        else
            caller.sendMessage(MinigameUtils.getLang("minigame.error.mechanicStartFail"), "error");
    }
}
Also used : StartGlobalMinigameEvent(au.com.mineauz.minigames.events.StartGlobalMinigameEvent)

Example 2 with StartGlobalMinigameEvent

use of au.com.mineauz.minigames.events.StartGlobalMinigameEvent in project Minigames by AddstarMC.

the class MinigameManager method startGlobalMinigame.

public void startGlobalMinigame(final Minigame minigame, final MinigamePlayer caller) {
    final boolean canStart = minigame.getMechanic().checkCanStart(minigame, caller);
    if (minigame.getType() == MinigameType.GLOBAL && minigame.getMechanic().validTypes().contains(MinigameType.GLOBAL) && canStart) {
        final StartGlobalMinigameEvent ev = new StartGlobalMinigameEvent(minigame, caller);
        Bukkit.getPluginManager().callEvent(ev);
        minigame.getMechanic().startMinigame(minigame, caller);
        final ResourcePackModule module = (ResourcePackModule) minigame.getModule("ResourcePack");
        if (module != null) {
            if (module.isEnabled()) {
                final String name = module.getResourcePackName();
                final ResourcePack pack = PLUGIN.getResourceManager().getResourcePack(name);
                if (pack.isValid()) {
                    for (final MinigamePlayer player : minigame.getPlayers()) {
                        player.applyResourcePack(pack);
                    }
                }
            }
        }
        minigame.setEnabled(true);
        minigame.saveMinigame();
    } else if (!minigame.getMechanic().validTypes().contains(MinigameType.GLOBAL)) {
        if (caller == null) {
            Bukkit.getLogger().info(MinigameUtils.getLang("minigame.error.invalidMechanic"));
        } else {
            caller.sendMessage(MinigameUtils.getLang("minigame.error.invalidMechanic"), MinigameMessageType.ERROR);
        }
    } else if (!canStart) {
        if (caller == null) {
            Bukkit.getLogger().info(MinigameUtils.getLang("minigame.error.mechanicStartFail"));
        } else {
            caller.sendMessage(MinigameUtils.getLang("minigame.error.mechanicStartFail"), MinigameMessageType.ERROR);
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) ResourcePack(au.com.mineauz.minigames.objects.ResourcePack) StartGlobalMinigameEvent(au.com.mineauz.minigames.events.StartGlobalMinigameEvent)

Aggregations

StartGlobalMinigameEvent (au.com.mineauz.minigames.events.StartGlobalMinigameEvent)2 MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)1 ResourcePack (au.com.mineauz.minigames.objects.ResourcePack)1