Search in sources :

Example 6 with Restricted

use of org.cubeengine.butler.filter.Restricted in project modules-extra by CubeEngine.

the class PowertoolCommand method list.

@Alias(value = "ptl")
@Command(desc = "Lists your powertool-bindings.")
@Restricted(value = Player.class, msg = "You already have enough power!")
public void list(Player context, @Flag boolean all) {
    if (all) {
        for (Inventory slot : context.getInventory().slots()) {
            if (slot.peek().isPresent()) {
                ItemStack item = slot.peek().get();
                PowertoolData data = item.get(PowertoolData.class).orElse(null);
                if (data != null) {
                    context.sendMessage(Text.of(GOLD, data.get(Keys.DISPLAY_NAME).orElse(Text.of(materialMatcher.getNameFor(item))), GOLD, ":"));
                    showPowerToolList(context, this.getPowerTools(item), false, false);
                }
            }
        }
        return;
    }
    if (!context.getItemInHand(HandTypes.MAIN_HAND).isPresent()) {
        i18n.send(context, NEUTRAL, "You do not have an item in your hand.");
    } else {
        this.showPowerToolList(context, this.getPowerTools(context.getItemInHand(HandTypes.MAIN_HAND).get()), false, true);
    }
}
Also used : PowertoolData(org.cubeengine.module.powertools.data.PowertoolData) IPowertoolData(org.cubeengine.module.powertools.data.IPowertoolData) ItemStack(org.spongepowered.api.item.inventory.ItemStack) Inventory(org.spongepowered.api.item.inventory.Inventory) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) Command(org.cubeengine.butler.parametric.Command) Restricted(org.cubeengine.butler.filter.Restricted) Alias(org.cubeengine.butler.alias.Alias)

Example 7 with Restricted

use of org.cubeengine.butler.filter.Restricted in project modules-extra by CubeEngine.

the class PowertoolCommand method clear.

@Alias(value = "ptc")
@Command(desc = "Removes all commands from your powertool")
@Restricted(value = Player.class, msg = "No more power for you!")
public void clear(Player context, @Flag boolean all) {
    if (all) {
        for (Inventory slot : context.getInventory().slots()) {
            if (slot.peek().isPresent()) {
                slot.set(this.setPowerTool(slot.peek().get(), null));
            }
        }
        i18n.send(context, POSITIVE, "Removed all commands bound to items in your inventory!");
        return;
    }
    if (!context.getItemInHand(HandTypes.MAIN_HAND).isPresent()) {
        i18n.send(context, NEUTRAL, "You are not holding any item in your hand.");
        return;
    }
    context.setItemInHand(HandTypes.MAIN_HAND, this.setPowerTool(context.getItemInHand(HandTypes.MAIN_HAND).get(), null));
    i18n.send(context, POSITIVE, "Removed all commands bound to the item in your hand!");
}
Also used : Inventory(org.spongepowered.api.item.inventory.Inventory) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) Command(org.cubeengine.butler.parametric.Command) Restricted(org.cubeengine.butler.filter.Restricted) Alias(org.cubeengine.butler.alias.Alias)

Example 8 with Restricted

use of org.cubeengine.butler.filter.Restricted in project modules-extra by CubeEngine.

the class LogCommands method tool.

@Alias(value = "lt")
@Command(desc = "Gives you an item to check logs with.\n" + "no log-type: Shows everything\n" + "chest: Shows chest-interactions only\n" + "player: Shows player-interacions only\n" + "kills: Shows kill-interactions only\n" + "block: Shows block-changes only")
@Restricted(value = User.class, msg = "Why don't you check in your log-file? You won't need a block there!")
public void tool(User context, @Optional @Label("log-type") String logType) {
    // TODO tabcompleter for logToolTypes (waiting for CE-389)
    Material blockMaterial = this.matchType(logType, false);
    if (blockMaterial == null) {
        context.sendTranslated(NEGATIVE, "{input} is not a valid log-type. Use chest, container, player, block or kills instead!", logType);
        return;
    }
    this.findLogTool(context, blockMaterial);
}
Also used : Material(org.bukkit.Material) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) Command(org.cubeengine.butler.parametric.Command) Restricted(org.cubeengine.butler.filter.Restricted) Alias(org.cubeengine.butler.alias.Alias)

Example 9 with Restricted

use of org.cubeengine.butler.filter.Restricted in project modules-extra by CubeEngine.

the class LogCommands method block.

@Alias(value = "lb")
@Command(desc = "Gives you a block to check logs with." + "no log-type: Shows everything\n" + "chest: Shows chest-interactions only\n" + "player: Shows player-interacions only\n" + "kills: Shows kill-interactions only\n" + "block: Shows block-changes only")
@Restricted(value = User.class, msg = "Why don't you check in your log-file? You won't need a block there!")
public void block(User context, @Optional @Label("log-type") String logType) {
    // TODO tabcompleter for logBlockTypes (waiting for CE-389)
    Material blockMaterial = this.matchType(logType, true);
    if (blockMaterial == null) {
        context.sendTranslated(NEGATIVE, "{input} is not a valid log-type. Use chest, container, player, block or kills instead!", logType);
        return;
    }
    this.findLogTool(context, blockMaterial);
}
Also used : Material(org.bukkit.Material) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) Command(org.cubeengine.butler.parametric.Command) Restricted(org.cubeengine.butler.filter.Restricted) Alias(org.cubeengine.butler.alias.Alias)

Aggregations

Restricted (org.cubeengine.butler.filter.Restricted)9 Command (org.cubeengine.butler.parametric.Command)9 ContainerCommand (org.cubeengine.libcube.service.command.ContainerCommand)5 Alias (org.cubeengine.butler.alias.Alias)4 Inventory (org.spongepowered.api.item.inventory.Inventory)3 ArrayList (java.util.ArrayList)2 Material (org.bukkit.Material)2 ItemStack (org.spongepowered.api.item.inventory.ItemStack)2 Instant (java.time.Instant)1 CommandPermission (org.cubeengine.libcube.service.command.annotation.CommandPermission)1 Unloggable (org.cubeengine.libcube.service.command.annotation.Unloggable)1 ConversationCommand (org.cubeengine.libcube.service.command.conversation.ConversationCommand)1 PermissionDeniedException (org.cubeengine.libcube.service.command.exception.PermissionDeniedException)1 IPowertoolData (org.cubeengine.module.powertools.data.IPowertoolData)1 PowertoolData (org.cubeengine.module.powertools.data.PowertoolData)1 IMarketSignData (org.cubeengine.module.signmarket.data.IMarketSignData)1 ImmutableMarketSignData (org.cubeengine.module.signmarket.data.ImmutableMarketSignData)1 MarketSignData (org.cubeengine.module.signmarket.data.MarketSignData)1 EntityType (org.spongepowered.api.entity.EntityType)1 User (org.spongepowered.api.entity.living.player.User)1