Search in sources :

Example 91 with CommandPermissions

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

the class UtilityCommands method extinguish.

@Command(name = "extinguish", aliases = { "/ex", "/ext", "/extinguish", "ex", "ext" }, desc = "Extinguish nearby fire")
@CommandPermissions("worldedit.extinguish")
@Logging(PLACEMENT)
public int extinguish(Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the square to remove in", def = "") Integer radius) throws WorldEditException {
    LocalConfiguration config = we.getConfiguration();
    int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40;
    int size = radius != null ? Math.max(1, radius) : defaultRadius;
    we.checkMaxRadius(size);
    Mask mask = new BlockTypeMask(editSession, BlockTypes.FIRE);
    int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, size);
    actor.print(Caption.of("worldedit.extinguish.removed", TextComponent.of(affected)));
    return affected;
}
Also used : BlockTypeMask(com.sk89q.worldedit.function.mask.BlockTypeMask) ExistingBlockMask(com.sk89q.worldedit.function.mask.ExistingBlockMask) Mask(com.sk89q.worldedit.function.mask.Mask) BlockTypeMask(com.sk89q.worldedit.function.mask.BlockTypeMask) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 92 with CommandPermissions

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

the class UtilityCommands method butcher.

@Command(name = "butcher", aliases = { "/butcher" }, desc = "Kill all or nearby mobs")
@CommandPermissions("worldedit.butcher")
@Logging(PLACEMENT)
public int butcher(Actor actor, @Arg(desc = "Radius to kill mobs in", def = "") Integer radius, @Switch(name = 'p', desc = "Also kill pets") boolean killPets, @Switch(name = 'n', desc = "Also kill NPCs") boolean killNpcs, @Switch(name = 'g', desc = "Also kill golems") boolean killGolems, @Switch(name = 'a', desc = "Also kill animals") boolean killAnimals, @Switch(name = 'b', desc = "Also kill ambient mobs") boolean killAmbient, @Switch(name = 't', desc = "Also kill mobs with name tags") boolean killWithName, @Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)") boolean killFriendly, @Switch(name = 'r', desc = "Also destroy armor stands") boolean killArmorStands, @Switch(name = 'w', desc = "Also kill water mobs") boolean killWater) throws WorldEditException {
    LocalConfiguration config = we.getConfiguration();
    if (radius == null) {
        radius = config.butcherDefaultRadius;
    } else if (radius < -1) {
        actor.print(Caption.of("worldedit.butcher.explain-all"));
        return 0;
    } else if (radius == -1) {
        if (config.butcherMaxRadius != -1) {
            radius = config.butcherMaxRadius;
        }
    }
    if (config.butcherMaxRadius != -1) {
        radius = Math.min(radius, config.butcherMaxRadius);
    }
    CreatureButcher flags = new CreatureButcher(actor);
    flags.or(CreatureButcher.Flags.FRIENDLY, killFriendly);
    // No permission check here. Flags will instead be filtered by the subsequent calls.
    flags.or(CreatureButcher.Flags.PETS, killPets, "worldedit.butcher.pets");
    flags.or(CreatureButcher.Flags.NPCS, killNpcs, "worldedit.butcher.npcs");
    flags.or(CreatureButcher.Flags.GOLEMS, killGolems, "worldedit.butcher.golems");
    flags.or(CreatureButcher.Flags.ANIMALS, killAnimals, "worldedit.butcher.animals");
    flags.or(CreatureButcher.Flags.AMBIENT, killAmbient, "worldedit.butcher.ambient");
    flags.or(CreatureButcher.Flags.TAGGED, killWithName, "worldedit.butcher.tagged");
    flags.or(CreatureButcher.Flags.ARMOR_STAND, killArmorStands, "worldedit.butcher.armorstands");
    flags.or(CreatureButcher.Flags.WATER, killWater, "worldedit.butcher.water");
    // FAWE start - run this sync
    int finalRadius = radius;
    int killed = TaskManager.taskManager().sync(() -> killMatchingEntities(finalRadius, actor, flags::createFunction));
    // FAWE end
    actor.print(Caption.of("worldedit.butcher.killed", TextComponent.of(killed), TextComponent.of(radius)));
    return killed;
}
Also used : CreatureButcher(com.sk89q.worldedit.command.util.CreatureButcher) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 93 with CommandPermissions

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

the class UtilityCommands method calc.

@Command(name = "/calculate", aliases = { "/calc", "/eval", "/evaluate", "/solve" }, desc = "Evaluate a mathematical expression")
@CommandPermissions("worldedit.calc")
public void calc(Actor actor, @Arg(desc = "Expression to evaluate", variable = true) List<String> input) {
    Expression expression;
    try {
        expression = Expression.compile(String.join(" ", input));
    } catch (ExpressionException e) {
        actor.print(Caption.of("worldedit.calc.invalid.with-error", TextComponent.of(String.join(" ", input)), TextComponent.of(e.getMessage())));
        return;
    }
    WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
        double result = expression.evaluate(new double[] {}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
        String formatted = Double.isNaN(result) ? "NaN" : formatForLocale(actor.getLocale()).format(result);
        return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.LIGHT_PURPLE));
    }, (Component) null);
}
Also used : Expression(com.sk89q.worldedit.internal.expression.Expression) ExpressionException(com.sk89q.worldedit.internal.expression.ExpressionException) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 94 with CommandPermissions

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

the class UtilityCommands method removeNear.

@Command(name = "removenear", aliases = { "/removenear" }, desc = "Remove blocks near you.")
@CommandPermissions("worldedit.removenear")
@Logging(PLACEMENT)
public int removeNear(Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The mask of blocks to remove") Mask mask, @Arg(desc = "The radius of the square to remove from", def = "50") int radius) throws WorldEditException {
    // FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow)
    new MaskTraverser(mask).setNewExtent(editSession);
    // FAWE end
    radius = Math.max(1, radius);
    we.checkMaxRadius(radius);
    int affected = editSession.removeNear(session.getPlacementPosition(actor), mask, radius);
    actor.print(Caption.of("worldedit.removenear.removed", TextComponent.of(affected)));
    return affected;
}
Also used : MaskTraverser(com.fastasyncworldedit.core.util.MaskTraverser) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 95 with CommandPermissions

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

the class WorldEditCommands method report.

// FAWE start
@Command(name = "debugpaste", desc = "Writes a report of latest.log, config.yml, worldedit-config.yml, strings.json to https://athion.net/ISPaster/paste")
@CommandPermissions(value = { "worldedit.report", "worldedit.debugpaste" }, queued = false)
public void report(Actor actor) throws WorldEditException {
    String dest;
    try {
        final File logFile = new File("logs/latest.log");
        final File config = new File(Fawe.platform().getDirectory(), "config.yml");
        final File worldeditConfig = new File(Fawe.platform().getDirectory(), "worldedit-config.yml");
        dest = IncendoPaster.debugPaste(logFile, Fawe.platform().getDebugInfo(), config, worldeditConfig);
    } catch (IOException e) {
        actor.printInfo(TextComponent.of(e.getMessage()));
        return;
    }
    actor.print(Caption.of("worldedit.report.written", TextComponent.of(dest).clickEvent(ClickEvent.openUrl(dest))));
}
Also used : IOException(java.io.IOException) File(java.io.File) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)133 Command (org.enginehub.piston.annotation.Command)133 Logging (com.sk89q.worldedit.command.util.Logging)47 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)34 ScatterCommand (com.fastasyncworldedit.core.command.tool.brush.ScatterCommand)25 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)22 LocalConfiguration (com.sk89q.worldedit.LocalConfiguration)20 Region (com.sk89q.worldedit.regions.Region)19 Preload (com.sk89q.worldedit.command.util.annotation.Preload)17 File (java.io.File)17 ClipboardHolder (com.sk89q.worldedit.session.ClipboardHolder)16 URIClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder)15 MultiClipboardHolder (com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder)14 MaskTraverser (com.fastasyncworldedit.core.util.MaskTraverser)13 Mask (com.sk89q.worldedit.function.mask.Mask)11 IOException (java.io.IOException)11 BrushTool (com.sk89q.worldedit.command.tool.BrushTool)10 Player (com.sk89q.worldedit.entity.Player)10 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)10 Location (com.sk89q.worldedit.util.Location)10