Search in sources :

Example 16 with Nerd

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");
}
Also used : Nerd(gg.projecteden.nexus.models.nerd.Nerd) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 17 with Nerd

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();
}
Also used : Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Arrays(java.util.Arrays) Nerd(gg.projecteden.nexus.models.nerd.Nerd) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) Tasks(gg.projecteden.nexus.utils.Tasks) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) Vector(org.bukkit.util.Vector) TickTime(gg.projecteden.utils.TimeUtils.TickTime) List(java.util.List) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) RandomUtils(gg.projecteden.nexus.utils.RandomUtils) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) Vector(org.bukkit.util.Vector) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 18 with Nerd

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;
}
Also used : DiscordUser(gg.projecteden.nexus.models.discord.DiscordUser) Matcher(java.util.regex.Matcher) DiscordUserService(gg.projecteden.nexus.models.discord.DiscordUserService) NicknameService(gg.projecteden.nexus.models.nickname.NicknameService) Nerd(gg.projecteden.nexus.models.nerd.Nerd) NerdService(gg.projecteden.nexus.models.nerd.NerdService) Nickname(gg.projecteden.nexus.models.nickname.Nickname)

Example 19 with Nerd

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);
}
Also used : Nerd(gg.projecteden.nexus.models.nerd.Nerd)

Example 20 with Nerd

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);
}
Also used : StringUtils(gg.projecteden.nexus.utils.StringUtils) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) BiFunction(java.util.function.BiFunction) OptionalDouble(java.util.OptionalDouble) Async(gg.projecteden.annotations.Async) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) HashMap(java.util.HashMap) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) RankHistory(gg.projecteden.nexus.models.hallofhistory.HallOfHistory.RankHistory) ArrayList(java.util.ArrayList) Nullables.isNullOrEmpty(gg.projecteden.nexus.utils.Nullables.isNullOrEmpty) ServerAge(gg.projecteden.nexus.features.commands.AgeCommand.ServerAge) Map(java.util.Map) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) Nickname(gg.projecteden.nexus.models.nickname.Nickname) Timespan(gg.projecteden.utils.TimeUtils.Timespan) ConfirmationMenu(gg.projecteden.nexus.features.menus.MenuUtils.ConfirmationMenu) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Nerd(gg.projecteden.nexus.models.nerd.Nerd) Rank(gg.projecteden.nexus.models.nerd.Rank) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) Tasks(gg.projecteden.nexus.utils.Tasks) TimeUtils.shortDateFormat(gg.projecteden.utils.TimeUtils.shortDateFormat) UUID(java.util.UUID) PlayerNotFoundException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException) TimeUtils.dateFormat(gg.projecteden.utils.TimeUtils.dateFormat) EdenSocialMediaSite(gg.projecteden.nexus.features.socialmedia.SocialMedia.EdenSocialMediaSite) HallOfHistory(gg.projecteden.nexus.models.hallofhistory.HallOfHistory) Utils(gg.projecteden.nexus.utils.Utils) OfflinePlayer(org.bukkit.OfflinePlayer) StringUtils.stripColor(gg.projecteden.nexus.utils.StringUtils.stripColor) Aliases(gg.projecteden.nexus.framework.commands.models.annotations.Aliases) TickTime(gg.projecteden.utils.TimeUtils.TickTime) List(java.util.List) ChronoUnit(java.time.temporal.ChronoUnit) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) LocalDate(java.time.LocalDate) NerdService(gg.projecteden.nexus.models.nerd.NerdService) HallOfHistoryService(gg.projecteden.nexus.models.hallofhistory.HallOfHistoryService) Comparator(java.util.Comparator) HashMap(java.util.HashMap) HallOfHistory(gg.projecteden.nexus.models.hallofhistory.HallOfHistory) Nerd(gg.projecteden.nexus.models.nerd.Nerd) OptionalDouble(java.util.OptionalDouble) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) HallOfHistoryService(gg.projecteden.nexus.models.hallofhistory.HallOfHistoryService) RankHistory(gg.projecteden.nexus.models.hallofhistory.HallOfHistory.RankHistory) UUID(java.util.UUID) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Aggregations

Nerd (gg.projecteden.nexus.models.nerd.Nerd)22 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)12 NerdService (gg.projecteden.nexus.models.nerd.NerdService)8 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)6 EventHandler (org.bukkit.event.EventHandler)5 Async (gg.projecteden.annotations.Async)4 JsonBuilder (gg.projecteden.nexus.utils.JsonBuilder)4 CustomCommand (gg.projecteden.nexus.framework.commands.models.CustomCommand)3 Arg (gg.projecteden.nexus.framework.commands.models.annotations.Arg)3 Group (gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group)3 CommandEvent (gg.projecteden.nexus.framework.commands.models.events.CommandEvent)3 PlayerNotFoundException (gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException)3 Aliases (gg.projecteden.nexus.framework.commands.models.annotations.Aliases)2 HallOfHistory (gg.projecteden.nexus.models.hallofhistory.HallOfHistory)2 RankHistory (gg.projecteden.nexus.models.hallofhistory.HallOfHistory.RankHistory)2 Rank (gg.projecteden.nexus.models.nerd.Rank)2 Nickname (gg.projecteden.nexus.models.nickname.Nickname)2 Tasks (gg.projecteden.nexus.utils.Tasks)2 TickTime (gg.projecteden.utils.TimeUtils.TickTime)2 HashMap (java.util.HashMap)2