Search in sources :

Example 1 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class GenerationCommands method caves.

// FAWE start
@Command(name = "/caves", desc = "Generates a cave network")
@CommandPermissions("worldedit.generation.caves")
@Logging(PLACEMENT)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void caves(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(name = "size", desc = "TODO", def = "8") int sizeOpt, @Arg(name = "frequency", desc = "TODO", def = "40") int frequencyOpt, @Arg(name = "rarity", desc = "TODO", def = "7") int rarityOpt, @Arg(name = "minY", desc = "TODO", def = "8") int minYOpt, @Arg(name = "maxY", desc = "TODO", def = "127") int maxYOpt, @Arg(name = "systemFrequency", desc = "TODO", def = "1") int systemFrequencyOpt, @Arg(name = "individualRarity", desc = "TODO", def = "25") int individualRarityOpt, @Arg(name = "pocketChance", desc = "TODO", def = "0") int pocketChanceOpt, @Arg(name = "pocketMin", desc = "TODO", def = "0") int pocketMinOpt, @Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt) throws WorldEditException {
    CavesGen gen = new CavesGen(sizeOpt, frequencyOpt, rarityOpt, minYOpt, maxYOpt, systemFrequencyOpt, individualRarityOpt, pocketChanceOpt, pocketMinOpt, pocketMaxOpt);
    editSession.generate(region, gen);
    actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
}
Also used : CavesGen(com.fastasyncworldedit.core.function.generator.CavesGen) Logging(com.sk89q.worldedit.command.util.Logging) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 2 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class GenerationCommands method generateBiome.

@Command(name = "/generatebiome", aliases = { "/genbiome", "/gb" }, desc = "Sets biome according to a formula.", descFooter = "Formula must return positive numbers (true) if the point is inside the shape\n" + "Sets the biome of blocks in that shape.\n" + "For details, see https://ehub.to/we/expr")
@CommandPermissions("worldedit.generation.shape.biome")
@Logging(ALL)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int generateBiome(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "The biome type to set") BiomeType target, @Arg(desc = "Expression to test block placement locations and set biome type. Requires x,y,z variables be present", variable = true) List<String> expression, @Switch(name = 'h', desc = "Generate a hollow shape") boolean hollow, @Switch(name = 'r', desc = "Use the game's coordinate origin") boolean useRawCoords, @Switch(name = 'o', desc = "Use the placement's coordinate origin") boolean offset, @Switch(name = 'c', desc = "Use the selection's center as origin") boolean offsetCenter) throws WorldEditException {
    final Vector3 zero;
    Vector3 unit;
    if (useRawCoords) {
        zero = Vector3.ZERO;
        unit = Vector3.ONE;
    } else if (offset) {
        zero = session.getPlacementPosition(actor).toVector3();
        unit = Vector3.ONE;
    } else if (offsetCenter) {
        final Vector3 min = region.getMinimumPoint().toVector3();
        final Vector3 max = region.getMaximumPoint().toVector3();
        zero = max.add(min).multiply(0.5);
        unit = Vector3.ONE;
    } else {
        final Vector3 min = region.getMinimumPoint().toVector3();
        final Vector3 max = region.getMaximumPoint().toVector3();
        zero = max.add(min).multiply(0.5);
        unit = max.subtract(zero);
        if (unit.getX() == 0) {
            unit = unit.withX(1.0);
        }
        if (unit.getY() == 0) {
            unit = unit.withY(1.0);
        }
        if (unit.getZ() == 0) {
            unit = unit.withZ(1.0);
        }
    }
    final Vector3 unit1 = unit;
    try {
        final int affected = editSession.makeBiomeShape(region, zero, unit1, target, String.join(" ", expression), hollow, session.getTimeout());
        actor.print(Caption.of("worldedit.generatebiome.changed", TextComponent.of(affected)));
        return affected;
    } catch (ExpressionException e) {
        actor.printError(TextComponent.of(e.getMessage()));
        return 0;
    }
}
Also used : BlockVector3(com.sk89q.worldedit.math.BlockVector3) Vector3(com.sk89q.worldedit.math.Vector3) ExpressionException(com.sk89q.worldedit.internal.expression.ExpressionException) Logging(com.sk89q.worldedit.command.util.Logging) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 3 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class GenerationCommands method ore.

@Command(name = "/ore", desc = "Generates ores")
@CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void ore(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern") Pattern material, @Arg(desc = "Ore vein size") @Range(from = 0, to = Integer.MAX_VALUE) int size, @Arg(desc = "Ore vein frequency (number of times to attempt to place ore)", def = "10") @Range(from = 0, to = Integer.MAX_VALUE) int freq, @Arg(desc = "Ore vein rarity (% chance each attempt is placed)", def = "100") @Range(from = 0, to = 100) int rarity, @Arg(desc = "Ore vein min y", def = "0") int minY, @Arg(desc = "Ore vein max y", def = "63") int maxY) throws WorldEditException {
    new MaskTraverser(mask).setNewExtent(editSession);
    checkCommandArgument(minY >= editSession.getMinY(), Caption.of("fawe.error.outside-range-lower", "miny", editSession.getMinY()));
    checkCommandArgument(maxY <= editSession.getMaxY(), Caption.of("fawe.error.outside-range-upper", "maxy", editSession.getMaxY()));
    checkCommandArgument(minY < maxY, Caption.of("fawe.error.argument-size-mismatch", "miny", "maxy"));
    editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
    actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
}
Also used : MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) Logging(com.sk89q.worldedit.command.util.Logging) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 4 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class GenerationCommands method ores.

@Command(name = "/ores", desc = "Generates ores")
@CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask) throws WorldEditException {
    new MaskTraverser(mask).setNewExtent(editSession);
    editSession.addOres(region, mask);
    actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
}
Also used : MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) Logging(com.sk89q.worldedit.command.util.Logging) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 5 with Confirm

use of com.sk89q.worldedit.command.util.annotation.Confirm in project FastAsyncWorldEdit by IntellectualSites.

the class HistorySubCommands method importdb.

@Command(name = "import", desc = "Import history into the database" + " - The time uses s, m, h, d, y.\n" + " - Import from disk: /history import")
@CommandPermissions("fawe.rollback.import")
@Confirm
public synchronized void importdb(Actor actor) throws WorldEditException {
    File folder = MainUtil.getFile(Fawe.platform().getDirectory(), Settings.settings().PATHS.HISTORY);
    if (folder.exists()) {
        for (File worldFolder : Objects.requireNonNull(folder.listFiles())) {
            if (worldFolder != null && worldFolder.isDirectory()) {
                String worldName = worldFolder.getName();
                World world = FaweAPI.getWorld(worldName);
                if (world != null) {
                    for (File userFolder : worldFolder.listFiles()) {
                        if (!userFolder.isDirectory()) {
                            continue;
                        }
                        String userUUID = userFolder.getName();
                        try {
                            UUID uuid = UUID.fromString(userUUID);
                            for (File historyFile : userFolder.listFiles()) {
                                String name = historyFile.getName();
                                if (!name.endsWith(".bd")) {
                                    continue;
                                }
                                RollbackOptimizedHistory rollback = new RollbackOptimizedHistory(world, uuid, Integer.parseInt(name.substring(0, name.length() - 3)));
                                SimpleChangeSetSummary summary = rollback.summarize(RegionWrapper.GLOBAL(), false);
                                if (summary != null) {
                                    rollback.setDimensions(BlockVector3.at(summary.minX, world.getMinY(), summary.minZ), BlockVector3.at(summary.maxX, world.getMaxY(), summary.maxZ));
                                    rollback.setTime(historyFile.lastModified());
                                    RollbackDatabase db = DBHandler.IMP.getDatabase(world);
                                    db.logEdit(rollback);
                                    actor.print(TextComponent.of("Logging: " + historyFile));
                                }
                            }
                        } catch (IllegalArgumentException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
        actor.print(TextComponent.of("Done import!"));
    }
}
Also used : SimpleChangeSetSummary(com.fastasyncworldedit.core.history.changeset.SimpleChangeSetSummary) World(com.sk89q.worldedit.world.World) UUID(java.util.UUID) File(java.io.File) RollbackDatabase(com.fastasyncworldedit.core.database.RollbackDatabase) RollbackOptimizedHistory(com.fastasyncworldedit.core.history.RollbackOptimizedHistory) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)22 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)20 Command (org.enginehub.piston.annotation.Command)20 Logging (com.sk89q.worldedit.command.util.Logging)17 Preload (com.sk89q.worldedit.command.util.annotation.Preload)15 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)10 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)8 Mask (com.sk89q.worldedit.function.mask.Mask)6 ExistingBlockMask (com.sk89q.worldedit.function.mask.ExistingBlockMask)5 FaweLimit (com.fastasyncworldedit.core.limit.FaweLimit)3 SolidBlockMask (com.sk89q.worldedit.function.mask.SolidBlockMask)3 ExpressionException (com.sk89q.worldedit.internal.expression.ExpressionException)3 Vector3 (com.sk89q.worldedit.math.Vector3)3 Region (com.sk89q.worldedit.regions.Region)3 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)2 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)2 RollbackOptimizedHistory (com.fastasyncworldedit.core.history.RollbackOptimizedHistory)2 Player (com.sk89q.worldedit.entity.Player)2 BlockArrayClipboard (com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard)2 RegionMask (com.sk89q.worldedit.function.mask.RegionMask)2