use of gg.projecteden.nexus.models.nerd.Nerd in project Nexus by ProjectEdenGG.
the class PlayerSearchCommand method search.
@Path("<name> [amount]")
void search(String search, @Arg("25") int limit) {
if (search.length() < 3)
error("Please be more specific!");
List<Nerd> nerds = service.find(search).stream().limit(limit).collect(Collectors.toList());
if (nerds.size() == 0)
error("No matches found for &e" + search);
send("&3Matches for '&e" + search + "&3' (&e" + nerds.size() + "&3):");
for (Nerd nerd : nerds) send(json("&e" + nerd.getName()).insert(nerd.getName()));
send("&3Shift+Click on a name to insert it into your chat");
}
use of gg.projecteden.nexus.models.nerd.Nerd in project Nexus by ProjectEdenGG.
the class WeeeCommand method weee.
@Path("[player]")
void weee(@Arg("self") Nerd nerd) {
if (nerd.getWorldGroup().isMinigames())
error("Cannot weee " + nerd.getNickname() + ", they are in minigames");
List<Vector> vectors = Arrays.asList(new Vector(3, 0, 1), new Vector(-3, 0, 1), new Vector(1, 0, 3), new Vector(1, 0, -3), new Vector(0, 2.5, 0));
Tasks.Countdown.builder().duration(TickTime.SECOND.x(10)).doZero(true).onTick(i -> {
if (i % 5 == 0)
nerd.getOnlinePlayer().setVelocity(RandomUtils.randomElement(vectors));
}).start();
}
use of gg.projecteden.nexus.models.nerd.Nerd in project Nexus by ProjectEdenGG.
the class IngameBridgeListener method parseMentions.
public static String parseMentions(String message) {
if (message != null && message.contains("@")) {
Matcher matcher = Pattern.compile("@[\\w]+").matcher(message);
while (matcher.find()) {
String group = matcher.group();
String search = group.replace("@", "");
Nerd nerd = new NerdService().findExact(search);
if (nerd != null) {
DiscordUser mentioned = new DiscordUserService().get(nerd);
if (mentioned.getUserId() != null) {
message = message.replace(group, "<@" + mentioned.getUserId() + ">");
} else {
Nickname fromNickname = new NicknameService().getFromNickname(search);
if (fromNickname != null) {
mentioned = new DiscordUserService().get(fromNickname);
if (mentioned.getUserId() != null)
message = message.replace(group, "<@" + mentioned.getUserId() + ">");
}
}
}
}
}
return message;
}
use of gg.projecteden.nexus.models.nerd.Nerd in project Nexus by ProjectEdenGG.
the class SocialListener method checkSession.
private static void checkSession(Player player) {
Nerd nerd = Nerd.of(player);
long login = nerd.getLastJoin().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
long now = System.currentTimeMillis();
if ((now - login) >= (60 * 60 * 12 * 1000))
// Odd behavior occurs when new players leave too quickly
if ((now - login) <= (60 * 60 * 13 * 1000))
Achievement.SLEEPLESS_NIGHT.check(player);
}
use of gg.projecteden.nexus.models.nerd.Nerd 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);
}
Aggregations