Search in sources :

Example 41 with Command

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

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

Example 43 with Command

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

the class PlayerCommands method explosion.

@Command(desc = "Creates an explosion")
public void explosion(CommandSource context, @Optional Integer damage, @Named({ "player", "p" }) Player player, @Flag boolean unsafe, @Flag boolean fire, @Flag boolean blockDamage, @Flag boolean playerDamage) {
    damage = damage == null ? 1 : damage;
    if (damage > this.module.getConfig().command.explosion.power) {
        i18n.send(context, NEGATIVE, "The power of the explosion shouldn't be greater than {integer}", this.module.getConfig().command.explosion.power);
        return;
    }
    Location<World> loc;
    if (player != null) {
        if (!context.equals(player)) {
            if (!context.hasPermission(module.perms().COMMAND_EXPLOSION_OTHER.getId())) {
                i18n.send(context, NEGATIVE, "You are not allowed to specify a player.");
                return;
            }
        }
        loc = player.getLocation();
    } else {
        if (!(context instanceof Player)) {
            i18n.send(context, NEGATIVE, "This command can only be used by a player!");
            return;
        }
        java.util.Optional<BlockRayHit<World>> end = BlockRay.from(((Player) context)).distanceLimit(module.getConfig().command.explosion.distance).stopFilter(BlockRay.onlyAirFilter()).build().end();
        if (end.isPresent()) {
            loc = end.get().getLocation();
        } else {
            throw new IllegalStateException();
        }
    }
    if (!context.hasPermission(module.perms().COMMAND_EXPLOSION_BLOCK_DAMAGE.getId()) && (blockDamage || unsafe)) {
        i18n.send(context, NEGATIVE, "You are not allowed to break blocks");
        return;
    }
    if (!context.hasPermission(module.perms().COMMAND_EXPLOSION_FIRE.getId()) && (fire || unsafe)) {
        i18n.send(context, NEGATIVE, "You are not allowed to set fireticks");
        return;
    }
    if (!context.hasPermission(module.perms().COMMAND_EXPLOSION_PLAYER_DAMAGE.getId()) && (playerDamage || unsafe)) {
        i18n.send(context, NEGATIVE, "You are not allowed to damage another player");
        return;
    }
    Explosion explosion = Explosion.builder().location(loc).canCauseFire(fire || unsafe).shouldDamageEntities(playerDamage || unsafe).shouldBreakBlocks(blockDamage || unsafe).build();
    Sponge.getCauseStackManager().pushCause(context);
    loc.getExtent().triggerExplosion(explosion);
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) Explosion(org.spongepowered.api.world.explosion.Explosion) World(org.spongepowered.api.world.World) BlockRayHit(org.spongepowered.api.util.blockray.BlockRayHit) Command(org.cubeengine.butler.parametric.Command)

Example 44 with Command

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

the class PlayerCommands method hat.

@Command(desc = "Gives a player a hat")
public void hat(CommandSource context, @Optional String item, @Named({ "player", "p" }) Player player, @Flag boolean quiet) {
    ItemStack head;
    if (player != null) {
        if (!context.hasPermission(module.perms().COMMAND_HAT_OTHER.getId())) {
            i18n.send(context, NEGATIVE, "You can't set the hat of an other player.");
            return;
        }
    } else if (context instanceof Player) {
        player = (Player) context;
    } else {
        i18n.send(context, NEGATIVE, "You have to specify a player!");
        return;
    }
    if (item != null) {
        if (!context.hasPermission(module.perms().COMMAND_HAT_ITEM.getId())) {
            i18n.send(context, NEGATIVE, "You can only use your item in hand!");
            return;
        }
        head = materialMatcher.itemStack(item);
        if (head == null) {
            i18n.send(context, NEGATIVE, "Item not found!");
            return;
        }
    } else if (context instanceof Player) {
        head = ((Player) context).getItemInHand(MAIN_HAND).orElse(null);
    } else {
        i18n.send(context, NEGATIVE, "Trying to be Notch? No hat for you!");
        i18n.send(context, NEUTRAL, "Please specify an item!");
        return;
    }
    if (head == null) {
        i18n.send(context, NEGATIVE, "You do not have any item in your hand!");
        return;
    }
    EquipmentType type = head.getType().getDefaultProperty(EquipmentProperty.class).map(EquipmentProperty::getValue).orElse(null);
    if (type == null || type != EquipmentTypes.HEADWEAR) {
        if (!context.hasPermission(module.perms().COMMAND_HAT_MORE_ARMOR.getId())) {
            i18n.send(context, NEGATIVE, "You are not allowed to use other armor as headpiece");
            return;
        }
    }
    head.setQuantity(1);
    if (item == null && context instanceof Player) {
        ItemStack clone = head.copy();
        clone.setQuantity(head.getQuantity() - 1);
        ((Player) context).setItemInHand(MAIN_HAND, clone);
    }
    if (player.getHelmet().isPresent()) {
        player.getInventory().offer(player.getHelmet().get());
    }
    player.setHelmet(head);
    if (!(quiet && context.hasPermission(module.perms().COMMAND_HAT_QUIET.getId())) && player.hasPermission(module.perms().COMMAND_HAT_NOTIFY.getId())) {
        i18n.send(player, POSITIVE, "Your hat was changed");
    }
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) ItemStack(org.spongepowered.api.item.inventory.ItemStack) EquipmentType(org.spongepowered.api.item.inventory.equipment.EquipmentType) Command(org.cubeengine.butler.parametric.Command)

Example 45 with Command

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

the class HideCommands method listhiddens.

@Command(desc = "Lists all hidden players.")
public void listhiddens(CommandSource context) throws ExecutionException, InterruptedException {
    Set<UUID> hiddens = this.module.getHiddenUsers();
    if (hiddens.isEmpty()) {
        i18n.send(context, NEUTRAL, "There are no hidden users!");
        return;
    }
    i18n.send(context, POSITIVE, "The following users are hidden:");
    for (UUID uuid : hiddens) {
        context.sendMessage(Text.of(" - ", YELLOW, Sponge.getServer().getGameProfileManager().get(uuid).get().getName().orElse("???")));
    }
}
Also used : UUID(java.util.UUID) Command(org.cubeengine.butler.parametric.Command)

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