use of gg.projecteden.nexus.features.minigames.models.Arena 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.Arena in project Nexus by ProjectEdenGG.
the class PotionEffectEditorMenu method init.
@Override
public void init(Player player, InventoryContents contents) {
addBackItem(contents, e -> menus.getTeamMenus().openPotionEffectsMenu(player, arena, team));
contents.set(0, 3, ClickableItem.from(nameItem(Material.REDSTONE, "&eDuration", "||&eCurrent value: &3" + potionEffect.getDuration()), e -> openAnvilMenu(player, arena, team, potionEffect, String.valueOf(potionEffect.getDuration()), (p, text) -> {
if (Utils.isInt(text)) {
team.getLoadout().getEffects().remove(potionEffect);
potionEffect = new PotionEffectBuilder(potionEffect).duration(Integer.parseInt(text)).build();
team.getLoadout().getEffects().add(potionEffect);
arena.write();
Tasks.wait(1, () -> {
// Since potion effects don't have setters, pass-by-reference is broken, so we
// have to do some hacky waits to get the menu to open with the correct object
player.closeInventory();
Tasks.wait(1, () -> menus.getTeamMenus().openPotionEffectEditorMenu(player, arena, team, potionEffect));
});
return AnvilGUI.Response.text(text);
} else {
PlayerUtils.send(player, PREFIX + "You must use an integer for the duration.");
return AnvilGUI.Response.close();
}
})));
contents.set(0, 5, ClickableItem.from(nameItem(Material.GLOWSTONE_DUST, "&eAmplifier", "||&eCurrent value: &3" + (potionEffect.getAmplifier() + 1)), e -> openAnvilMenu(player, arena, team, potionEffect, String.valueOf(potionEffect.getAmplifier()), (p, text) -> {
if (Utils.isInt(text)) {
team.getLoadout().getEffects().remove(potionEffect);
potionEffect = new PotionEffectBuilder(potionEffect).amplifier(Integer.parseInt(text) - 1).build();
team.getLoadout().getEffects().add(potionEffect);
arena.write();
Tasks.wait(1, () -> {
player.closeInventory();
Tasks.wait(1, () -> menus.getTeamMenus().openPotionEffectEditorMenu(player, arena, team, potionEffect));
});
return AnvilGUI.Response.text(text);
} else {
PlayerUtils.send(player, PREFIX + "You must use an integer for the amplifier.");
return AnvilGUI.Response.close();
}
})));
contents.set(0, 8, ClickableItem.from(nameItem(Material.END_CRYSTAL, "&eSave"), e -> arena.write()));
int row = 2;
int column = 0;
for (PotionEffectType effect : PotionEffectType.values()) {
if (effect == null)
continue;
ItemStack potionItem = new ItemBuilder(Material.POTION).name("&e" + StringUtils.camelCase(effect.getName().replace("_", " "))).potionEffect(new PotionEffectBuilder(effect).duration(5).amplifier(0)).potionEffectColor(effect.getColor()).build();
if (effect == potionEffect.getType())
potionItem.setType(Material.SPLASH_POTION);
contents.set(row, column, ClickableItem.from(potionItem, e -> {
team.getLoadout().getEffects().remove(potionEffect);
potionEffect = new PotionEffectBuilder(potionEffect).type(effect).build();
team.getLoadout().getEffects().add(potionEffect);
arena.write();
Tasks.wait(1, () -> {
player.closeInventory();
Tasks.wait(1, () -> menus.getTeamMenus().openPotionEffectEditorMenu(player, arena, team, potionEffect));
});
}));
if (column == 8) {
column = 0;
row++;
} else {
column++;
}
}
}
use of gg.projecteden.nexus.features.minigames.models.Arena in project Nexus by ProjectEdenGG.
the class TeamMechanic method nextTurn.
public void nextTurn(@NotNull Match match) {
Arena arena = match.getArena();
MatchData matchData = match.getMatchData();
MatchTasks tasks = match.getTasks();
if (match.isEnded() || matchData == null)
return;
if (matchData.getTurnTeam() != null) {
onTurnEnd(match, matchData.getTurnTeam());
matchData.setTurnTeam(null);
}
if (shouldBeOver(match)) {
end(match);
return;
}
if (matchData.getTurns() >= match.getArena().getMaxTurns()) {
match.broadcast("Max turns reached, ending game");
match.end();
return;
}
if (matchData.getTurnTeamList().isEmpty()) {
matchData.setTurnTeamList(new ArrayList<>(match.getAliveTeams()));
if (shuffleTurnList())
Collections.shuffle(matchData.getTurnTeamList());
}
tasks.cancel(MatchTaskType.TURN);
Team team = matchData.getTurnTeamList().get(0);
matchData.getTurnTeamList().remove(team);
matchData.setTurnTeam(team);
match.getScoreboard().update();
onTurnStart(match, team);
tasks.register(MatchTaskType.TURN, tasks.wait(arena.getTurnTime() * TickTime.SECOND.get(), () -> nextTurn(match)));
}
use of gg.projecteden.nexus.features.minigames.models.Arena in project Nexus by ProjectEdenGG.
the class TeamMechanic method announceWinners.
@Override
public void announceWinners(@NotNull Match match) {
Arena arena = match.getArena();
Map<Team, Integer> scores = match.getScores();
int winningScore = getWinningScore(scores.values());
List<Team> winners = getWinningTeams(winningScore, scores);
String announcement = null;
if (winningScore == 0)
announcement = "No teams scored in ";
else if (arena.getTeams().size() == winners.size())
announcement = "All teams tied in ";
JsonBuilder builder = new JsonBuilder();
builder.next(announcement == null ? getWinnersComponent(winners) : Component.text(announcement));
builder.next(arena);
if (winningScore != 0)
builder.next(" (" + winningScore + ")");
Minigames.broadcast(builder);
}
use of gg.projecteden.nexus.features.minigames.models.Arena in project Nexus by ProjectEdenGG.
the class TeamMechanic method basicBalanceCheck.
public final boolean basicBalanceCheck(@NotNull List<Minigamer> minigamers) {
if (minigamers.isEmpty())
return false;
Match match = minigamers.get(0).getMatch();
Arena arena = match.getArena();
List<Team> teams = new ArrayList<>(arena.getTeams());
int required = 0;
for (Team team : teams) required += team.getMinPlayers();
if (match.getMinigamers().size() < required) {
error("Not enough players to meet team requirements!", match);
return false;
}
return true;
}
Aggregations