use of gg.projecteden.nexus.features.minigames.models.Minigamer in project Nexus by ProjectEdenGG.
the class Nameplates method of.
public static String of(Player player, Player viewer) {
final Presence presence = Presence.of(player);
final Minigamer minigamer = PlayerManager.get(player);
final JsonBuilder nameplate = new JsonBuilder();
if (minigamer.isPlaying())
if (minigamer.getTeam() != null && minigamer.getTeam().getNameTagVisibility() == NameTagVisibility.NEVER)
nameplate.next(minigamer.getNickname());
else
nameplate.next(minigamer.getColoredName());
else
nameplate.next(presence.ingame()).next(" ").next(Nerd.of(player).getChatFormat(new ChatterService().get(viewer)));
return nameplate.serialize();
}
use of gg.projecteden.nexus.features.minigames.models.Minigamer in project Nexus by ProjectEdenGG.
the class AbstractTaskMenu method scheduleInvClose.
// todo: use for more tasks
public void scheduleInvClose(HasPlayer _player) {
Player player = _player.getPlayer();
Minigamer minigamer = PlayerManager.get(player);
// don't schedule if match just ended
if (!minigamer.isPlaying(Sabotage.class))
return;
Match.MatchTasks tasks = minigamer.getMatch().getTasks();
if (closeInvTasks.containsKey(player.getUniqueId()))
tasks.cancel(closeInvTasks.remove(player.getUniqueId()));
closeInvTasks.put(player.getUniqueId(), tasks.wait(20, () -> {
player.sendMessage(Sabotage.COMPLETED_TASK_TEXT);
player.closeInventory();
}));
}
use of gg.projecteden.nexus.features.minigames.models.Minigamer 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));
});
}
use of gg.projecteden.nexus.features.minigames.models.Minigamer in project Nexus by ProjectEdenGG.
the class SabotageMatchData method getProgress.
public double getProgress() {
double progress = 0;
double total = 0;
for (Map.Entry<UUID, Set<Task>> entry : tasks.entrySet()) {
UUID uuid = entry.getKey();
Set<Task> taskSet = entry.getValue();
Minigamer minigamer;
try {
minigamer = PlayerManager.get(uuid);
} catch (PlayerNotOnlineException e) {
continue;
}
if (SabotageTeam.of(minigamer) == SabotageTeam.IMPOSTOR)
continue;
for (Task task : taskSet) {
if (task.getTask().getTaskType() == Tasks.TaskType.SABOTAGE)
continue;
progress += task.getCompleted();
total += task.getTaskSize();
}
}
return progress / total;
}
use of gg.projecteden.nexus.features.minigames.models.Minigamer in project Nexus by ProjectEdenGG.
the class TeamMechanic method onDeath.
@Override
public void onDeath(@NotNull MinigamerDeathEvent event) {
// auto-balancing
super.onDeath(event);
if (!usesAutoBalancing())
return;
Match match = event.getMatch();
Minigamer minigamer = event.getMinigamer();
if (!minigamer.isAlive() || match.isEnded() || minigamer.getTeam() == null)
return;
if (minigamer.getTeam().getMinigamers(match).size() - 1 < minigamer.getTeam().getMinPlayers())
return;
List<BalanceWrapper> wrappers = getBalanceWrappers(match).stream().filter(wrapper -> // only try to auto-balance to other teams
!wrapper.getTeam().equals(minigamer.getTeam()) && wrapper.percentageDiscrepancy() > 0 && wrapper.getNeededPlayers() != -1 && wrapper.extraPlayerPercentDiscrepancy() >= 0).sorted(Comparator.reverseOrder()).collect(Collectors.toList());
if (wrappers.isEmpty())
return;
// select randomly if multiple teams are equal
List<BalanceWrapper> randomWrappers = new ArrayList<>();
randomWrappers.add(wrappers.get(0));
double val = wrappers.get(0).extraPlayerPercentDiscrepancy();
// iterator var
int index = 1;
while (index < wrappers.size() && Math.abs(wrappers.get(index).extraPlayerPercentDiscrepancy() - val) < 0.0001d) {
randomWrappers.add(wrappers.get(index));
index++;
}
// assign team
Team team = RandomUtils.randomElement(randomWrappers).getTeam();
minigamer.setTeam(team);
minigamer.tell("", false);
minigamer.tell("&3You have been auto balanced to " + team.getColoredName());
}
Aggregations