Search in sources :

Example 1 with Track

use of gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track in project Nexus by ProjectEdenGG.

the class HoleInTheWall method onStart.

@Override
public void onStart(@NotNull MatchStartEvent event) {
    super.onStart(event);
    Match match = event.getMatch();
    HoleInTheWallArena arena = event.getMatch().getArena();
    HoleInTheWallMatchData matchData = event.getMatch().getMatchData();
    matchData.getTracks().forEach(track -> {
        Optional<Minigamer> minigamer = arena.worldguard().getPlayersInRegion(track.getRegion()).stream().map(PlayerManager::get).filter(_minigamer -> _minigamer.isPlaying(match)).findFirst();
        minigamer.ifPresent(track::setMinigamer);
    });
    match.getTasks().countdown(Countdown.builder().duration(TickTime.SECOND.x(5)).onSecond(i -> match.broadcast("&7Starting in &e" + i + "...")).onComplete(() -> {
        match.broadcast("Go!");
        matchData.getTracks().stream().filter(track -> track.getMinigamer() != null).forEach(Track::start);
    }));
}
Also used : ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) ActionGroup(gg.projecteden.nexus.utils.Utils.ActionGroup) PlayerManager(gg.projecteden.nexus.features.minigames.managers.PlayerManager) PlayerMoveEvent(org.bukkit.event.player.PlayerMoveEvent) Player(org.bukkit.entity.Player) Action(org.bukkit.event.block.Action) TeamlessMechanic(gg.projecteden.nexus.features.minigames.models.mechanics.multiplayer.teamless.TeamlessMechanic) Match(gg.projecteden.nexus.features.minigames.models.Match) MinigamerQuitEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MinigamerQuitEvent) Countdown(gg.projecteden.nexus.utils.Tasks.Countdown) EventHandler(org.bukkit.event.EventHandler) GameMode(org.bukkit.GameMode) Location(org.bukkit.Location) MaterialTag(gg.projecteden.nexus.utils.MaterialTag) MatchEndEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchEndEvent) PlayerInteractEvent(org.bukkit.event.player.PlayerInteractEvent) StringUtils.getLocationString(gg.projecteden.nexus.utils.StringUtils.getLocationString) MatchInitializeEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchInitializeEvent) Material(org.bukkit.Material) BlockPlaceEvent(org.bukkit.event.block.BlockPlaceEvent) Sign(org.bukkit.block.Sign) SoundCategory(org.bukkit.SoundCategory) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer) Set(java.util.Set) Sound(org.bukkit.Sound) UUID(java.util.UUID) MatchStartEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchStartEvent) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) Track(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track) ItemStack(org.bukkit.inventory.ItemStack) StringUtils.stripColor(gg.projecteden.nexus.utils.StringUtils.stripColor) TickTime(gg.projecteden.utils.TimeUtils.TickTime) MinigameException(gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException) PlayerLeavingRegionEvent(gg.projecteden.nexus.features.regionapi.events.player.PlayerLeavingRegionEvent) HoleInTheWallArena(gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena) HoleInTheWallMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData) Optional(java.util.Optional) NotNull(org.jetbrains.annotations.NotNull) PlayerManager(gg.projecteden.nexus.features.minigames.managers.PlayerManager) HoleInTheWallArena(gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer) HoleInTheWallMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData) Match(gg.projecteden.nexus.features.minigames.models.Match)

Example 2 with Track

use of gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track in project Nexus by ProjectEdenGG.

the class HoleInTheWall method onEnd.

@Override
public void onEnd(@NotNull MatchEndEvent event) {
    HoleInTheWallMatchData matchData = event.getMatch().getMatchData();
    matchData.getTracks().forEach(Track::reset);
    super.onEnd(event);
}
Also used : HoleInTheWallMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData) Track(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track)

Example 3 with Track

use of gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track in project Nexus by ProjectEdenGG.

the class HoleInTheWall method onPlayerInteract.

@Override
public void onPlayerInteract(Minigamer minigamer, PlayerInteractEvent event) {
    Match match = minigamer.getMatch();
    HoleInTheWallArena arena = match.getArena();
    HoleInTheWallMatchData matchData = match.getMatchData();
    if (event.getClickedBlock() != null) {
        if (event.getAction() == Action.LEFT_CLICK_BLOCK)
            if (MaterialTag.STAINED_GLASS.isTagged(event.getClickedBlock().getType())) {
                if (isInAnswerRegion(minigamer, event.getClickedBlock().getLocation())) {
                    Player player = event.getPlayer();
                    player.playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, SoundCategory.BLOCKS, 1F, 1F);
                    player.getInventory().addItem(new ItemStack(event.getClickedBlock().getType()));
                    event.getClickedBlock().setType(Material.AIR);
                }
            }
        if (ActionGroup.CLICK_BLOCK.applies(event))
            if (MaterialTag.SIGNS.isTagged(event.getClickedBlock().getType())) {
                Sign sign = (Sign) event.getClickedBlock().getState();
                if (stripColor(sign.getLine(2)).contains("Fast Forward")) {
                    Track track = matchData.getTrack(minigamer);
                    if (track != null) {
                        UUID uuid = minigamer.getPlayer().getUniqueId();
                        String type = "HoleInTheWall-Skip";
                        if (new CooldownService().check(uuid, type, TickTime.SECOND.x(3)))
                            track.skip();
                        else
                            minigamer.tell("You must wait &e" + new CooldownService().getDiff(uuid, type));
                    }
                }
            }
    }
}
Also used : Player(org.bukkit.entity.Player) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) Sign(org.bukkit.block.Sign) HoleInTheWallArena(gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena) StringUtils.getLocationString(gg.projecteden.nexus.utils.StringUtils.getLocationString) ItemStack(org.bukkit.inventory.ItemStack) UUID(java.util.UUID) HoleInTheWallMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData) Track(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track) Match(gg.projecteden.nexus.features.minigames.models.Match)

Example 4 with Track

use of gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track in project Nexus by ProjectEdenGG.

the class HoleInTheWall method onQuit.

@Override
public void onQuit(@NotNull MinigamerQuitEvent event) {
    HoleInTheWallMatchData matchData = event.getMatch().getMatchData();
    Track track = matchData.getTrack(event.getMinigamer());
    if (track != null)
        track.reset();
    super.onQuit(event);
}
Also used : HoleInTheWallMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData) Track(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track)

Example 5 with Track

use of gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track in project Nexus by ProjectEdenGG.

the class HoleInTheWall method onMatchEnd.

@EventHandler
public void onMatchEnd(MatchEndEvent event) {
    Match match = event.getMatch();
    if (!match.isMechanic(this))
        return;
    HoleInTheWallMatchData matchData = match.getMatchData();
    if (!matchData.isEnding() && !shouldBeOver(match)) {
        if (match.getTimer().getTime() == 0)
            match.broadcast("Time is up!");
        matchData.setEnding(true);
        event.setCancelled(true);
        matchData.getTracks().stream().filter(track -> track.getMinigamer() != null).forEach(Track::end);
        match.getTasks().wait(TickTime.SECOND.x(5), match::end);
    }
}
Also used : ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) ActionGroup(gg.projecteden.nexus.utils.Utils.ActionGroup) PlayerManager(gg.projecteden.nexus.features.minigames.managers.PlayerManager) PlayerMoveEvent(org.bukkit.event.player.PlayerMoveEvent) Player(org.bukkit.entity.Player) Action(org.bukkit.event.block.Action) TeamlessMechanic(gg.projecteden.nexus.features.minigames.models.mechanics.multiplayer.teamless.TeamlessMechanic) Match(gg.projecteden.nexus.features.minigames.models.Match) MinigamerQuitEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MinigamerQuitEvent) Countdown(gg.projecteden.nexus.utils.Tasks.Countdown) EventHandler(org.bukkit.event.EventHandler) GameMode(org.bukkit.GameMode) Location(org.bukkit.Location) MaterialTag(gg.projecteden.nexus.utils.MaterialTag) MatchEndEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchEndEvent) PlayerInteractEvent(org.bukkit.event.player.PlayerInteractEvent) StringUtils.getLocationString(gg.projecteden.nexus.utils.StringUtils.getLocationString) MatchInitializeEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchInitializeEvent) Material(org.bukkit.Material) BlockPlaceEvent(org.bukkit.event.block.BlockPlaceEvent) Sign(org.bukkit.block.Sign) SoundCategory(org.bukkit.SoundCategory) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer) Set(java.util.Set) Sound(org.bukkit.Sound) UUID(java.util.UUID) MatchStartEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchStartEvent) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) Track(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track) ItemStack(org.bukkit.inventory.ItemStack) StringUtils.stripColor(gg.projecteden.nexus.utils.StringUtils.stripColor) TickTime(gg.projecteden.utils.TimeUtils.TickTime) MinigameException(gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException) PlayerLeavingRegionEvent(gg.projecteden.nexus.features.regionapi.events.player.PlayerLeavingRegionEvent) HoleInTheWallArena(gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena) HoleInTheWallMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData) Optional(java.util.Optional) NotNull(org.jetbrains.annotations.NotNull) HoleInTheWallMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData) Track(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track) Match(gg.projecteden.nexus.features.minigames.models.Match) EventHandler(org.bukkit.event.EventHandler)

Aggregations

HoleInTheWallMatchData (gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData)7 Track (gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track)7 HoleInTheWallArena (gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena)5 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)4 Match (gg.projecteden.nexus.features.minigames.models.Match)4 MinigameException (gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException)3 CooldownService (gg.projecteden.nexus.models.cooldown.CooldownService)3 StringUtils.getLocationString (gg.projecteden.nexus.utils.StringUtils.getLocationString)3 UUID (java.util.UUID)3 Location (org.bukkit.Location)3 Sign (org.bukkit.block.Sign)3 Player (org.bukkit.entity.Player)3 ItemStack (org.bukkit.inventory.ItemStack)3 PlayerManager (gg.projecteden.nexus.features.minigames.managers.PlayerManager)2 Minigamer (gg.projecteden.nexus.features.minigames.models.Minigamer)2 MatchEndEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MatchEndEvent)2 MatchInitializeEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MatchInitializeEvent)2 MatchStartEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MatchStartEvent)2 MinigamerQuitEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MinigamerQuitEvent)2 TeamlessMechanic (gg.projecteden.nexus.features.minigames.models.mechanics.multiplayer.teamless.TeamlessMechanic)2