Search in sources :

Example 1 with HoleInTheWallArena

use of gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena 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 HoleInTheWallArena

use of gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena in project Nexus by ProjectEdenGG.

the class HoleInTheWall method onRegionExit.

@EventHandler
public void onRegionExit(PlayerLeavingRegionEvent event) {
    Minigamer minigamer = PlayerManager.get(event.getPlayer());
    if (!minigamer.isPlaying(this))
        return;
    Match match = minigamer.getMatch();
    HoleInTheWallArena arena = match.getArena();
    if (arena.ownsRegion(event.getRegion(), "track")) {
        if (!(event.getParentEvent() instanceof PlayerMoveEvent) || !arena.isInRegion(((PlayerMoveEvent) event.getParentEvent()).getTo(), "track"))
            if (match.isStarted())
                event.setCancelled(true);
    }
    if (arena.ownsRegion(event.getRegion(), "lobby")) {
        if (!match.isStarted())
            event.setCancelled(true);
    }
}
Also used : PlayerMoveEvent(org.bukkit.event.player.PlayerMoveEvent) HoleInTheWallArena(gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer) Match(gg.projecteden.nexus.features.minigames.models.Match) EventHandler(org.bukkit.event.EventHandler)

Example 3 with HoleInTheWallArena

use of gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena 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 HoleInTheWallArena

use of gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena in project Nexus by ProjectEdenGG.

the class HoleInTheWall method onInitialize.

@Override
public void onInitialize(@NotNull MatchInitializeEvent event) {
    super.onInitialize(event);
    HoleInTheWallArena arena = event.getMatch().getArena();
    HoleInTheWallMatchData matchData = event.getMatch().getMatchData();
    for (Location location : arena.getDesignHangerLocation()) {
        Set<ProtectedRegion> trackRegions = arena.getRegionsLikeAt("track", location);
        if (trackRegions.size() != 1)
            throw new MinigameException("Was expecting 1 track region at " + getLocationString(location) + ", but found " + trackRegions.size());
        Track track = matchData.new Track(trackRegions.iterator().next(), location);
        track.reset();
        matchData.getTracks().add(track);
    }
}
Also used : ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) MinigameException(gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException) HoleInTheWallArena(gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena) HoleInTheWallMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData) Track(gg.projecteden.nexus.features.minigames.models.matchdata.HoleInTheWallMatchData.Track) Location(org.bukkit.Location)

Example 5 with HoleInTheWallArena

use of gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena in project Nexus by ProjectEdenGG.

the class HoleInTheWall method isInAnswerRegion.

private boolean isInAnswerRegion(Minigamer minigamer, Location location) {
    Match match = minigamer.getMatch();
    HoleInTheWallArena arena = match.getArena();
    HoleInTheWallMatchData matchData = match.getMatchData();
    Set<ProtectedRegion> answerRegions = arena.getRegionsLikeAt("answer", location);
    if (answerRegions.size() == 1) {
        Track track = matchData.getTrack(answerRegions.iterator().next());
        return track != null && minigamer.equals(track.getMinigamer());
    }
    return false;
}
Also used : ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) HoleInTheWallArena(gg.projecteden.nexus.features.minigames.models.arenas.HoleInTheWallArena) 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)

Aggregations

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