Search in sources :

Example 21 with Description

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

the class RadioCommand method configAddSong.

@Path("config addSong <radio> <song>")
@Description("Add a song to a radio")
@Permission(Group.ADMIN)
void configAddSong(Radio radio, @Arg(type = RadioSong.class) List<RadioSong> radioSongs) {
    for (RadioSong radioSong : radioSongs) config.addSong(radio, radioSong);
    configService.save(config);
    send(PREFIX + "Added " + radioSongs.stream().map(RadioSong::getName).collect(Collectors.joining(", ")) + " to " + radio.getId());
}
Also used : RadioSong(gg.projecteden.nexus.models.radio.RadioConfig.RadioSong) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 22 with Description

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

the class CustomCommand method help.

@Path("help")
protected void help() {
    List<String> aliases = getAllAliases();
    if (aliases.size() > 1)
        send(PREFIX + "Aliases: " + String.join("&e, &3", aliases));
    List<JsonBuilder> lines = new ArrayList<>();
    final List<Method> methods = getPathMethods(event).stream().filter(method -> {
        Path path = method.getAnnotation(Path.class);
        HideFromHelp hide = method.getAnnotation(HideFromHelp.class);
        if (hide != null)
            return false;
        if ("help".equals(path.value()) || "?".equals(path.value()))
            return false;
        return true;
    }).toList();
    methods.forEach(method -> {
        Path path = method.getAnnotation(Path.class);
        Description desc = method.getAnnotation(Description.class);
        if (methods.size() == 1 && desc == null)
            desc = this.getClass().getAnnotation(Description.class);
        String usage = "/" + getAliasUsed().toLowerCase() + " " + (isNullOrEmpty(path.value()) ? "" : path.value());
        String description = (desc == null ? "" : " &7- " + desc.value());
        StringBuilder suggestion = new StringBuilder();
        for (String word : usage.split(" ")) {
            if (word.startsWith("[") || word.startsWith("<"))
                break;
            if (word.startsWith("("))
                suggestion.append(trimFirst(word.split("\\|")[0]));
            else
                suggestion.append(word).append(" ");
        }
        lines.add(json("&c" + usage + description).suggest(suggestion.toString()));
    });
    if (lines.size() == 0)
        error("No usage available");
    send(PREFIX + "Usage:");
    lines.forEach(this::send);
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) Arrays(java.util.Arrays) MongoPlayerService(gg.projecteden.nexus.framework.persistence.mongodb.player.MongoPlayerService) StringUtils(gg.projecteden.nexus.utils.StringUtils) SneakyThrows(lombok.SneakyThrows) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) Enchantment(org.bukkit.enchantments.Enchantment) BiFunction(java.util.function.BiFunction) StringUtils.trimFirst(gg.projecteden.nexus.utils.StringUtils.trimFirst) RequiredArgsConstructor(lombok.RequiredArgsConstructor) ConverterFor(gg.projecteden.nexus.framework.commands.models.annotations.ConverterFor) Player(org.bukkit.entity.Player) CommandRunEvent(gg.projecteden.nexus.framework.commands.models.events.CommandRunEvent) Nullables.isNullOrEmpty(gg.projecteden.nexus.utils.Nullables.isNullOrEmpty) PlayerUtils(gg.projecteden.nexus.utils.PlayerUtils) MustBeCommandBlockException(gg.projecteden.nexus.framework.exceptions.preconfigured.MustBeCommandBlockException) Block(org.bukkit.block.Block) Location(org.bukkit.Location) MaterialTag(gg.projecteden.nexus.utils.MaterialTag) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) World(org.bukkit.World) PlayerInventory(org.bukkit.inventory.PlayerInventory) Nickname(gg.projecteden.nexus.models.nickname.Nickname) Method(java.lang.reflect.Method) Timespan(gg.projecteden.utils.TimeUtils.Timespan) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) Bukkit(org.bukkit.Bukkit) Sign(org.bukkit.block.Sign) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) CommandSender(org.bukkit.command.CommandSender) NoPermissionException(gg.projecteden.nexus.framework.exceptions.preconfigured.NoPermissionException) Nerd(gg.projecteden.nexus.models.nerd.Nerd) Entity(org.bukkit.entity.Entity) Rank(gg.projecteden.nexus.models.nerd.Rank) NonNull(lombok.NonNull) Collection(java.util.Collection) HideFromHelp(gg.projecteden.nexus.framework.commands.models.annotations.HideFromHelp) UUID(java.util.UUID) PlayerNotFoundException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException) EntityType(org.bukkit.entity.EntityType) LivingEntity(org.bukkit.entity.LivingEntity) ItemUtils(gg.projecteden.nexus.utils.ItemUtils) NamedTextColor(net.kyori.adventure.text.format.NamedTextColor) OfflinePlayer(org.bukkit.OfflinePlayer) ItemStack(org.bukkit.inventory.ItemStack) Objects(java.util.Objects) Switch(gg.projecteden.nexus.framework.commands.models.annotations.Switch) Contract(org.jetbrains.annotations.Contract) List(java.util.List) Stream(java.util.stream.Stream) LocalDate(java.time.LocalDate) Fallback(gg.projecteden.nexus.framework.commands.models.annotations.Fallback) NerdService(gg.projecteden.nexus.models.nerd.NerdService) TabCompleterFor(gg.projecteden.nexus.framework.commands.models.annotations.TabCompleterFor) OnlinePlayers(gg.projecteden.nexus.utils.PlayerUtils.OnlinePlayers) Pattern(java.util.regex.Pattern) MultiCommandCommand(gg.projecteden.nexus.features.commands.staff.MultiCommandCommand) NotNull(org.jetbrains.annotations.NotNull) PlayerOwnedObject(gg.projecteden.interfaces.PlayerOwnedObject) WorldEditUtils(gg.projecteden.nexus.utils.WorldEditUtils) Getter(lombok.Getter) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) PlayerManager(gg.projecteden.nexus.features.minigames.managers.PlayerManager) LocalDateTime(java.time.LocalDateTime) TimeUtils.parseDateTime(gg.projecteden.utils.TimeUtils.parseDateTime) ComponentLike(net.kyori.adventure.text.ComponentLike) ColorType(gg.projecteden.nexus.utils.ColorType) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) InvalidInputException(gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) RandomUtils(gg.projecteden.nexus.utils.RandomUtils) Component(net.kyori.adventure.text.Component) Parameter(java.lang.reflect.Parameter) WorldGroup(gg.projecteden.nexus.utils.WorldGroup) MustBeIngameException(gg.projecteden.nexus.framework.exceptions.preconfigured.MustBeIngameException) LinkedList(java.util.LinkedList) WorldGuardUtils(gg.projecteden.nexus.utils.WorldGuardUtils) ChatColor(net.md_5.bungee.api.ChatColor) NamespacedKey(org.bukkit.NamespacedKey) UUIDUtils(gg.projecteden.utils.UUIDUtils) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer) StringUtils.an(gg.projecteden.nexus.utils.StringUtils.an) TimeUtils.parseDate(gg.projecteden.utils.TimeUtils.parseDate) Collectors.toList(java.util.stream.Collectors.toList) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) BlockCommandSender(org.bukkit.command.BlockCommandSender) PlayerNotOnlineException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotOnlineException) BlockedInMinigamesException(gg.projecteden.nexus.framework.exceptions.preconfigured.BlockedInMinigamesException) Nullables.isNullOrAir(gg.projecteden.nexus.utils.Nullables.isNullOrAir) AllArgsConstructor(lombok.AllArgsConstructor) MustBeConsoleException(gg.projecteden.nexus.framework.exceptions.preconfigured.MustBeConsoleException) Collections(java.util.Collections) NoArgsConstructor(lombok.NoArgsConstructor) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) HideFromHelp(gg.projecteden.nexus.framework.commands.models.annotations.HideFromHelp) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Aggregations

Description (gg.projecteden.nexus.framework.commands.models.annotations.Description)22 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)21 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)7 LocalDate (java.time.LocalDate)5 JsonBuilder (gg.projecteden.nexus.utils.JsonBuilder)4 ItemStack (org.bukkit.inventory.ItemStack)4 RadioUtils.getListenedRadio (gg.projecteden.nexus.features.radio.RadioUtils.getListenedRadio)3 RadioUtils.isInRangeOfRadiusRadio (gg.projecteden.nexus.features.radio.RadioUtils.isInRangeOfRadiusRadio)3 Radio (gg.projecteden.nexus.models.radio.RadioConfig.Radio)3 Player (org.bukkit.entity.Player)3 AdventChest (gg.projecteden.nexus.features.events.y2020.pugmas20.models.AdventChest)2 ConverterFor (gg.projecteden.nexus.framework.commands.models.annotations.ConverterFor)2 Switch (gg.projecteden.nexus.framework.commands.models.annotations.Switch)2 TabCompleterFor (gg.projecteden.nexus.framework.commands.models.annotations.TabCompleterFor)2 CommandEvent (gg.projecteden.nexus.framework.commands.models.events.CommandEvent)2 Nerd (gg.projecteden.nexus.models.nerd.Nerd)2 Rank (gg.projecteden.nexus.models.nerd.Rank)2 Nickname (gg.projecteden.nexus.models.nickname.Nickname)2 RadioSong (gg.projecteden.nexus.models.radio.RadioConfig.RadioSong)2 PlayerUtils (gg.projecteden.nexus.utils.PlayerUtils)2