use of gg.projecteden.nexus.features.minigames.models.Match in project Nexus by ProjectEdenGG.
the class ToyTesting method onMatchStart.
@EventHandler
public void onMatchStart(MatchStartEvent event) {
Match match = event.getMatch();
String arenaName = match.getArena().getName();
if (arenaName.equalsIgnoreCase("AlphaVsOmega")) {
setPlayedGame(match.getPlayers(), Toy.BATTLESHIP);
} else if (arenaName.equalsIgnoreCase("MasterMind")) {
setPlayedGame(match.getPlayers(), Toy.MASTERMIND);
}
}
use of gg.projecteden.nexus.features.minigames.models.Match in project Nexus by ProjectEdenGG.
the class MinigamesCommand method autoreset.
@Path("autoreset [boolean]")
@Permission(PERMISSION_USE)
void autoreset(Boolean autoreset) {
Match match = minigamer.getMatch();
if (!minigamer.isPlaying())
error("You must be playing a checkpoint game to use that command");
if (!(match.getMechanic() instanceof CheckpointMechanic))
error("You are not in a checkpoint game");
CheckpointMatchData matchData = match.getMatchData();
matchData.autoreset(minigamer, autoreset);
if (matchData.isAutoresetting(minigamer))
send(PREFIX + "Enabled &eAuto Reset");
else
send(PREFIX + "Disabled &eAuto Reset");
}
use of gg.projecteden.nexus.features.minigames.models.Match in project Nexus by ProjectEdenGG.
the class MinigamesCommand method list.
@Path("list [filter]")
@Permission(PERMISSION_USE)
void list(String filter) {
JsonBuilder json = json(PREFIX);
final List<Arena> arenas = ArenaManager.getAll(filter).stream().sorted(Comparator.comparing(Arena::getName).thenComparing(arena -> MatchManager.find(arena) != null)).toList();
final Iterator<Arena> iterator = arenas.iterator();
while (iterator.hasNext()) {
Arena arena = iterator.next();
Match match = MatchManager.find(arena);
if (match == null)
json.next("&3" + arena.getName());
else
json.next("&e" + arena.getName()).hover(match.getMinigamers().stream().map(Minigamer::getNickname).collect(Collectors.joining(", ")));
if (iterator.hasNext())
json.group().next("&3, ").group();
}
send(json);
}
use of gg.projecteden.nexus.features.minigames.models.Match 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.Match in project Nexus by ProjectEdenGG.
the class TeamMechanic method getBalanceWrappers.
@NotNull
protected List<BalanceWrapper> getBalanceWrappers(@NotNull Match match) {
// ALL PERCENTAGES HERE RANGE FROM 0 to 1 !!
List<Team> teams = match.getArena().getTeams();
List<BalanceWrapper> wrappers = new ArrayList<>();
// sum of all balance percentages
double percentageSum = 0;
// count of teams w/o balance percentages
int noPercentage = 0;
for (Team team : teams) {
BalanceWrapper wrapper = new BalanceWrapper(team, match);
wrappers.add(wrapper);
if (wrapper.getPercentage() != null)
percentageSum += wrapper.getPercentage();
else
noPercentage++;
}
if (noPercentage > 0 && percentageSum < 1) {
// evenly split the balance of teams that don't have a balance percentage (if there is any unassigned %)
double percentage = (1d / noPercentage) * (1d - percentageSum);
wrappers.stream().filter(wrapper -> wrapper.getPercentage() == null).forEach(wrapper -> wrapper.setPercentage(percentage));
}
// ensure percentages add up to 100
double totalPercentage = wrappers.stream().mapToDouble(BalanceWrapper::getPercentage).sum();
wrappers.forEach(wrapper -> wrapper.setPercentage(wrapper.getPercentage() / totalPercentage));
return wrappers;
}
Aggregations