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());
}
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);
}
Aggregations