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