Search in sources :

Example 1 with Announcement

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;
}
Also used : Locale(java.util.Locale) Announcement(org.cubeengine.module.shout.announce.Announcement) TranslatedParserException(org.cubeengine.libcube.service.command.TranslatedParserException) Text(org.spongepowered.api.text.Text)

Example 2 with 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()));
    }
}
Also used : Announcement(org.cubeengine.module.shout.announce.Announcement) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) Command(org.cubeengine.butler.parametric.Command) Alias(org.cubeengine.butler.alias.Alias)

Example 3 with Announcement

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;
}
Also used : Announcement(org.cubeengine.module.shout.announce.Announcement) ArrayList(java.util.ArrayList)

Aggregations

Announcement (org.cubeengine.module.shout.announce.Announcement)3 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 Alias (org.cubeengine.butler.alias.Alias)1 Command (org.cubeengine.butler.parametric.Command)1 ContainerCommand (org.cubeengine.libcube.service.command.ContainerCommand)1 TranslatedParserException (org.cubeengine.libcube.service.command.TranslatedParserException)1 Text (org.spongepowered.api.text.Text)1