use of org.cubeengine.module.shout.announce.Announcement in project modules-extra by CubeEngine.
the class AnnouncementParser method parse.
@Override
public Announcement parse(Class clazz, CommandInvocation invocation) throws ParserException {
String name = invocation.consume(1);
Announcement announcement = manager.getAnnouncement(name);
if (announcement == null) {
Text trans = i18n.translate(invocation.getContext(Locale.class), NEGATIVE, "{input#announcement} was not found!", name);
throw new TranslatedParserException(trans);
}
return announcement;
}
use of org.cubeengine.module.shout.announce.Announcement in project modules-extra by CubeEngine.
the class ShoutCommand method list.
@Alias(value = { "announcements" })
@Command(alias = "announcements", desc = "List all announcements")
public void list(CommandSource context) {
Collection<Announcement> list = this.module.getManager().getAllAnnouncements();
if (list.isEmpty()) {
i18n.send(context, NEGATIVE, "There are no announcements loaded!");
return;
}
i18n.send(context, POSITIVE, "Here is the list of announcements:");
for (Announcement announcement : list) {
context.sendMessage(Text.of(" - ", announcement.getName()));
}
}
use of org.cubeengine.module.shout.announce.Announcement in project modules-extra by CubeEngine.
the class AnnouncementParser method suggest.
@Override
public List<String> suggest(Class type, CommandInvocation invocation) {
List<String> list = new ArrayList<>();
String token = invocation.currentToken();
for (Announcement announcement : manager.getAllAnnouncements()) {
if (announcement.getName().startsWith(token)) {
list.add(announcement.getName());
}
}
return list;
}
Aggregations