Search in sources :

Example 1 with Nerd

use of gg.projecteden.nexus.models.nerd.Nerd in project Nexus by ProjectEdenGG.

the class BirthdaysCommand method birthday.

@Path("[amount]")
void birthday(@Arg("10") int amount) {
    List<Nerd> nerds = service.getNerdsWithBirthdays();
    nerds.sort((nerd1, nerd2) -> {
        LocalDate now = LocalDate.now();
        return (int) ChronoUnit.DAYS.between(now, getNextBirthday(nerd1)) - (int) ChronoUnit.DAYS.between(now, getNextBirthday(nerd2));
    });
    line();
    send("&3Upcoming birthdays:");
    line();
    for (int i = 0; i < Math.min(amount, nerds.size()); i++) {
        if (LocalDate.now().getDayOfYear() == getNextBirthday(nerds.get(i)).getDayOfYear())
            send("&3" + (i + 1) + " &e" + Nickname.of(nerds.get(i)) + " &7- Today");
        else {
            long until = ChronoUnit.DAYS.between(LocalDate.now(), getNextBirthday(nerds.get(i)));
            send(json().next("&3" + (i + 1) + " &e" + Nickname.of(nerds.get(i)) + " &7- " + until + plural(" day", until)).hover(nerds.get(i).getBirthday().format(DateTimeFormatter.ofPattern("MM/dd/yyyy"))));
        }
    }
}
Also used : Nerd(gg.projecteden.nexus.models.nerd.Nerd) LocalDate(java.time.LocalDate) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 2 with Nerd

use of gg.projecteden.nexus.models.nerd.Nerd in project Nexus by ProjectEdenGG.

the class OnlineCommand method help.

@Path
@Override
public void help() {
    long vanished = OnlinePlayers.getAll().stream().filter(PlayerUtils::isVanished).count();
    long online = OnlinePlayers.getAll().size() - vanished;
    boolean canSeeVanished = !isPlayer() || player().hasPermission("pv.see");
    String counts = online + ((canSeeVanished && vanished > 0) ? " &3+ &e" + vanished : "");
    line();
    send("&3There are &e" + counts + " &3out of maximum &e" + Bukkit.getMaxPlayers() + " &3players online");
    Rank.REVERSED.forEach(rank -> {
        List<Nerd> nerds = rank.getOnlineNerds().stream().filter(this::canSee).collect(Collectors.toList());
        if (nerds.size() == 0)
            return;
        JsonBuilder builder = new JsonBuilder(rank.getColoredName() + "s&f: ");
        nerds.forEach(nerd -> getNameWithPresence(nerd, builder));
        send(builder);
    });
    line();
    send("&e&lClick &3on a player's name to open the &eQuickAction &3menu");
    line();
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) Nerd(gg.projecteden.nexus.models.nerd.Nerd) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 3 with Nerd

use of gg.projecteden.nexus.models.nerd.Nerd in project Nexus by ProjectEdenGG.

the class TeleportHereCommand method onJoin.

@EventHandler
public void onJoin(PlayerJoinEvent event) {
    Nerd nerd = Nerd.of(event.getPlayer());
    if (nerd.getTeleportOnLogin() == null)
        return;
    // No /back
    event.getPlayer().teleportAsync(nerd.getTeleportOnLogin());
    nerd.setTeleportOnLogin(null);
    new NerdService().save(nerd);
}
Also used : Nerd(gg.projecteden.nexus.models.nerd.Nerd) NerdService(gg.projecteden.nexus.models.nerd.NerdService) EventHandler(org.bukkit.event.EventHandler)

Example 4 with Nerd

use of gg.projecteden.nexus.models.nerd.Nerd in project Nexus by ProjectEdenGG.

the class UUIDSearchCommand method search.

@Path("<uuid> [amount]")
void search(String search, @Arg("25") int limit) {
    if (search.length() < 4)
        error("Please be more specific!");
    // List<Nerd> nerds = service.find(search, "uuid").stream().limit(limit).collect(Collectors.toList());
    List<Nerd> nerds = new ArrayList<>();
    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.getUuid() + " (" + nerd.getName() + ")").insert(nerd.getUuid().toString()));
    send("&3Shift+Click on a name to insert it into your chat");
}
Also used : ArrayList(java.util.ArrayList) Nerd(gg.projecteden.nexus.models.nerd.Nerd) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 5 with Nerd

use of gg.projecteden.nexus.models.nerd.Nerd in project Nexus by ProjectEdenGG.

the class TicketFeature method sendMessage.

private static void sendMessage(Ticket ticket, @Nullable Player staff, String staffName, TicketAction action) {
    String staffNick = staffName;
    if (staff != null)
        staffNick = Nickname.of(staff);
    for (Nerd _staff : Rank.getOnlineStaff()) {
        if (staff == null || !_staff.getUniqueId().equals(staff.getUniqueId()))
            action.sendMessage(_staff.getUniqueId(), ticket, staffNick);
    }
    if (isUUID0(ticket.getUuid()))
        return;
    if (Rank.of(ticket.getUuid()).isStaff())
        return;
    if (!PlayerUtils.canSee(ticket.getPlayer(), staff)) {
        if (action.equals(TicketAction.TELEPORT))
            return;
        staffNick = "A staff member";
    }
    action.sendMessage(ticket.getUuid(), ticket, staffNick);
}
Also used : Nerd(gg.projecteden.nexus.models.nerd.Nerd)

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