Search in sources :

Example 1 with Command

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

the class ChatCommands method chatcolors.

@Command(desc = "Displays the colors")
public void chatcolors(CommandSource context) {
    i18n.send(context, POSITIVE, "The following chat codes are available:");
    Builder builder = Text.builder();
    int i = 0;
    for (TextColor color : Sponge.getRegistry().getAllOf(TextColor.class)) {
        if (color == TextColors.NONE) {
            continue;
        }
        if (i++ % 3 == 0) {
            builder.append(Text.NEW_LINE);
        }
        builder.append(Text.of(" ")).append(Text.of(color, color.getName())).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(color)), ")"));
    }
    builder.append(Text.NEW_LINE);
    builder.append(Text.of(" ")).append(Text.of(BOLD, "bold")).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(BOLD)), ")"));
    builder.append(Text.of(" ")).append(Text.of(ITALIC, "italic")).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(ITALIC)), ")"));
    builder.append(Text.of(" ")).append(Text.of(UNDERLINE, "underline")).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(UNDERLINE)), ")"));
    builder.append(Text.NEW_LINE);
    builder.append(Text.of(" ")).append(Text.of(STRIKETHROUGH, "strikethrough")).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(STRIKETHROUGH)), ")"));
    builder.append(Text.of(" ")).append(Text.of(OBFUSCATED, "obfuscated")).append(Text.of(" (", FORMATTING_CODE.serialize(Text.of(OBFUSCATED)), ")"));
    context.sendMessage(builder.build());
}
Also used : Builder(org.spongepowered.api.text.Text.Builder) TextColor(org.spongepowered.api.text.format.TextColor) Command(org.cubeengine.butler.parametric.Command)

Example 2 with Command

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

the class ChatCommands method reply.

@Command(alias = "r", desc = "Replies to the last person that whispered to you.")
public void reply(CommandSource context, @Greed(INFINITE) String message) {
    UUID lastWhisper;
    if (context instanceof Player) {
        lastWhisper = lastWhispers.get(((Player) context).getUniqueId());
    } else {
        lastWhisper = lastWhispers.get(consoleUUID);
    }
    if (lastWhisper == null) {
        i18n.send(context, NEUTRAL, "No one has sent you a message that you could reply to!");
        return;
    }
    CommandSource target;
    if (lastWhisper.equals(consoleUUID)) {
        target = Sponge.getServer().getConsole();
    } else {
        target = Sponge.getServer().getPlayer(lastWhisper).orElse(null);
    }
    if (!this.sendWhisperTo(target, message, context)) {
        i18n.send(context, NEGATIVE, "Could not find the player to reply to. Is the player offline?");
    }
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) UUID(java.util.UUID) CommandSource(org.spongepowered.api.command.CommandSource) Command(org.cubeengine.butler.parametric.Command)

Example 3 with Command

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

the class ManagementCommands method showHelp.

@Command(name = "help", desc = "Prints out all the custom chat commands.")
public void showHelp(CommandSource context) {
    List<Text> list = config.commands.entrySet().stream().map(e -> Text.of("!", e.getKey(), " -> ", e.getValue())).collect(Collectors.toList());
    PaginationList pages = PaginationList.builder().contents(list).build();
    pages.sendTo(context);
}
Also used : I18n(org.cubeengine.libcube.service.i18n.I18n) CommandSource(org.spongepowered.api.command.CommandSource) INFINITE(org.cubeengine.butler.parameter.Parameter.INFINITE) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) POSITIVE(org.cubeengine.libcube.service.i18n.formatter.MessageType.POSITIVE) Collectors(java.util.stream.Collectors) Greed(org.cubeengine.butler.parametric.Greed) Complete(org.cubeengine.butler.parametric.Complete) PaginationList(org.spongepowered.api.service.pagination.PaginationList) Command(org.cubeengine.butler.parametric.Command) List(java.util.List) CommandManager(org.cubeengine.libcube.service.command.CommandManager) Text(org.spongepowered.api.text.Text) NEGATIVE(org.cubeengine.libcube.service.i18n.formatter.MessageType.NEGATIVE) ENGLISH(java.util.Locale.ENGLISH) Flag(org.cubeengine.butler.parametric.Flag) PaginationList(org.spongepowered.api.service.pagination.PaginationList) Text(org.spongepowered.api.text.Text) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) Command(org.cubeengine.butler.parametric.Command)

Example 4 with Command

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

the class InvasionCommand method invasion.

@Command(desc = "Spawns a mob next to every player on the server")
public void invasion(CommandSource context, String mob) {
    EntityType entityType = em.mob(mob, context.getLocale());
    if (entityType == null) {
        i18n.send(context, MessageType.NEGATIVE, "EntityType {input} not found", mob);
        return;
    }
    Sponge.getCauseStackManager().pushCause(context);
    for (Player player : Sponge.getServer().getOnlinePlayers()) {
        Optional<BlockRayHit<World>> end = BlockRay.from(player).stopFilter(BlockRay.onlyAirFilter()).distanceLimit(module.getConfig().command.invasion.distance).build().end();
        if (end.isPresent()) {
            Location<World> location = end.get().getLocation();
            Entity entity = location.getExtent().createEntity(entityType, location.getPosition());
            location.getExtent().spawnEntity(entity);
        }
    }
}
Also used : EntityType(org.spongepowered.api.entity.EntityType) Entity(org.spongepowered.api.entity.Entity) Player(org.spongepowered.api.entity.living.player.Player) World(org.spongepowered.api.world.World) BlockRayHit(org.spongepowered.api.util.blockray.BlockRayHit) Command(org.cubeengine.butler.parametric.Command)

Example 5 with Command

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

the class NukeCommand method nuke.

@Command(desc = "Makes a carpet of TNT fall on a player or where you're looking")
public void nuke(CommandSource context, @Optional Integer diameter, @Named({ "player", "p" }) Player player, @Named({ "height", "h" }) Integer height, @Named({ "range", "r" }) Integer range, @Flag boolean unsafe, @Flag boolean quiet) {
    Location<World> location;
    range = range == null ? 4 : range;
    height = height == null ? 5 : height;
    diameter = diameter == null ? 5 : diameter;
    diameter = Math.min(10, diameter);
    if (range != 4 && !context.hasPermission(module.perms().COMMAND_NUKE_CHANGE_RANGE.getId())) {
        i18n.send(context, NEGATIVE, "You are not allowed to change the explosion range of the nuke carpet!");
        return;
    }
    if (range < 0 || range > this.module.getConfig().command.nuke.maxExplosionRange) {
        i18n.send(context, NEGATIVE, "The explosion range can't be less than 0 or greater than {integer}", this.module.getConfig().command.nuke.maxExplosionRange);
        return;
    }
    if (player != null) {
        if (!context.equals(player) && !context.hasPermission(module.perms().COMMAND_NUKE_OTHER.getId())) {
            i18n.send(context, NEGATIVE, "You are not allowed to specify a player!");
            return;
        }
        location = ((Player) context).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)).stopFilter(onlyAirFilter()).distanceLimit(100).build().end();
        if (!end.isPresent()) {
            throw new IllegalStateException();
        }
        location = end.get().getLocation();
    }
    location = this.getSpawnLocation(location, height);
    Shape aShape = new Cuboid(new Vector3d(location.getX() + .5, location.getY() + .5, location.getZ() + .5), diameter, 1, diameter);
    int blockAmount = this.spawnNuke(aShape, location.getExtent(), range, unsafe);
    if (!quiet) {
        i18n.send(context, POSITIVE, "You spawned {integer} blocks of tnt.", blockAmount);
    }
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) Shape(org.cubeengine.libcube.util.math.shape.Shape) Vector3d(com.flowpowered.math.vector.Vector3d) Cuboid(org.cubeengine.libcube.util.math.shape.Cuboid) World(org.spongepowered.api.world.World) BlockRayHit(org.spongepowered.api.util.blockray.BlockRayHit) 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