Search in sources :

Example 1 with Path

use of gg.projecteden.nexus.framework.commands.models.annotations.Path 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 Path

use of gg.projecteden.nexus.framework.commands.models.annotations.Path in project Nexus by ProjectEdenGG.

the class BookCommand method edit.

@Path
void edit() {
    checkCanEdit();
    Material type = book.getType() == Material.WRITABLE_BOOK ? Material.WRITTEN_BOOK : Material.WRITABLE_BOOK;
    ItemStack editable = new ItemStack(type, book.getAmount());
    editable.setItemMeta(meta);
    inventory().setItem(hand, editable);
}
Also used : Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 3 with Path

use of gg.projecteden.nexus.framework.commands.models.annotations.Path in project Nexus by ProjectEdenGG.

the class ModReviewCommand method add.

@Permission(Group.ADMIN)
@Path("add <name> <verdict> [notes...]")
void add(String name, ModVerdict verdict, String notes) {
    Mod mod = new Mod(name, verdict, notes);
    modReview.add(mod);
    save();
    send(PREFIX + "Added mod &e" + mod.getName());
}
Also used : Mod(gg.projecteden.nexus.models.modreview.ModReview.Mod) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 4 with Path

use of gg.projecteden.nexus.framework.commands.models.annotations.Path 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 5 with Path

use of gg.projecteden.nexus.framework.commands.models.annotations.Path in project Nexus by ProjectEdenGG.

the class BlockCenterCommand method pitch.

@Path("pitch")
void pitch() {
    Location newLocation = location().clone();
    newLocation.setPitch(centered.getPitch());
    player().teleportAsync(newLocation);
}
Also used : Location(org.bukkit.Location) LocationUtils.getCenteredLocation(gg.projecteden.nexus.utils.LocationUtils.getCenteredLocation) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Aggregations

Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)333 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)110 JsonBuilder (gg.projecteden.nexus.utils.JsonBuilder)51 Async (gg.projecteden.annotations.Async)48 ItemStack (org.bukkit.inventory.ItemStack)38 CommandEvent (gg.projecteden.nexus.framework.commands.models.events.CommandEvent)31 ArrayList (java.util.ArrayList)31 CustomCommand (gg.projecteden.nexus.framework.commands.models.CustomCommand)30 Description (gg.projecteden.nexus.framework.commands.models.annotations.Description)29 List (java.util.List)28 Location (org.bukkit.Location)28 Group (gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group)27 UUID (java.util.UUID)26 Arg (gg.projecteden.nexus.framework.commands.models.annotations.Arg)25 Nerd (gg.projecteden.nexus.models.nerd.Nerd)24 HashMap (java.util.HashMap)24 BiFunction (java.util.function.BiFunction)21 Map (java.util.Map)20 Player (org.bukkit.entity.Player)20 NonNull (lombok.NonNull)18