use of gg.projecteden.nexus.features.minigames.models.MatchData 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.MatchData in project Nexus by ProjectEdenGG.
the class Minigames method registerMatchDatas.
public static void registerMatchDatas() {
try {
String path = Minigames.class.getPackage().getName();
Set<Class<? extends MatchData>> matchDataTypes = new Reflections(path + ".models.matchdata").getSubTypesOf(MatchData.class);
for (Class<?> matchDataType : matchDataTypes) {
if (matchDataType.getAnnotation(MatchDataFor.class) == null)
continue;
for (MechanicType mechanicType : MechanicType.values()) for (Class<? extends Mechanic> superclass : mechanicType.get().getSuperclasses()) for (Class<? extends Mechanic> applicableMechanic : matchDataType.getAnnotation(MatchDataFor.class).value()) if (applicableMechanic.equals(superclass))
try {
Constructor<?> constructor = matchDataType.getConstructor(Match.class);
constructor.setAccessible(true);
matchDataMap.put(mechanicType.get(), constructor);
} catch (NoSuchMethodException ex) {
Nexus.warn("MatchData " + matchDataType.getSimpleName() + " has no Match constructor");
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
Aggregations