Search in sources :

Example 36 with Command

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

the class VigilLookupCommands method lookup.

@Alias(value = "lookup")
@Command(desc = "Performs a lookup.")
public void lookup(Player context, @Named("radius") int radius) {
    LookupData ld = new LookupData();
    Lookup lookup = new Lookup(ld).with(context.getLocation()).withRadius(radius);
    this.qm.queryAndShow(lookup, context);
}
Also used : Lookup(org.cubeengine.module.vigil.Lookup) LookupData(org.cubeengine.module.vigil.data.LookupData) Command(org.cubeengine.butler.parametric.Command) ContainerCommand(org.cubeengine.libcube.service.command.ContainerCommand) Alias(org.cubeengine.butler.alias.Alias)

Example 37 with Command

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

the class IgnoreCommands method ignore.

@Command(desc = "Ignores all messages from players")
public void ignore(CommandSource context, List<User> players) {
    if (!(context instanceof Player)) {
        int rand1 = new Random().nextInt(6) + 1;
        int rand2 = new Random().nextInt(6 - rand1 + 1) + 1;
        i18n.send(context, NEUTRAL, "Ignore ({text:8+:color=WHITE}): {integer#random} + {integer#random} = {integer#sum} -> {text:failed:color=RED}", rand1, rand2, rand1 + rand2);
        return;
    }
    Player sender = ((Player) context);
    List<String> added = new ArrayList<>();
    for (User user : players) {
        if (user == context) {
            i18n.send(context, NEGATIVE, "If you do not feel like talking to yourself just don't talk.");
        } else if (!this.addIgnore(sender, user)) {
            if (user.hasPermission(module.perms().COMMAND_IGNORE_PREVENT.getId())) {
                i18n.send(context, NEGATIVE, "You are not allowed to ignore {user}!", user);
                continue;
            }
            i18n.send(context, NEGATIVE, "{user} is already on your ignore list!", user);
        } else {
            added.add(user.getName());
        }
    }
    if (added.isEmpty()) {
        return;
    }
    i18n.send(context, POSITIVE, "You added {user#list} to your ignore list!", StringUtils.implode(ChatFormat.WHITE + ", " + ChatFormat.DARK_GREEN, added));
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) User(org.spongepowered.api.entity.living.player.User) Random(java.util.Random) ArrayList(java.util.ArrayList) Command(org.cubeengine.butler.parametric.Command)

Example 38 with Command

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

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

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

the class VoteCommands method vote.

@Command(desc = "Shows your current vote situation")
public void vote(CommandSource context) {
    if (!(context instanceof Player)) {
        i18n.send(context, NEUTRAL, "Well you wont get any rewards.");
        if (!module.getConfig().voteUrl.isEmpty()) {
            i18n.send(context, NEUTRAL, "But here go vote anyways: {name#voteurl}", module.getConfig().voteUrl);
        }
        return;
    }
    VoteModel voteModel = db.getDSL().selectFrom(TABLE_VOTE).where(TABLE_VOTE.ID.eq(((Player) context).getUniqueId())).fetchOne();
    if (voteModel == null) {
        i18n.send(context, NEUTRAL, "Sorry but you do not have any registered votes on this server!");
        return;
    }
    i18n.send(context, POSITIVE, "You current vote-count is {amount}", voteModel.getVotes());
    if (voteModel.timePassed(module.getConfig().voteBonusTime.toMillis())) {
        i18n.send(context, NEUTRAL, "Sadly you did not vote in the last {input#time} so your vote-count will be reset to 1", TimeUtil.format(context.getLocale(), module.getConfig().voteBonusTime.toMillis()));
    } else if (voteModel.timePassed(DAYS.toMillis(1))) {
        i18n.send(context, NEUTRAL, "Voting now will increase your consecutive votes and result in higher reward!");
    } else {
        i18n.send(context, POSITIVE, "You voted {input#time} so you will probably not be able to vote again already!", TimeUtil.format(context.getLocale(), new Date(voteModel.getLastVote())));
    }
    if (!module.getConfig().voteUrl.isEmpty()) {
        i18n.send(context, POSITIVE, "You can vote here now: {name#voteurl}", module.getConfig().voteUrl);
    }
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) VoteModel(org.cubeengine.module.vote.storage.VoteModel) Date(java.util.Date) 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