Search in sources :

Example 66 with MinigamePlayer

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

the class MultiplayerType method endMinigame.

@Override
public void endMinigame(List<MinigamePlayer> winners, List<MinigamePlayer> losers, Minigame mgm) {
    if (mgm.isTeamGame()) {
        for (MinigamePlayer player : winners) {
            player.removeTeam();
        }
        for (MinigamePlayer player : losers) {
            player.removeTeam();
        }
        for (Team t : TeamsModule.getMinigameModule(mgm).getTeams()) {
            t.resetScore();
        }
    }
    if (mgm.getMpTimer() == null)
        return;
    mgm.getMpTimer().setStartWaitTime(0);
    mgm.setMpTimer(null);
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) Team(au.com.mineauz.minigames.minigame.Team)

Example 67 with MinigamePlayer

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

the class MultiplayerType method playerRespawn.

/*----------------*/
/*-----EVENTS-----*/
/*----------------*/
@EventHandler(priority = EventPriority.HIGHEST)
public void playerRespawn(PlayerRespawnEvent event) {
    final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply.isInMinigame() && ply.getMinigame().getType() == MinigameType.MULTIPLAYER) {
        Minigame mg = ply.getMinigame();
        Location respawnPos;
        if (ply.getMinigame().isTeamGame()) {
            Team team = ply.getTeam();
            if (mg.hasStarted() && !ply.isLatejoining()) {
                if (mg.isAllowedMPCheckpoints() && ply.hasCheckpoint()) {
                    respawnPos = ply.getCheckpoint();
                } else {
                    List<Location> starts = new ArrayList<>();
                    if (TeamsModule.getMinigameModule(mg).hasTeamStartLocations()) {
                        starts.addAll(team.getStartLocations());
                        ply.getLoadout().equiptLoadout(ply);
                    } else {
                        starts.addAll(mg.getStartLocations());
                    }
                    Collections.shuffle(starts);
                    respawnPos = starts.get(0);
                }
                ply.getLoadout().equiptLoadout(ply);
            } else {
                respawnPos = mg.getLobbyPosition();
            }
        } else {
            if (mg.hasStarted() && !ply.isLatejoining()) {
                if (mg.isAllowedMPCheckpoints() && ply.hasCheckpoint()) {
                    respawnPos = ply.getCheckpoint();
                } else {
                    List<Location> starts = new ArrayList<>(mg.getStartLocations());
                    Collections.shuffle(starts);
                    respawnPos = starts.get(0);
                }
                ply.getLoadout().equiptLoadout(ply);
            } else {
                respawnPos = mg.getLobbyPosition();
            }
        }
        event.setRespawnLocation(respawnPos);
        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> ply.getPlayer().setNoDamageTicks(60));
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) ArrayList(java.util.ArrayList) Team(au.com.mineauz.minigames.minigame.Team) Minigame(au.com.mineauz.minigames.minigame.Minigame) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 68 with MinigamePlayer

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

the class MinigameManager method stopGlobalMinigame.

public void stopGlobalMinigame(final Minigame minigame, final MinigamePlayer caller) {
    if (minigame.getType() == MinigameType.GLOBAL) {
        final StopGlobalMinigameEvent ev = new StopGlobalMinigameEvent(minigame, caller);
        Bukkit.getPluginManager().callEvent(ev);
        minigame.getMechanic().stopMinigame(minigame, caller);
        minigame.setEnabled(false);
        final ResourcePackModule module = (ResourcePackModule) minigame.getModule("ResourcePack");
        if (module != null) {
            if (module.isEnabled()) {
                final ResourcePack pack = PLUGIN.getResourceManager().getResourcePack("empty");
                if (pack.isValid()) {
                    for (final MinigamePlayer player : minigame.getPlayers()) {
                        player.applyResourcePack(pack);
                    }
                }
            }
        }
        minigame.saveMinigame();
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) ResourcePack(au.com.mineauz.minigames.objects.ResourcePack) StopGlobalMinigameEvent(au.com.mineauz.minigames.events.StopGlobalMinigameEvent)

Example 69 with MinigamePlayer

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

the class MenuItemToolMode method onClick.

public ItemStack onClick() {
    MinigamePlayer ply = getContainer().getViewer();
    if (MinigameUtils.hasMinigameTool(ply)) {
        MinigameTool tool = MinigameUtils.getMinigameTool(ply);
        if (tool.getMode() != null)
            tool.getMode().onUnsetMode(ply, tool);
        tool.setMode(mode);
        tool.getMode().onSetMode(ply, tool);
    }
    return getItem();
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) MinigameTool(au.com.mineauz.minigames.tool.MinigameTool)

Example 70 with MinigamePlayer

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

the class MenuItemInteger method onDoubleClick.

@Override
public ItemStack onDoubleClick() {
    MinigamePlayer ply = getContainer().getViewer();
    ply.setNoClose(true);
    ply.getPlayer().closeInventory();
    ply.sendMessage("Enter number value into chat for " + getName() + ", the menu will automatically reopen in 10s if nothing is entered.", MinigameMessageType.INFO);
    String min = "N/A";
    String max = "N/A";
    if (this.min != null) {
        min = this.min.toString();
    }
    if (this.max != null) {
        max = this.max.toString();
    }
    ply.setManualEntry(this);
    ply.sendInfoMessage("Min: " + min + ", Max: " + max);
    getContainer().startReopenTimer(10);
    return null;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer)

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