Search in sources :

Example 1 with MatchBeginEvent

use of gg.projecteden.nexus.features.minigames.models.events.matches.MatchBeginEvent in project Nexus by ProjectEdenGG.

the class Mechanic method onStart.

public void onStart(@NotNull MatchStartEvent event) {
    Match match = event.getMatch();
    match.broadcast("Starting match");
    match.broadcastNoPrefix("");
    int lives = match.getArena().getLives();
    if (lives > 0)
        match.getMinigamers().forEach(minigamer -> minigamer.setLives(lives));
    else
        match.getMinigamers().forEach(minigamer -> {
            if (minigamer.getTeam().getLives() > 0)
                minigamer.setLives(minigamer.getTeam().getLives());
        });
    int beginDelay = match.getArena().getBeginDelay();
    if (beginDelay > 0) {
        int taskId = match.getTasks().countdown(Countdown.builder().duration(TickTime.SECOND.x(beginDelay)).onSecond(i -> {
            if (Arrays.asList(60, 30, 15, 5, 4, 3, 2, 1).contains(i))
                match.broadcast("&7Starting in &e" + plural(i + " second", i) + "...");
        }).onComplete(() -> {
            MatchBeginEvent beginEvent = new MatchBeginEvent(match);
            if (beginEvent.callEvent())
                onBegin(beginEvent);
        }));
        match.getTasks().register(MatchTaskType.BEGIN_DELAY, taskId);
    } else {
        MatchBeginEvent beginEvent = new MatchBeginEvent(match);
        if (beginEvent.callEvent())
            onBegin(beginEvent);
    }
    int taskId = match.getTasks().repeat(0, 1, () -> match.getMinigamers().forEach(Minigamer::tick));
    match.getTasks().register(MatchTaskType.TICK, taskId);
}
Also used : Arrays(java.util.Arrays) StringUtils.plural(gg.projecteden.nexus.utils.StringUtils.plural) StringUtils(gg.projecteden.nexus.utils.StringUtils) ActionGroup(gg.projecteden.nexus.utils.Utils.ActionGroup) Match(gg.projecteden.nexus.features.minigames.models.Match) Countdown(gg.projecteden.nexus.utils.Tasks.Countdown) MatchJoinEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchJoinEvent) Block(org.bukkit.block.Block) MatchEndEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchEndEvent) Map(java.util.Map) Utils.getMin(gg.projecteden.nexus.utils.Utils.getMin) Team(gg.projecteden.nexus.features.minigames.models.Team) Timespan(gg.projecteden.utils.TimeUtils.Timespan) Minigames(gg.projecteden.nexus.features.minigames.Minigames) Nexus(gg.projecteden.nexus.Nexus) TextComponent(net.kyori.adventure.text.TextComponent) MatchBeginEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchBeginEvent) MinigameModifier(gg.projecteden.nexus.features.minigames.models.modifiers.MinigameModifier) Collection(java.util.Collection) TitleBuilder(gg.projecteden.nexus.utils.TitleBuilder) MatchStartEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchStartEvent) StringUtils.left(gg.projecteden.nexus.utils.StringUtils.left) NamedTextColor(net.kyori.adventure.text.format.NamedTextColor) Arena(gg.projecteden.nexus.features.minigames.models.Arena) ItemStack(org.bukkit.inventory.ItemStack) MinigamerDeathEvent(gg.projecteden.nexus.features.minigames.models.events.matches.minigamers.MinigamerDeathEvent) Nullable(org.jetbrains.annotations.Nullable) NoModifier(gg.projecteden.nexus.features.minigames.modifiers.NoModifier) Contract(org.jetbrains.annotations.Contract) List(java.util.List) Named(gg.projecteden.interfaces.Named) Annotation(java.lang.annotation.Annotation) NotNull(org.jetbrains.annotations.NotNull) PlayerParticlePerk(gg.projecteden.nexus.features.minigames.models.perks.common.PlayerParticlePerk) TeamMechanic(gg.projecteden.nexus.features.minigames.models.mechanics.multiplayer.teams.TeamMechanic) ActionBarUtils.sendActionBar(gg.projecteden.nexus.utils.ActionBarUtils.sendActionBar) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) HashMap(java.util.HashMap) ComponentLike(net.kyori.adventure.text.ComponentLike) MinigamerQuitEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MinigamerQuitEvent) ArrayList(java.util.ArrayList) GameMode(org.bukkit.GameMode) Component(net.kyori.adventure.text.Component) PlayerInteractEvent(org.bukkit.event.player.PlayerInteractEvent) MatchInitializeEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchInitializeEvent) Listener(org.bukkit.event.Listener) MinigamerDisplayTimerEvent(gg.projecteden.nexus.features.minigames.models.events.matches.minigamers.sabotage.MinigamerDisplayTimerEvent) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer) MinigamerDamageEvent(gg.projecteden.nexus.features.minigames.models.events.matches.minigamers.MinigamerDamageEvent) Perk(gg.projecteden.nexus.features.minigames.models.perks.Perk) HasDescription(gg.projecteden.nexus.framework.interfaces.HasDescription) Utils(gg.projecteden.nexus.utils.Utils) MatchTaskType(gg.projecteden.nexus.features.minigames.models.Match.MatchTasks.MatchTaskType) TickTime(gg.projecteden.utils.TimeUtils.TickTime) Collections(java.util.Collections) MatchBeginEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchBeginEvent) Match(gg.projecteden.nexus.features.minigames.models.Match)

Aggregations

Named (gg.projecteden.interfaces.Named)1 Nexus (gg.projecteden.nexus.Nexus)1 Minigames (gg.projecteden.nexus.features.minigames.Minigames)1 Arena (gg.projecteden.nexus.features.minigames.models.Arena)1 Match (gg.projecteden.nexus.features.minigames.models.Match)1 MatchTaskType (gg.projecteden.nexus.features.minigames.models.Match.MatchTasks.MatchTaskType)1 Minigamer (gg.projecteden.nexus.features.minigames.models.Minigamer)1 Team (gg.projecteden.nexus.features.minigames.models.Team)1 MatchBeginEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MatchBeginEvent)1 MatchEndEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MatchEndEvent)1 MatchInitializeEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MatchInitializeEvent)1 MatchJoinEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MatchJoinEvent)1 MatchStartEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MatchStartEvent)1 MinigamerQuitEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MinigamerQuitEvent)1 MinigamerDamageEvent (gg.projecteden.nexus.features.minigames.models.events.matches.minigamers.MinigamerDamageEvent)1 MinigamerDeathEvent (gg.projecteden.nexus.features.minigames.models.events.matches.minigamers.MinigamerDeathEvent)1 MinigamerDisplayTimerEvent (gg.projecteden.nexus.features.minigames.models.events.matches.minigamers.sabotage.MinigamerDisplayTimerEvent)1 TeamMechanic (gg.projecteden.nexus.features.minigames.models.mechanics.multiplayer.teams.TeamMechanic)1 MinigameModifier (gg.projecteden.nexus.features.minigames.models.modifiers.MinigameModifier)1 Perk (gg.projecteden.nexus.features.minigames.models.perks.Perk)1