com.sk89q.minecraft.util.commands.CommandContext Java Examples

The following examples show how to use com.sk89q.minecraft.util.commands.CommandContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenerationCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"/ore"},
        usage = "<mask> <pattern> <size> <freq> <rarity> <minY> <maxY>",
        desc = "Generates ores",
        help = "Generates ores",
        min = 7,
        max = 7
)
@CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT)
public void ore(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, CommandContext context) throws WorldEditException, ParameterException {
    player.checkConfirmationRegion(() -> {
        editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
        BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
    }, getArguments(context), region, context);
}
 
Example #2
Source File: AdminCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"postponerestart", "pr"},
        usage = "[matches]",
        desc = "Cancels any queued restarts and postpones automatic restart to at least " +
               "the given number of matches from now (default and maximum is 10).",
        min = 0,
        max = 1
)
@CommandPermissions("server.cancelrestart")
@Console
public void postponeRestart(CommandContext args, CommandSender sender) throws CommandException {
    final Integer matches = restartListener.restartAfterMatches(CommandUtils.getMatch(sender), args.getInteger(0, 10));
    if(matches == null) {
        restartManager.cancelRestart();
        sender.sendMessage(ChatColor.RED + "Automatic match count restart disabled");
    } else if(matches > 0) {
        restartManager.cancelRestart();
        sender.sendMessage(ChatColor.RED + "Server will restart automatically in " + matches + " matches");
    } else if(matches == 0) {
        sender.sendMessage(ChatColor.RED + "Server will restart automatically after the current match");
    }
}
 
Example #3
Source File: GenerationCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"/hsphere"},
        usage = "<pattern> <radius>[,<radius>,<radius>] [raised?]",
        desc = "Generates a hollow sphere.",
        help =
                "Generates a hollow sphere.\n" +
                        "By specifying 3 radii, separated by commas,\n" +
                        "you can generate an ellipsoid. The order of the ellipsoid radii\n" +
                        "is north/south, up/down, east/west.",
        min = 2,
        max = 3
)
@CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT)
public void hsphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector radius, @Optional("false") boolean raised, CommandContext context) throws WorldEditException, ParameterException {
    sphere(fp, player, session, editSession, pattern, radius, raised, true, context);
}
 
Example #4
Source File: SelectionCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
private Vector[] getChangesForEachDir(CommandContext args) {
    List<Vector> changes = new ArrayList<Vector>(6);
    int change = args.getInteger(0);

    if (!args.hasFlag('h')) {
        changes.add((new Vector(0, 1, 0)).multiply(change));
        changes.add((new Vector(0, -1, 0)).multiply(change));
    }

    if (!args.hasFlag('v')) {
        changes.add((new Vector(1, 0, 0)).multiply(change));
        changes.add((new Vector(-1, 0, 0)).multiply(change));
        changes.add((new Vector(0, 0, 1)).multiply(change));
        changes.add((new Vector(0, 0, -1)).multiply(change));
    }

    return changes.toArray(new Vector[0]);
}
 
Example #5
Source File: BrushOptionsCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"secondary"},
        usage = "[brush-arguments]",
        desc = "Set the left click brush",
        help = "Set the left click brush",
        min = 1
)
public void secondary(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    BaseBlock item = player.getBlockInHand();
    BrushTool tool = session.getBrushTool(player, false);
    session.setTool(item, null, player);
    String cmd = "brush " + args.getJoinedStrings(0);
    CommandEvent event = new CommandEvent(player, cmd);
    CommandManager.getInstance().handleCommandOnCurrentThread(event);
    BrushTool newTool = session.getBrushTool(item, player, false);
    if (newTool != null && tool != null) {
        newTool.setPrimary(tool.getPrimary());
    }
}
 
Example #6
Source File: StartAndEndCommand.java    From CardinalPGM with MIT License 6 votes vote down vote up
@Command(aliases = {"end", "finish"}, desc = "Ends the match.", usage = "[team]", flags = "n")
@CommandPermissions("cardinal.match.end")
public static void end(CommandContext cmd, CommandSender sender) throws CommandException {
    if (!GameHandler.getGameHandler().getMatch().isRunning()) {
        throw new CommandException(ChatConstant.ERROR_NO_END.getMessage(ChatUtil.getLocale(sender)));
    }
    if (cmd.argsLength() > 0) {
        Optional<TeamModule> team = Teams.getTeamByName(cmd.getString(0));
        GameHandler.getGameHandler().getMatch().end(team.orNull());
    } else {
        if (cmd.hasFlag('n')) {
            GameHandler.getGameHandler().getMatch().end();
        } else {
            GameHandler.getGameHandler().getMatch().end(TimeLimit.getMatchWinner());
        }
    }
}
 
Example #7
Source File: ChunkCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"chunkinfo"},
        usage = "",
        desc = "Get information about the chunk that you are inside",
        min = 0,
        max = 0
)
@CommandPermissions("worldedit.chunkinfo")
public void chunkInfo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    Vector pos = player.getBlockIn();
    int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
    int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);

    String folder1 = Integer.toString(MathUtils.divisorMod(chunkX, 64), 36);
    String folder2 = Integer.toString(MathUtils.divisorMod(chunkZ, 64), 36);
    String filename = "c." + Integer.toString(chunkX, 36)
            + "." + Integer.toString(chunkZ, 36) + ".dat";

    player.print(BBC.getPrefix() + "Chunk: " + chunkX + ", " + chunkZ);
    player.print(BBC.getPrefix() + "Old format: " + folder1 + "/" + folder2 + "/" + filename);
    player.print(BBC.getPrefix() + "McRegion: region/" + McRegionChunkStore.getFilename(
            new Vector2D(chunkX, chunkZ)));
}
 
Example #8
Source File: CFICommand.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"cfi", "createfromimage"},
        usage = "",
        min = 0,
        max = -1,
        anyFlags = true,
        desc = "Start CreateFromImage"
)
@CommandPermissions("worldedit.anvil.cfi")
public void cfi(FawePlayer fp, CommandContext context) throws CommandException, IOException {
    CFICommands.CFISettings settings = child.getSettings(fp);
    settings.popMessages(fp);
    dispatch(fp, settings, context);
    HeightMapMCAGenerator gen = settings.getGenerator();
    if (gen != null && gen.isModified()) {
        gen.update();
        CFIChangeSet set = new CFIChangeSet(gen, fp.getUUID());
        LocalSession session = fp.getSession();
        session.remember(fp.getPlayer(), gen, set, fp.getLimit());
    }
}
 
Example #9
Source File: WhisperCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = {"msg", "message", "whisper", "pm", "tell", "dm"},
    usage = "<target> <message...>",
    desc = "Private message a user",
    min = 2,
    max = -1
)
@CommandPermissions("projectares.msg")
public void message(final CommandContext args, final CommandSender sender) throws CommandException {
    final Player player = CommandUtils.senderToPlayer(sender);
    final Identity from = identityProvider.currentIdentity(player);
    final String content = args.getJoinedStrings(1);

    executor.callback(
        userFinder.findUser(sender, args, 0),
        CommandFutureCallback.onSuccess(sender, args, response -> {
            whisperSender.send(sender, from, identityProvider.createIdentity(response), content);
        })
    );
}
 
Example #10
Source File: GenerationCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"/pyramid"},
        usage = "<pattern> <size>",
        flags = "h",
        desc = "Generate a filled pyramid",
        min = 2,
        max = 2
)
@CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT)
public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
    worldEdit.checkMaxRadius(size);
    Vector pos = session.getPlacementPosition(player);
    fp.checkConfirmationRadius(() -> {
        int affected = editSession.makePyramid(pos, pattern, size, !hollow);
        player.findFreePosition();
        BBC.VISITOR_BLOCK.send(fp, affected);
    }, getArguments(context), size, context);
}
 
Example #11
Source File: SuperPickaxeCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"area"},
        usage = "<radius>",
        desc = "Enable the area super pickaxe pickaxe mode",
        min = 1,
        max = 1
)
@CommandPermissions("worldedit.superpickaxe.area")
public void area(Player player, LocalSession session, CommandContext args) throws WorldEditException {

    LocalConfiguration config = we.getConfiguration();
    int range = args.getInteger(0);

    if (range > config.maxSuperPickaxeSize) {
        BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);
        return;
    }

    session.setSuperPickaxe(new AreaPickaxe(range));
    session.enableSuperPickAxe();
    BBC.SUPERPICKAXE_AREA_ENABLED.send(player);
}
 
Example #12
Source File: WhitelistCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = {"add"},
    desc = "Add a player to the whitelist",
    usage = "<username>",
    min = 1,
    max = 1
)
public void add(CommandContext args, final CommandSender sender) throws CommandException {
    syncExecutor.callback(
        userFinder.findUser(sender, args, 0),
        CommandFutureCallback.onSuccess(sender, args, result -> {
            whitelist.add(result.user);
            audiences.get(sender).sendMessage(
                new TranslatableComponent(
                    "whitelist.add",
                    new PlayerComponent(identities.currentIdentity(result.user), NameStyle.FANCY)
                )
            );
        })
    );
}
 
Example #13
Source File: FreeForAllCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = {"max", "size"},
    desc = "Change the maximum number of players allowed to participate in the match.",
    min = 1,
    max = 2
)
@CommandPermissions("pgm.team.size")
public static void max(CommandContext args, CommandSender sender) throws CommandException {
    FreeForAllMatchModule ffa = CommandUtils.getMatchModule(FreeForAllMatchModule.class, sender);
    if("default".equals(args.getString(0))) {
        ffa.setMaxPlayers(null, null);
    } else {
        int maxPlayers = args.getInteger(0);
        if(maxPlayers < 0) throw new CommandException("max-players cannot be less than 0");

        int maxOverfill = args.argsLength() >= 2 ? args.getInteger(1) : maxPlayers;
        if(maxOverfill < maxPlayers) throw new CommandException("max-overfill cannot be less than max-players");

        if(maxPlayers < ffa.getMinPlayers()) throw new CommandException("max-players cannot be less than min-players");

        ffa.setMaxPlayers(maxPlayers, maxOverfill);
    }

    sender.sendMessage(ChatColor.WHITE + "Maximum players is now " + ChatColor.AQUA + ffa.getMaxPlayers() +
                       ChatColor.WHITE + " and overfill is " + ChatColor.AQUA + ffa.getMaxOverfill());
}
 
Example #14
Source File: UserCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = { "seen", "find" },
    usage = "<player>",
    desc = "Shows when a player was last seen",
    min = 1,
    max = 1
)
@CommandPermissions("projectares.seen")
public void find(final CommandContext args, final CommandSender sender) throws CommandException {
    syncExecutor.callback(
        userFinder.findUser(sender, args, 0),
        CommandFutureCallback.onSuccess(sender, args, result -> {
            ComponentRenderers.send(sender, userFormatter.formatLastSeen(result));
        })
    );
}
 
Example #15
Source File: BrushOptionsCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"primary"},
        usage = "[brush-arguments]",
        desc = "Set the right click brush",
        help = "Set the right click brush",
        min = 1
)
public void primary(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    BaseBlock item = player.getBlockInHand();
    BrushTool tool = session.getBrushTool(player, false);
    session.setTool(item, null, player);
    String cmd = "brush " + args.getJoinedStrings(0);
    CommandEvent event = new CommandEvent(player, cmd);
    CommandManager.getInstance().handleCommandOnCurrentThread(event);
    BrushTool newTool = session.getBrushTool(item, player, false);
    if (newTool != null && tool != null) {
        newTool.setSecondary(tool.getSecondary());
    }
}
 
Example #16
Source File: DestroyableCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
public void setCompletion(CommandContext args, CommandSender sender, Destroyable destroyable, String value) throws CommandException {
    assertEditPerms(sender);

    Double completion;
    Integer breaks;

    if(value.endsWith("%")) {
        completion = Double.parseDouble(value.substring(0, value.length() - 1)) / 100d;
        breaks = null;
    } else {
        completion = null;
        breaks = Integer.parseInt(value);
    }

    try {
        if(completion != null) {
            destroyable.setDestructionRequired(completion);
        }
        else if(breaks != null) {
            destroyable.setBreaksRequired(breaks);
        }
    } catch(IllegalArgumentException e) {
        throw new CommandException(e.getMessage());
    }
}
 
Example #17
Source File: BrushProcessor.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public BrushSettings set(LocalSession session, CommandContext context, Brush brush) throws InvalidToolBindException {
    CommandLocals locals = context.getLocals();
    Actor actor = locals.get(Actor.class);
    BrushSettings bs = new BrushSettings();

    BrushTool tool = session.getBrushTool((Player) actor, false);
    if (tool != null) {
        BrushSettings currentContext = tool.getContext();
        if (currentContext != null) {
            Brush currentBrush = currentContext.getBrush();
            if (currentBrush != null && currentBrush.getClass() == brush.getClass()) {
                bs = currentContext;
            }
        }
    }

    bs.addPermissions(getPermissions());

    if (locals != null) {
        String args = (String) locals.get("arguments");
        if (args != null) {
            bs.addSetting(BrushSettings.SettingType.BRUSH, args.substring(args.indexOf(' ') + 1));
        }
    }
    return bs.setBrush(brush);
}
 
Example #18
Source File: ListCommand.java    From CardinalPGM with MIT License 6 votes vote down vote up
@Command(aliases = {"list"}, desc = "Lists all online players.", flags = "v")
public static void list(final CommandContext args, CommandSender sender) {
    boolean version = args.hasFlag('v');
    String result = ChatColor.GRAY + ChatConstant.MISC_ONLINE.asMessage().getMessage(ChatUtil.getLocale(sender)) +
            " (" + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers() + "): " + ChatColor.RESET;
    for (Player player : Bukkit.getOnlinePlayers()) {
        result += player.getDisplayName();
        if (version) {
            result += ChatColor.GRAY + " (" + Protocols.getName(player.getProtocolVersion()) + ")";
        }
        result += ChatColor.RESET + ", ";
    }
    if (result.endsWith(", ")) {
        result = result.substring(0, result.length() - 2);
    }
    sender.sendMessage(result);
}
 
Example #19
Source File: MapDevelopmentCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = {"matchfeatures", "features"},
    desc = "Lists all features by ID and type",
    min = 0,
    max = 1
)
@CommandPermissions(Permissions.MAPDEV)
public void featuresCommand(CommandContext args, CommandSender sender) throws CommandException {
    final Match match = tc.oc.pgm.commands.CommandUtils.getMatch(sender);
    new PrettyPaginatedResult<Feature>("Match Features") {
        @Override
        public String format(Feature feature, int i) {
            String text = (i + 1) + ". " + ChatColor.RED + feature.getClass().getSimpleName();
            if(feature instanceof SluggedFeature) {
                text += ChatColor.GRAY + " - " +ChatColor.GOLD + ((SluggedFeature) feature).slug();
            }
            return text;
        }
    }.display(new BukkitWrappedCommandSender(sender),
              match.features().all().collect(Collectors.toList()),
              args.getInteger(0, 1));
}
 
Example #20
Source File: SettingCommands.java    From CardinalPGM with MIT License 6 votes vote down vote up
@Command(aliases = {"toggle"}, desc = "Toggle a setting.", usage = "<setting>", min = 1)
public static void toggle(final CommandContext cmd, CommandSender sender) throws CommandException {
    if (!(sender instanceof Player)) {
        throw new CommandException(ChatConstant.ERROR_CONSOLE_NO_USE.getMessage(ChatUtil.getLocale(sender)));
    }
    Setting setting = Settings.getSettingByName(cmd.getString(0));
    if (setting == null) {
        throw new CommandException(ChatConstant.ERROR_NO_SETTING_MATCH.getMessage(ChatUtil.getLocale(sender)));
    }
    int index = setting.getValues().indexOf(setting.getValueByPlayer((Player) sender));
    index ++;
    if (index >= setting.getValues().size()) {
        index = 0;
    }
    Bukkit.dispatchCommand(sender, "set " + cmd.getString(0) + " " + setting.getValues().get(index).getValue());
}
 
Example #21
Source File: ServerCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"gqueuerestart", "gqr"},
        usage = "[-c]",
        desc = "Shutdown the next time the server is inactive and empty",
        flags = "c",
        help = "The -c flag cancels a previously queued restart"
)
@CommandPermissions("bungeecord.command.restart")
public void queueRestart(final CommandContext args, final CommandSender sender) throws CommandException {
    if(restartManager == null) {
        throw new CommandException("Scheduled restarts are not enabled");
    } else {
        if(args.hasFlag('c')) {
            sender.sendMessage(new TextComponent("Restart cancelled"));
            restartManager.cancelRestart();
        } else {
            sender.sendMessage(new TextComponent("Restart queued"));
            restartManager.requestRestart("/gqr command by " + sender.getName());
        }
    }
}
 
Example #22
Source File: WhitelistCommands.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Command(
    aliases = {"on", "enable"},
    desc = "Enable the whitelist",
    min = 0,
    max = 0
)
public void enable(CommandContext args, CommandSender sender) throws CommandException {
    whitelist.setEnabled(true);
    status(args, sender);
}
 
Example #23
Source File: QueueCommands.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Command(
    aliases = {"ping"},
    desc = "Send a Ping message to the direct exchange, -r to wait for a reply",
    usage = "<routing key> [-s | -f | -e]",
    flags = "sfe",
    min = 1,
    max = 1
)
public void ping(CommandContext args, CommandSender sender) throws CommandException {
    final String routingKey = args.getString(0);
    final Audience audience = audiences.get(sender);

    audience.sendMessage("ping " + routingKey);

    final Ping.ReplyWith replyWith;
    if(args.hasFlag('s')) {
        replyWith = Ping.ReplyWith.success;
    } else if(args.hasFlag('f')) {
        replyWith = Ping.ReplyWith.failure;
    } else if(args.hasFlag('e')) {
        replyWith = Ping.ReplyWith.exception;
    } else {
        replyWith = null;
    }

    if(replyWith == null) {
        exchange.publishAsync(new Ping(), routingKey);
    } else {
        final Transaction<Reply> transaction = transactions.request(new Ping(replyWith), routingKey);
        syncExecutor.callback(
            transaction,
            CommandFutureCallback.onSuccess(sender, args, reply -> {
                audience.sendMessage(reply.getClass().getSimpleName() + String.format(" (%.3fms)", transaction.elapsedTimeMillis()));
            })
        );
    }
}
 
Example #24
Source File: TeamCommands.java    From CardinalPGM with MIT License 5 votes vote down vote up
@Command(aliases = {"alias"}, desc = "Renames a the team specified.", usage = "<team> <name>", min = 2)
@CommandPermissions("cardinal.team.alias")
public static void alias(final CommandContext cmd, CommandSender sender) throws CommandException {
    Optional<TeamModule> team = Teams.getTeamByName(cmd.getString(0));
    if (!team.isPresent()) {
        throw new CommandException(new LocalizedChatMessage(ChatConstant.ERROR_NO_TEAM_MATCH).getMessage(ChatUtil.getLocale(sender)));
    }
    String msg = cmd.getJoinedStrings(1);
    ChatUtil.getGlobalChannel().sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.GRAY + "{0}", new LocalizedChatMessage(ChatConstant.GENERIC_TEAM_ALIAS, team.get().getCompleteName() + ChatColor.GRAY, team.get().getColor() + msg + ChatColor.GRAY)));
    team.get().setName(msg);
    Bukkit.getServer().getPluginManager().callEvent(new TeamNameChangeEvent(team.get()));
}
 
Example #25
Source File: WhitelistCommands.java    From CardinalPGM with MIT License 5 votes vote down vote up
@Command(aliases = {"kick"}, desc = "Kicks everyone who is not on the whitelist.", min = 0, max = 0)
@CommandPermissions("cardinal.whitelist.kick")
public static void kick(final CommandContext args, final CommandSender sender) throws CommandException {
    for (Player player : Bukkit.getOnlinePlayers()) {
        if (!player.isWhitelisted() && !player.isOp() && !player.hasPermission("cardinal.whitelist.bypass")) {
            player.kickPlayer(ChatColor.RED + ChatConstant.GENERIC_KICKED_NOT_WHITELISTED.getMessage(ChatUtil.getLocale(player)));
        }
    }
    ChatUtil.getGlobalChannel().sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.RED + "{0}", ChatConstant.GENERIC_KICKED_NOT_WHITELISTED.asMessage()));
}
 
Example #26
Source File: CommandUtils.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Get an online {@link Player} by exact name
 */
public static Player getPlayer(CommandContext args, CommandSender sender, int index) throws CommandException {
    if(args.argsLength() > index) {
        Player player = sender.getServer().getPlayerExact(args.getString(index), sender);
        if(player == null) throw new CommandException(ComponentRenderers.toLegacyText(new TranslatableComponent("command.playerNotFound"), sender));
        return player;
    } else {
        throw new CommandException(ComponentRenderers.toLegacyText(new TranslatableComponent("command.specifyPlayer"), sender));
    }
}
 
Example #27
Source File: ToolCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        aliases = {"deltree"},
        usage = "",
        desc = "Floating tree remover tool",
        min = 0,
        max = 0
)
@CommandPermissions("worldedit.tool.deltree")
public void deltree(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    session.setTool(new FloatingTreeRemover(), player);
    BBC.TOOL_DELTREE.send(player, ItemType.toHeldName(player.getItemInHand()));
}
 
Example #28
Source File: ServerCommands.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Command(
    aliases = {"hub", "lobby"},
    desc = "Teleport to the lobby",
    min = 0,
    max = 1
)
public void hub(final CommandContext args, CommandSender sender) throws CommandException {
    teleporter.sendToLobby(CommandUtils.senderToPlayer(sender), args.getString(0, null));
}
 
Example #29
Source File: RegionCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        aliases = {"/curve", "/spline"},
        usage = "<pattern> [thickness]",
        desc = "Draws a spline through selected points",
        help =
                "Draws a spline through selected points.\n" +
                        "Can only be used with convex polyhedral selections.\n" +
                        "Flags:\n" +
                        "  -h generates only a shell",
        flags = "h",
        min = 1,
        max = 2
)
@CommandPermissions("worldedit.region.curve")
@Logging(REGION)
public void curve(FawePlayer player, EditSession editSession,
                  @Selection Region region,
                  Pattern pattern,
                  @Optional("0") @Range(min = 0) int thickness,
                  @Switch('h') boolean shell,
                  CommandContext context) throws WorldEditException {
    if (!(region instanceof ConvexPolyhedralRegion)) {
        player.sendMessage(BBC.getPrefix() + "//curve only works with convex polyhedral selections");
        return;
    }
    worldEdit.checkMaxRadius(thickness);

    player.checkConfirmationRegion(() -> {
        ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
        List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices());

        int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);

        BBC.VISITOR_BLOCK.send(player, blocksChanged);
    }, getArguments(context), region, context);
}
 
Example #30
Source File: InventoryCommand.java    From CardinalPGM with MIT License 5 votes vote down vote up
@Command(aliases = {"inventory", "inv"}, desc = "Opens a player's inventory", min = 1, usage = "<player>")
public static void inventory(final CommandContext cmd, CommandSender sender) throws CommandException {
    if (!(sender instanceof Player)) {
        throw new CommandException(ChatConstant.ERROR_CONSOLE_NO_USE.getMessage(ChatUtil.getLocale(sender)));
    }
    Player target = Bukkit.getPlayer(cmd.getString(0), sender);
    if (target == null) {
        throw new CommandException(ChatConstant.ERROR_PLAYER_NOT_FOUND.getMessage(ChatUtil.getLocale(sender)));
    }
    GameHandler.getGameHandler().getMatch().getModules().getModule(ObserverModule.class).openInventory((Player)sender, target, true);
}