use of gg.projecteden.nexus.features.minigames.models.mechanics.custom.sabotage.SabotageTeam in project Nexus by ProjectEdenGG.
the class SabotageMatchData method endMeeting.
public void endMeeting() {
if (votingScreen instanceof ResultsScreen)
return;
AbstractVoteScreen oldScreen = votingScreen;
votingScreen = new ResultsScreen();
meetingEnded = LocalDateTime.now();
match.getTasks().cancel(meetingTaskID);
match.getTasks().cancel(endMeetingTask);
meetingTaskID = -1;
endMeetingTask = -1;
match.getMinigamers().forEach(minigamer -> {
oldScreen.close(minigamer);
votingScreen.open(minigamer);
minigamer.getPlayer().getInventory().remove(Sabotage.VOTING_ITEM.get());
});
match.getTasks().wait(TimeUtils.TickTime.SECOND.x(Sabotage.POST_MEETING_DELAY), () -> {
match.getMinigamers().forEach(minigamer -> votingScreen.close(minigamer));
Minigamer ejected = null;
int votes = getVotesFor(null).size();
boolean tie = false;
for (Minigamer minigamer : match.getAliveMinigamers()) {
int mVotes = getVotesFor(minigamer).size();
if (mVotes > votes) {
ejected = minigamer;
votes = mVotes;
tie = false;
} else if (mVotes == votes) {
ejected = null;
tie = true;
}
}
String ejectedName;
if (ejected != null) {
ejectedName = ejected.getNickname();
} else
ejectedName = "Nobody";
String display = ejectedName + " was ejected.";
if (ejected == null)
display += " (" + (tie ? "Tied" : "Skipped") + ")";
// TODO: true animation
match.showTitle(Title.title(Component.empty(), new JsonBuilder(display).build(), Title.Times.of(fade, Duration.ofSeconds(7), fade)));
match.playSound(Sound.sound(org.bukkit.Sound.ENTITY_PLAYER_SPLASH_HIGH_SPEED, Sound.Source.PLAYER, 1.0F, 1.0F));
clearVotes();
votingScreen = null;
roundStarted = LocalDateTime.now();
match.getMinigamers().forEach(Minigamer::respawn);
SabotageTeam team = SabotageTeam.of(ejected);
if (team == SabotageTeam.JESTER) {
ejected.scored();
match.end();
} else if (ejected != null)
match.getMechanic().onDeath(new MinigamerDeathEvent(ejected));
});
}
Aggregations