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);
}));
}
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);
}
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));
}
}
}
}
}
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);
}
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);
}
}
Aggregations