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

The following examples show how to use com.sk89q.minecraft.util.commands.CommandPermissions. 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: MapDevelopmentCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = {"pushmaps"},
    desc = "Synchronizes ALL loaded maps with the database",
    min = 0,
    max = 0
)
@CommandPermissions(Permissions.DEVELOPER)
public void pushMaps(CommandContext args, final CommandSender sender) throws CommandException {
    Audience audience = audiences.get(sender);
    audience.sendMessage(new Component("Pushing " + mapLibrary.getMaps().size() + " maps..."));

    syncExecutor.callback(
        mapLibrary.pushAllMaps(),
        CommandFutureCallback.onSuccess(sender, args, response ->
            audience.sendMessage(new Component(response.toString()))
        )
    );
}
 
Example #2
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 #3
Source File: AdminCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = {"restart"},
    desc = "Queues a server restart after a certain amount of time",
    usage = "[seconds] - defaults to 30 seconds",
    flags = "f",
    min = 0,
    max = 1
)
@CommandPermissions("server.restart")
public void restart(CommandContext args, CommandSender sender) throws CommandException {
    // Countdown defers automatic restart, so don't allow excessively long times
    Duration countdown = TimeUtils.min(
        tc.oc.commons.bukkit.commands.CommandUtils.getDuration(args, 0, Duration.ofSeconds(30)),
        Duration.ofMinutes(5)
    );

    final Match match = CommandUtils.getMatch(sender);
    if(!match.canAbort() && !args.hasFlag('f')) {
        throw new CommandException(PGMTranslations.get().t("command.admin.restart.matchRunning", sender));
    }

    restartListener.queueRestart(match, countdown, "/restart command");
}
 
Example #4
Source File: DebugCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = "deployinfo",
    desc = "What is deployed on this server?",
    min = 0,
    max = 0
)
@CommandPermissions(Permissions.DEVELOPER)
public void deployInfo(CommandContext args, CommandSender sender) throws CommandException {
    final DeployInfo info = startupDocument.deploy_info();
    if(info == null) {
        throw new CommandException("No deploy info was loaded");
    } else {
        sender.sendMessage(new Component("Nextgen"));
        sender.sendMessage(new Component("  path: " + info.nextgen().path()));
        sender.sendMessage(new Component("  version: " + format(info.nextgen().version())));
        for(Map.Entry<String, DeployInfo.Version> entry : info.packages().entrySet()) {
            sender.sendMessage(new Component(entry.getKey() + ": " + format(entry.getValue())));
        }
    }
}
 
Example #5
Source File: CFICommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"heightmap"},
        usage = "<url>",
        desc = "Start CFI with a height map as a base"
)
@CommandPermissions("worldedit.anvil.cfi")
public void heightmap(FawePlayer fp, BufferedImage image, @Optional("1") double yscale) {
    if (yscale != 0) {
        int[] raw = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
        int[] table = new int[256];
        for (int i = 0; i < table.length; i++) {
            table[i] = Math.min(255, (int) (i * yscale));
        }
        for (int i = 0; i < raw.length; i++) {
            int color = raw[i];
            int red = table[(color >> 16) & 0xFF];
            int green = table[(color >> 8) & 0xFF];
            int blue = table[(color >> 0) & 0xFF];
            raw[i] = (red << 16) + (green << 8) + (blue << 0);
        }
    }
    HeightMapMCAGenerator generator = new HeightMapMCAGenerator(image, getFolder(generateName()));
    setup(generator, fp);
}
 
Example #6
Source File: SelectionCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"/inset"},
        usage = "<amount>",
        desc = "Inset the selection area",
        help =
                "Contracts the selection by the given amount in all directions.\n" +
                        "Flags:\n" +
                        "  -h only contract horizontally\n" +
                        "  -v only contract vertically\n",
        flags = "hv",
        min = 1,
        max = 1
)
@Logging(REGION)
@CommandPermissions("worldedit.selection.inset")
public void inset(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    Region region = session.getSelection(player.getWorld());
    region.contract(getChangesForEachDir(args));
    session.getRegionSelector(player.getWorld()).learnChanges();
    session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
    BBC.SELECTION_INSET.send(player);
}
 
Example #7
Source File: CFICommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"brush"},
        usage = "",
        desc = "Info about using brushes with CFI"
)
@CommandPermissions("worldedit.anvil.cfi")
public void brush(FawePlayer fp) throws ParameterException{
    CFISettings settings = assertSettings(fp);
    settings.popMessages(fp);
    Message msg;
    if (settings.getGenerator().getImageViewer() != null) {
        msg = msg("CFI supports using brushes during creation").newline()
                .text(" - Place the map on a wall of item frames").newline()
                .text(" - Use any WorldEdit brush on the item frames").newline()
                .text(" - Example: ").text("Video").linkTip("https://goo.gl/PK4DMG").newline();
    } else {
        msg = msg("This is not supported with your platform/version").newline();
    }
    msg.text("&8< &7[&aBack&7]").cmdTip(alias()).send(fp);
}
 
Example #8
Source File: AnvilCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"deleteallunclaimed", "delallunclaimed" },
        usage = "<age-ticks> [file-age=60000]",
        desc = "(Supports: WG, P2, GP) Delete all chunks which haven't been occupied AND claimed",
        help = "(Supports: WG, P2, GP) Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n" +
                "Have not been accessed since `file-duration` (ms) after creation and\n" +
                "Have not been used in the past `chunk-inactivity` (ms)" +
                "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`",
        min = 1,
        max = 3
)
@CommandPermissions("worldedit.anvil.deleteallunclaimed")
public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException {
    String folder = Fawe.imp().getWorldName(player.getWorld());
    long chunkInactivityMillis = fileDurationMillis; // Use same value for now
    DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
    if (debug) filter.enableDebug();
    DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
    if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
}
 
Example #9
Source File: AnvilCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"deleteallunvisited", "delunvisited" },
        usage = "<folder> <age-ticks> [file-age=60000]",
        desc = "Delete all chunks which haven't been occupied",
        help = "Delete all chunks which haven't been occupied for `age-ticks` (20t = 1s) and \n" +
                "Have not been accessed since `file-duration` (ms) after creation and\n" +
                "Have not been used in the past `chunk-inactivity` (ms)" +
                "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`",
        min = 2,
        max = 3
)
@CommandPermissions("worldedit.anvil.deleteallunvisited")
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Optional("60000") int fileDurationMillis) throws WorldEditException {
    long chunkInactivityMillis = fileDurationMillis; // Use same value for now
    DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
    DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
    if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
}
 
Example #10
Source File: MapCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = {"maplist", "maps", "ml"},
    desc = "Shows the maps that are currently loaded",
    usage = "[page]",
    min = 0,
    max = 1,
    help = "Shows all the maps that are currently loaded including ones that are not in the rotation."
)
@CommandPermissions("pgm.maplist")
public static void maplist(CommandContext args, final CommandSender sender) throws CommandException {
    final Set<PGMMap> maps = ImmutableSortedSet.copyOf(new PGMMap.DisplayOrder(), PGM.getMatchManager().getMaps());

    new PrettyPaginatedResult<PGMMap>(PGMTranslations.get().t("command.map.mapList.title", sender)) {
        @Override public String format(PGMMap map, int index) {
            return (index + 1) + ". " + map.getInfo().getShortDescription(sender);
        }
    }.display(new BukkitWrappedCommandSender(sender), maps, args.getInteger(0, 1) /* page */);
}
 
Example #11
Source File: NavigationCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"up"},
        usage = "<number>",
        desc = "Go upwards some distance",
        flags = "fg",
        min = 1,
        max = 1
)
@CommandPermissions("worldedit.navigation.up")
@Logging(POSITION)
public void up(Player player, LocalSession session, CommandContext args) throws WorldEditException {
    final int distance = args.getInteger(0);

    final boolean alwaysGlass = getAlwaysGlass(args);
    if (player.ascendUpwards(distance, alwaysGlass)) {
        BBC.WHOOSH.send(player);
    } else {
        BBC.UP_FAIL.send(player);
    }
}
 
Example #12
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 #13
Source File: MapDevelopmentCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = {"loadnewmaps", "findnewmaps", "newmaps"},
    desc = "Scan for new maps and load them",
    min = 0,
    max = 0
)
@CommandPermissions("pgm.loadnewmaps")
public void loadNewMaps(CommandContext args, CommandSender sender) throws CommandException {
    final Audience audience = audiences.get(sender);
    audience.sendMessage(new Component(new TranslatableComponent("command.loadNewMaps.loading"), ChatColor.WHITE));
    // Clear errors for maps that failed to load, because we want to see those errors again
    mapErrorTracker.clearErrorsExcept(mapLibrary.getMaps());
    try {
        final Set<PGMMap> newMaps = matchManager.loadMapsAndRotations();

        if(newMaps.isEmpty()) {
            audience.sendMessage(new Component(new TranslatableComponent("command.loadNewMaps.noNewMaps"), ChatColor.WHITE));
        } else if(newMaps.size() == 1) {
            audience.sendMessage(new Component(new TranslatableComponent("command.loadNewMaps.foundSingleMap", new Component(newMaps.iterator().next().getInfo().name, ChatColor.YELLOW)), ChatColor.WHITE));
        } else {
            audience.sendMessage(new Component(new TranslatableComponent("command.loadNewMaps.foundMultipleMaps", new Component(Integer.toString(newMaps.size()), ChatColor.AQUA)), ChatColor.WHITE));
        }
    } catch(MapNotFoundException e) {
        audience.sendWarning(new TranslatableComponent("command.loadNewMaps.noMaps"), false);
    }
}
 
Example #14
Source File: SchematicCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(aliases = {"formats", "listformats", "f"}, desc = "List available formats", max = 0)
@CommandPermissions("worldedit.schematic.formats")
public void formats(final Actor actor) throws WorldEditException {
    BBC.SCHEMATIC_FORMAT.send(actor);
    Message m = new Message(BBC.SCHEMATIC_FORMAT).newline();
    String baseCmd = Commands.getAlias(SchematicCommands.class, "schematic") + " " + Commands.getAlias(SchematicCommands.class, "save");
    boolean first = true;
    for (final ClipboardFormat format : ClipboardFormat.values()) {
        StringBuilder builder = new StringBuilder();
        builder.append(format.name()).append(": ");
        for (final String lookupName : format.getAliases()) {
            if (!first) {
                builder.append(", ");
            }
            builder.append(lookupName);
            first = false;
        }
        String cmd = baseCmd + " " + format.name() + " <filename>";
        m.text(builder).suggestTip(cmd).newline();
        first = true;
    }
    m.send(actor);
}
 
Example #15
Source File: MapDevelopmentCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = {"feature", "fl"},
    desc = "Prints information regarding a specific feature",
    min = 1,
    max = -1
)
@CommandPermissions(Permissions.MAPDEV)
public void featureCommand(CommandContext args, CommandSender sender) throws CommandException {
    final String slug = args.getJoinedStrings(0);
    final Optional<Feature<?>> feature = matchManager.getCurrentMatch(sender).features().bySlug(slug);
    if(feature.isPresent()) {
        sender.sendMessage(ChatColor.GOLD + slug + ChatColor.GRAY + " corresponds to: " + ChatColor.WHITE + feature.get().toString());
    } else {
        sender.sendMessage(ChatColor.RED + "No feature by the name of " + ChatColor.GOLD + slug + ChatColor.RED + " was found.");
    }
}
 
Example #16
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 #17
Source File: RegionCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"/setskylight"},
        desc = "Set sky lighting in a selection",
        min = 1,
        max = 1
)
@CommandPermissions("worldedit.light.set")
public void setskylighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
    FawePlayer fp = FawePlayer.wrap(player);
    final FaweLocation loc = fp.getLocation();
    final int cx = loc.x >> 4;
    final int cz = loc.z >> 4;
    final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false);
    for (Vector pt : region) {
        queue.setSkyLight((int) pt.getX(), (int) pt.getY(), (int) pt.getZ(), value);
    }
    int count = 0;
    for (Vector2D chunk : region.getChunks()) {
        queue.sendChunk(queue.getFaweChunk(chunk.getBlockX(), chunk.getBlockZ()));
        count++;
    }
    BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
}
 
Example #18
Source File: FreezeCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = { "freeze", "f" },
    usage = "<player>",
    desc = "Freeze a player",
    min = 1,
    max = 1
)
@CommandPermissions(Freeze.PERMISSION)
public void freeze(final CommandContext args, final CommandSender sender) throws CommandException {
    if(!freeze.enabled()) {
        throw new ComponentCommandException(new TranslatableComponent("command.freeze.notEnabled"));
    }

    executor.callback(
        userFinder.findLocalPlayer(sender, args, 0),
        CommandFutureCallback.onSuccess(sender, args, response -> freeze.toggleFrozen(sender, response.player()))
    );
}
 
Example #19
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 #20
Source File: AnvilCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"replace", "r"},
        usage = "[from-block] <to-block>",
        desc = "Replace all blocks in the selection with another"
)
@CommandPermissions("worldedit.anvil.replace")
public void replace(Player player, EditSession editSession, @Selection Region selection, @Optional String from, String to, @Switch('d') boolean useData) throws WorldEditException {
    final FaweBlockMatcher matchFrom;
    if (from == null) {
        matchFrom = FaweBlockMatcher.NOT_AIR;
    } else {
        matchFrom = FaweBlockMatcher.fromBlocks(worldEdit.getBlocks(player, from, true), useData || from.contains(":"));
    }
    final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true));
    ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo);
    MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
    if (result != null) {
        player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
    }
}
 
Example #21
Source File: OptionsCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"/gmask", "gmask", "globalmask", "/globalmask"},
        usage = "[mask]",
        help = "The global destination mask applies to all edits you do and masks based on the destination blocks (i.e. the blocks in the world).",
        desc = "Set the global mask",
        min = 0,
        max = -1
)
@CommandPermissions({"worldedit.global-mask", "worldedit.mask.global"})
public void gmask(Player player, LocalSession session, EditSession editSession, @Optional CommandContext context) throws WorldEditException {
    if (context == null || context.argsLength() == 0) {
        session.setMask((Mask) null);
        BBC.MASK_DISABLED.send(player);
    } else {
        ParserContext parserContext = new ParserContext();
        parserContext.setActor(player);
        parserContext.setWorld(player.getWorld());
        parserContext.setSession(session);
        parserContext.setExtent(editSession);
        Mask mask = worldEdit.getMaskFactory().parseFromInput(context.getJoinedStrings(0), parserContext);
        session.setMask(mask);
        BBC.MASK.send(player);
    }
}
 
Example #22
Source File: FreeForAllCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
    aliases = {"min"},
    desc = "Change the minimum number of players required to start the match.",
    min = 1,
    max = 1
)
@CommandPermissions("pgm.team.size")
public static void min(CommandContext args, CommandSender sender) throws CommandException {
    FreeForAllMatchModule ffa = CommandUtils.getMatchModule(FreeForAllMatchModule.class, sender);
    if("default".equals(args.getString(0))) {
        ffa.setMinPlayers(null);
    } else {
        int minPlayers = args.getInteger(0);
        if(minPlayers < 0) throw new CommandException("min-players cannot be less than 0");
        if(minPlayers > ffa.getMaxPlayers()) throw new CommandException("min-players cannot be greater than max-players");
        ffa.setMinPlayers(minPlayers);
    }

    sender.sendMessage(ChatColor.WHITE + "Minimum players is now " + ChatColor.AQUA + ffa.getMinPlayers());
}
 
Example #23
Source File: TeamCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"teams", "listteams"},
        desc = "Lists the teams registered for competition on this server.",
        min = 0,
        max = 1,
        usage = "[page]"
)
@Console
@CommandPermissions("tourney.listteams")
public void listTeams(final CommandContext args, final CommandSender sender) throws CommandException {
    new Paginator<team.Id>()
        .title(new TranslatableComponent("tourney.teams.title", tournamentName))
        .entries((team, index) -> teamName(team))
        .display(audiences.get(sender),
                 tournament.accepted_teams(),
                 args.getInteger(0, 1));
}
 
Example #24
Source File: CFICommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"populate"},
        usage = "",
        desc = ""
)
@CommandPermissions("worldedit.anvil.cfi")
public void populate(FawePlayer fp) throws ParameterException{
    CFISettings settings = assertSettings(fp);
    settings.popMessages(fp);
    settings.setCategory("populate");
    msg("What would you like to populate?").newline()
    .text("(You will need to type these commands)").newline()
    .cmdOptions(alias() + " ", "", "Ores", "Ore", "Caves", "Schematics", "Smooth")
    .newline().text("&8< &7[&aBack&7]").cmdTip(alias())
    .send(fp);
}
 
Example #25
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 #26
Source File: AnvilCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"deleteunclaimed"},
        usage = "<age-ticks> [file-age=60000]",
        desc = "(Supports: WG, P2, GP) Delete all chunks which haven't been occupied AND claimed",
        help = "(Supports: WG, P2, GP) Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n" +
                "Have not been accessed since `file-duration` (ms) after creation and\n" +
                "Have not been used in the past `chunk-inactivity` (ms)" +
                "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`",
        min = 1,
        max = 3
)
@CommandPermissions("worldedit.anvil.deleteunclaimed")
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException {
    String folder = Fawe.imp().getWorldName(player.getWorld());
    long chunkInactivityMillis = fileDurationMillis; // Use same value for now
    DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
    if (debug) filter.enableDebug();
    DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
    if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
}
 
Example #27
Source File: TourneyCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"invalidate", "nosave", "norecord"},
        desc = "Indicates that the current match should not be saved to the database.",
        min = 0,
        max = 0,
        flags = "c"
)
@Console
@CommandPermissions("tourney.invalidate")
public static void invalidate(final CommandContext args, final CommandSender sender) throws CommandException {
    Tourney plugin = Tourney.get();
    if (!Arrays.asList(TourneyState.ENABLED_RUNNING, TourneyState.ENABLED_FINISHED).contains(plugin.getState())) {
        throw new CommandException("This match may not be invalidated at this time.");
    }

    if (plugin.isRecordQueued()) {
        if (args.hasFlag('c')) {
            plugin.setRecordQueued(false);
            sender.sendMessage(ChatColor.YELLOW + "Match successfully invalidated.");
        } else {
            throw new CommandException("Match is eligible for invalidation. Re-run command with -c to confirm. Invalidation may not be reversed.");
        }
    } else {
        throw new CommandException("This match is not queued to be recorded.");
    }
}
 
Example #28
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 #29
Source File: ToolCommands.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"floodfill", "flood"},
        usage = "<pattern> <range>",
        desc = "Flood fill tool",
        min = 2,
        max = 2
)
@CommandPermissions("worldedit.tool.flood-fill")
public void floodFill(Player player, EditSession editSession, LocalSession session, Pattern pattern, double range) throws WorldEditException {
    LocalConfiguration config = we.getConfiguration();
    if (range > config.maxSuperPickaxeSize) {
        BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);
        return;
    }
    session.setTool(new FloodFillTool((int) range, pattern), player);
    BBC.TOOL_FLOOD_FILL.send(player, ItemType.toHeldName(player.getItemInHand()));
}
 
Example #30
Source File: RestartCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Command(
        aliases = {"cancelrestart", "cr"},
        desc = "Cancels a previously requested restart",
        min = 0,
        max = 0
)
@CommandPermissions("server.cancelrestart")
@Console
public void cancelRestart(CommandContext args, final CommandSender sender) throws CommandException {
    if(!restartManager.isRestartRequested()) {
        throw new TranslatableCommandException("command.admin.cancelRestart.noActionTaken");
    }

    syncExecutor.callback(
        restartManager.cancelRestart(),
        CommandFutureCallback.onSuccess(sender, args, o -> {
            audiences.get(sender).sendMessage(new TranslatableComponent("command.admin.cancelRestart.restartUnqueued"));
        })
    );
}