Search in sources :

Example 1 with ResourcePackModule

use of au.com.mineauz.minigames.minigame.modules.ResourcePackModule in project Minigames by AddstarMC.

the class Events method onPlayerResourcePack.

@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerResourcePack(PlayerResourcePackStatusEvent event) {
    final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    List<MinigamePlayer> required = plugin.getPlayerManager().getApplyingPack();
    if (ply.isInMinigame()) {
        if (required.contains(ply)) {
            ResourcePackModule module = ResourcePackModule.getMinigameModule(ply.getMinigame());
            if (!module.isEnabled())
                return;
            if (!module.isForced())
                return;
            switch(event.getStatus()) {
                case ACCEPTED:
                    required.remove(ply);
                    return;
                case DECLINED:
                    Minigames.getPlugin().getPlayerManager().quitMinigame(ply, true);
                    MessageManager.sendMessage(ply, MinigameMessageType.ERROR, null, "minigames.resource.declined");
                    required.remove(ply);
                    return;
                case FAILED_DOWNLOAD:
                    Minigames.getPlugin().getPlayerManager().quitMinigame(ply, true);
                    MessageManager.sendMessage(ply, MinigameMessageType.ERROR, null, "minigames.resource.failed");
                    required.remove(ply);
                    return;
                case SUCCESSFULLY_LOADED:
                    required.remove(ply);
            }
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) OfflineMinigamePlayer(au.com.mineauz.minigames.objects.OfflineMinigamePlayer) ResourcePackModule(au.com.mineauz.minigames.minigame.modules.ResourcePackModule) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ResourcePackModule (au.com.mineauz.minigames.minigame.modules.ResourcePackModule)1 MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)1 OfflineMinigamePlayer (au.com.mineauz.minigames.objects.OfflineMinigamePlayer)1 EventHandler (org.bukkit.event.EventHandler)1