Search in sources :

Example 6 with ResourcePack

use of au.com.mineauz.minigames.objects.ResourcePack in project Minigames by AddstarMC.

the class ResourcePackManager method loadEmptyPack.

private boolean loadEmptyPack() {
    try {
        URL u = new URL("https://github.com/AddstarMC/Minigames/raw/master/Minigames/src/main/resources/resourcepack/emptyResourcePack.zip");
        ResourcePack empty = new ResourcePack("empty", u);
        addResourcePack(empty);
        return true;
    } catch (MalformedURLException e) {
        return false;
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ResourcePack(au.com.mineauz.minigames.objects.ResourcePack) URL(java.net.URL)

Example 7 with ResourcePack

use of au.com.mineauz.minigames.objects.ResourcePack 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

ResourcePack (au.com.mineauz.minigames.objects.ResourcePack)7 MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)4 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 StartGlobalMinigameEvent (au.com.mineauz.minigames.events.StartGlobalMinigameEvent)1 StopGlobalMinigameEvent (au.com.mineauz.minigames.events.StopGlobalMinigameEvent)1 MinigameType (au.com.mineauz.minigames.gametypes.MinigameType)1 PotionEffect (org.bukkit.potion.PotionEffect)1