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;
}
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;
}
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);
}
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;
}
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))));
}
Aggregations