Search in sources :

Example 11 with MinigamePlayer

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

Example 12 with MinigamePlayer

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

the class RegionDisplayManager method update.

public void update(Region region) {
    Set<MinigamePlayer> watchers = Sets.newHashSet(activeWatchers.get(region));
    ArmorStand stand = nameDisplay.remove(region);
    if (stand != null)
        stand.remove();
    for (MinigamePlayer player : watchers) {
        hide(region, player);
        show(region, player);
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) ArmorStand(org.bukkit.entity.ArmorStand)

Example 13 with MinigamePlayer

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

the class RegionDisplayManager method update.

public void update(Node node) {
    Set<MinigamePlayer> watchers = Sets.newHashSet(activeWatchers.get(node));
    ArmorStand stand = nameDisplay.remove(node);
    if (stand != null)
        stand.remove();
    for (MinigamePlayer player : watchers) {
        hide(node, player);
        show(node, player);
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) ArmorStand(org.bukkit.entity.ArmorStand)

Example 14 with MinigamePlayer

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

the class RegionDisplayManager method hideAll.

public void hideAll(Player player) {
    MinigamePlayer mplayer = Minigames.getPlugin().getPlayerManager().getMinigamePlayer(player);
    Map<Region, IDisplayObject> regions = regionDisplays.remove(player);
    if (regions != null) {
        for (IDisplayObject display : regions.values()) {
            display.remove();
        }
        for (Region region : regions.keySet()) {
            hideInfo(region, mplayer);
        }
    }
    Map<Node, IDisplayObject> nodes = nodeDisplays.remove(player);
    if (nodes != null) {
        for (IDisplayObject display : nodes.values()) {
            display.remove();
        }
        for (Node node : nodes.keySet()) {
            hideInfo(node, mplayer);
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) IDisplayObject(au.com.mineauz.minigames.display.IDisplayObject)

Example 15 with MinigamePlayer

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

the class AbstractAction method setWinnersLosers.

/**
 * Set winners losers.
 *
 * @param winner the winner
 */
void setWinnersLosers(final MinigamePlayer winner) {
    if (winner.getMinigame().getType() != MinigameType.SINGLEPLAYER) {
        final List<MinigamePlayer> w;
        final List<MinigamePlayer> l;
        if (winner.getMinigame().isTeamGame()) {
            w = new ArrayList<>(winner.getTeam().getPlayers());
            l = new ArrayList<>(winner.getMinigame().getPlayers().size() - winner.getTeam().getPlayers().size());
            for (final Team t : TeamsModule.getMinigameModule(winner.getMinigame()).getTeams()) {
                if (t != winner.getTeam()) {
                    l.addAll(t.getPlayers());
                }
            }
        } else {
            w = new ArrayList<>(1);
            l = new ArrayList<>(winner.getMinigame().getPlayers().size());
            w.add(winner);
            l.addAll(winner.getMinigame().getPlayers());
            l.remove(winner);
        }
        Minigames.getPlugin().getPlayerManager().endMinigame(winner.getMinigame(), w, l);
    } else {
        Minigames.getPlugin().getPlayerManager().endMinigame(winner);
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) Team(au.com.mineauz.minigames.minigame.Team)

Aggregations

MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)134 EventHandler (org.bukkit.event.EventHandler)46 Minigame (au.com.mineauz.minigames.minigame.Minigame)40 ArrayList (java.util.ArrayList)25 Team (au.com.mineauz.minigames.minigame.Team)24 OfflineMinigamePlayer (au.com.mineauz.minigames.objects.OfflineMinigamePlayer)15 Player (org.bukkit.entity.Player)15 Location (org.bukkit.Location)11 ItemStack (org.bukkit.inventory.ItemStack)8 MinigameTool (au.com.mineauz.minigames.tool.MinigameTool)7 Menu (au.com.mineauz.minigames.menu.Menu)5 TeamColor (au.com.mineauz.minigames.minigame.TeamColor)5 List (java.util.List)5 PotionEffect (org.bukkit.potion.PotionEffect)5 ResourcePack (au.com.mineauz.minigames.objects.ResourcePack)4 Material (org.bukkit.Material)4 Sign (org.bukkit.block.Sign)4 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)3 MenuItem (au.com.mineauz.minigames.menu.MenuItem)2 MenuItemBoolean (au.com.mineauz.minigames.menu.MenuItemBoolean)2