use of gg.projecteden.nexus.models.hallofhistory.HallOfHistory.RankHistory in project Nexus by ProjectEdenGG.
the class HallOfHistoryCommand method removeRankConfirm.
@Async
@Permission(Group.STAFF)
@Path("removeRank <player> <current|former> <rank> <promotionDate> [resignationDate]")
void removeRankConfirm(OfflinePlayer player, String when, Rank rank, LocalDate promotion, LocalDate resignation) {
boolean current = "current".equalsIgnoreCase(when);
HallOfHistory history = service.get(player.getUniqueId());
ConfirmationMenu.builder().title("Remove rank from " + player.getName() + "?").onConfirm((item) -> {
for (RankHistory rankHistory : new ArrayList<>(history.getRankHistory())) {
if (!new RankHistory(rank, current, promotion, resignation).equals(rankHistory))
continue;
history.getRankHistory().remove(rankHistory);
service.save(history);
send(PREFIX + "Removed the rank from &e" + player.getName());
send(json(PREFIX + "&eClick here &3to generate a command to re-add rank").suggest("/hoh addrank " + player.getName() + " " + getRankCommandArgs(rankHistory)));
return;
}
send(PREFIX + "Could not find the rank to delete");
}).open(player());
}
use of gg.projecteden.nexus.models.hallofhistory.HallOfHistory.RankHistory in project Nexus by ProjectEdenGG.
the class HallOfHistoryCommand method staffTime.
@Async
@Path("staffTime [page]")
public void staffTime(@Arg("1") int page) {
LocalDate now = LocalDate.now();
HallOfHistoryService service = new HallOfHistoryService();
Map<UUID, Long> staffTimeMap = new HashMap<>();
for (HallOfHistory hallOfHistory : service.getAll()) {
long days = 0;
days: for (LocalDate date = ServerAge.getEPOCH().toLocalDate(); date.isBefore(now); date = date.plusDays(1)) {
for (RankHistory rankHistory : hallOfHistory.getRankHistory()) {
LocalDate from = rankHistory.getPromotionDate();
LocalDate to = rankHistory.getResignationDate();
if (from == null)
continue;
if (to == null)
to = now;
if (Utils.isBetween(date, from, to)) {
++days;
continue days;
}
}
}
if (days == 0)
continue;
staffTimeMap.put(hallOfHistory.getUuid(), days);
}
send(PREFIX + "Staff times");
BiFunction<UUID, String, JsonBuilder> formatter = (uuid, index) -> {
String time = Timespan.ofSeconds(staffTimeMap.get(uuid) * (TickTime.DAY.get() / 20)).format();
return json(index + " &e" + time + " &7- " + Nerd.of(uuid).getNameFormat());
};
paginate(Utils.sortByValueReverse(staffTimeMap).keySet(), formatter, "/hoh staffTime", page);
}
use of gg.projecteden.nexus.models.hallofhistory.HallOfHistory.RankHistory in project Nexus by ProjectEdenGG.
the class HallOfHistoryCommand method promotionTimes.
@Path("promotionTimes [page]")
void promotionTimes(@Arg("1") int page) {
HallOfHistoryService service = new HallOfHistoryService();
Map<UUID, Long> promotionTimeMap = new HashMap<>();
for (HallOfHistory hallOfHistory : service.getAll()) {
Nerd nerd = Nerd.of(hallOfHistory.getUuid());
List<RankHistory> history = hallOfHistory.getRankHistory();
history.sort(Comparator.comparing(RankHistory::getPromotionDate));
if (nerd.getFirstJoin().isBefore(ServerAge.getEPOCH().minusYears(1)))
continue;
long days = nerd.getFirstJoin().toLocalDate().until(history.get(0).getPromotionDate(), ChronoUnit.DAYS);
if (days > 0)
promotionTimeMap.put(hallOfHistory.getUuid(), days);
}
OptionalDouble average = promotionTimeMap.values().stream().mapToLong(Long::valueOf).average();
send(PREFIX + "Promotion times | Average: " + StringUtils.getNf().format(average.orElse(0)) + " days");
BiFunction<UUID, String, JsonBuilder> formatter = (uuid, index) -> {
String time = Timespan.ofSeconds(promotionTimeMap.get(uuid) * (TickTime.DAY.get() / 20)).format();
return json(index + " &e" + Nickname.of(uuid) + " &7- " + time);
};
paginate(Utils.sortByValue(promotionTimeMap).keySet(), formatter, "/hoh promotionTimes", page);
}
use of gg.projecteden.nexus.models.hallofhistory.HallOfHistory.RankHistory in project Nexus by ProjectEdenGG.
the class HallOfHistoryCommand method view.
@Async
@Path("view <player>")
void view(OfflinePlayer target) {
line(4);
Nerd nerd = Nerd.of(target);
send("&e&l" + nerd.getNickname());
line();
if (!nerd.getNickname().equals(nerd.getName()))
send(" &eIGN: &3" + nerd.getName());
if (!nerd.getPronouns().isEmpty())
send(" &ePronouns: &3" + String.join(", ", nerd.getPronouns().stream().map(Enum::toString).toList()));
line();
HallOfHistory hallOfHistory = service.get(target.getUniqueId());
for (RankHistory rankHistory : hallOfHistory.getRankHistory()) {
JsonBuilder builder = new JsonBuilder();
builder.next(" " + (rankHistory.isCurrent() ? "&2Current" : "&cFormer") + " " + rankHistory.getRank().getChatColor() + rankHistory.getRank().getName());
if (isStaff())
builder.next(" &c[x]").command("/hoh removerank " + target.getName() + " " + getRankCommandArgs(rankHistory));
send(builder);
send(" &ePromotion Date: &3" + shortDateFormat(rankHistory.getPromotionDate()));
if (rankHistory.getResignationDate() != null)
send(" &eResignation Date: &3" + shortDateFormat(rankHistory.getResignationDate()));
}
line();
if (!isNullOrEmpty(nerd.getAbout()))
send(" &eAbout me: &3" + nerd.getAbout());
if (nerd.isMeetMeVideo()) {
line();
String url = EdenSocialMediaSite.WEBSITE.getUrl() + "/meet/" + nerd.getName().toLowerCase();
send(json(" &eMeet Me!&c " + url).url(url));
}
}
Aggregations