Search in sources :

Example 26 with Command

use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.

the class VigilAdminCommands method setReportActive.

@Command(desc = "enables or disables reports in a world")
public // TODO completer
void setReportActive(// TODO completer
CommandSource ctx, // TODO completer
World world, // TODO completer
String name, // TODO completer
@Default boolean enable) {
    Class<? extends Report> report = "*".equals(name) ? Report.class : Report.getReport(name).orElse(null);
    if (report == null) {
        // TODO suggest?
        i18n.send(ctx, NEGATIVE, "Unknown Report: {name}", name);
        return;
    }
    List<String> list = module.getConfig().disabledReports.computeIfAbsent(new ConfigWorld(world), w -> new ArrayList<>());
    if (enable) {
        i18n.send(ctx, POSITIVE, "Report {name} is now enabled in {world}", name, world);
        list.remove(name);
    } else {
        i18n.send(ctx, POSITIVE, "Report {name} is now disabled in {world}", name, world);
        list.add(name);
    }
    module.getConfig().markDirty(world);
    module.getConfig().save();
}
Also used : ConfigWorld(org.cubeengine.libcube.service.config.ConfigWorld) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) Command(org.cubeengine.butler.parametric.Command)

Example 27 with Command

use of org.cubeengine.butler.parametric.Command 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 28 with Command

use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.

the class EditModeCommand method copy.

@Restricted(Player.class)
@Command(desc = "Copies the settings from the previous sign")
public void copy(Player context) {
    ImmutableMarketSignData data = manager.getPreviousData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No previous market sign");
        return;
    }
    if (data.getOwner().equals(IMarketSignData.ADMIN_SIGN)) {
        if (!context.hasPermission(module.perms().EDIT_ADMIN.getId())) {
            throw new PermissionDeniedException(module.perms().EDIT_ADMIN);
        }
    } else {
        if (!context.hasPermission(module.perms().EDIT_USE.getId())) {
            throw new PermissionDeniedException(module.perms().EDIT_USE);
        }
    }
    MarketSignData copy = data.asMutable();
    if (!copy.isAdminOwner()) {
        copy.setStock(0);
    }
    Location<World> loc = manager.updateData(copy, context);
    manager.executeShowInfo(copy, context, loc);
}
Also used : ImmutableMarketSignData(org.cubeengine.module.signmarket.data.ImmutableMarketSignData) MarketSignData(org.cubeengine.module.signmarket.data.MarketSignData) IMarketSignData(org.cubeengine.module.signmarket.data.IMarketSignData) ImmutableMarketSignData(org.cubeengine.module.signmarket.data.ImmutableMarketSignData) PermissionDeniedException(org.cubeengine.libcube.service.command.exception.PermissionDeniedException) World(org.spongepowered.api.world.World) Restricted(org.cubeengine.butler.filter.Restricted) Command(org.cubeengine.butler.parametric.Command) ConversationCommand(org.cubeengine.libcube.service.command.conversation.ConversationCommand)

Example 29 with Command

use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.

the class EditModeCommand method setstock.

@Command(desc = "Sets the signs stock")
public void setstock(Player context, Integer amount) {
    MarketSignData data = manager.getCurrentData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No active sign!");
        return;
    }
    if (data.getStock() == null) {
        i18n.send(context, NEGATIVE, "This sign has no stock! Use \"stock\" first to enable it!");
        return;
    }
    data.setStock(amount);
    Location<World> loc = manager.updateData(data, context);
    manager.executeShowInfo(data, context, loc);
}
Also used : MarketSignData(org.cubeengine.module.signmarket.data.MarketSignData) IMarketSignData(org.cubeengine.module.signmarket.data.IMarketSignData) ImmutableMarketSignData(org.cubeengine.module.signmarket.data.ImmutableMarketSignData) World(org.spongepowered.api.world.World) Command(org.cubeengine.butler.parametric.Command) ConversationCommand(org.cubeengine.libcube.service.command.conversation.ConversationCommand)

Example 30 with Command

use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.

the class EditModeCommand method player.

@Command(desc = "Changes the sign to an player-sign")
public void player(Player context) {
    if (!context.hasPermission(module.perms().EDIT_PLAYER_SELF.getId())) {
        throw new PermissionDeniedException(module.perms().EDIT_PLAYER_SELF);
    }
    MarketSignData data = manager.getCurrentData(context);
    if (data == null) {
        i18n.send(context, NEGATIVE, "No active sign!");
        return;
    }
    if (data.isAdminOwner()) {
        data.setSize(6);
    }
    data.setOwner(context.getUniqueId());
    data.setStock(0);
    Location<World> loc = manager.updateData(data, context);
    manager.executeShowInfo(data, context, loc);
}
Also used : MarketSignData(org.cubeengine.module.signmarket.data.MarketSignData) IMarketSignData(org.cubeengine.module.signmarket.data.IMarketSignData) ImmutableMarketSignData(org.cubeengine.module.signmarket.data.ImmutableMarketSignData) PermissionDeniedException(org.cubeengine.libcube.service.command.exception.PermissionDeniedException) World(org.spongepowered.api.world.World) Command(org.cubeengine.butler.parametric.Command) ConversationCommand(org.cubeengine.libcube.service.command.conversation.ConversationCommand)

Aggregations

Command (org.cubeengine.butler.parametric.Command)46 World (org.spongepowered.api.world.World)18 ContainerCommand (org.cubeengine.libcube.service.command.ContainerCommand)14 ConversationCommand (org.cubeengine.libcube.service.command.conversation.ConversationCommand)14 IMarketSignData (org.cubeengine.module.signmarket.data.IMarketSignData)14 ImmutableMarketSignData (org.cubeengine.module.signmarket.data.ImmutableMarketSignData)14 MarketSignData (org.cubeengine.module.signmarket.data.MarketSignData)14 Player (org.spongepowered.api.entity.living.player.Player)11 Alias (org.cubeengine.butler.alias.Alias)10 Restricted (org.cubeengine.butler.filter.Restricted)9 PermissionDeniedException (org.cubeengine.libcube.service.command.exception.PermissionDeniedException)5 ItemStack (org.spongepowered.api.item.inventory.ItemStack)5 Language (de.cubeisland.engine.i18n.language.Language)4 Inventory (org.spongepowered.api.item.inventory.Inventory)4 BlockRayHit (org.spongepowered.api.util.blockray.BlockRayHit)4 ArrayList (java.util.ArrayList)3 Locale (java.util.Locale)3 Text (org.spongepowered.api.text.Text)3 Vector3d (com.flowpowered.math.vector.Vector3d)2 IOException (java.io.IOException)2