use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class HistoryCommands method undo.
@Command(name = "undo", aliases = { "/undo" }, desc = "Undoes the last action (from history)")
@CommandPermissions({ "worldedit.history.undo", "worldedit.history.undo.self" })
public void undo(Actor actor, LocalSession session, @Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of undoes to perform", def = "1") int times, @Arg(name = "player", desc = "Undo this player's operations", def = "") String playerName) throws WorldEditException {
times = Math.max(1, times);
LocalSession undoSession = session;
// FAWE start - Add fastmode check
if (session.hasFastMode()) {
actor.print(Caption.of("fawe.worldedit.history.command.undo.disabled"));
return;
}
// FAWE end
if (playerName != null) {
actor.checkPermission("worldedit.history.undo.other");
undoSession = worldEdit.getSessionManager().findByName(playerName);
if (undoSession == null) {
actor.print(Caption.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
return;
}
}
int timesUndone = 0;
for (int i = 0; i < times; ++i) {
BlockBag blockBag = actor instanceof Player ? undoSession.getBlockBag((Player) actor) : null;
EditSession undone = undoSession.undo(blockBag, actor);
if (undone != null) {
timesUndone++;
worldEdit.flushBlockBag(actor, undone);
} else {
break;
}
}
if (timesUndone > 0) {
actor.print(Caption.of("worldedit.undo.undone", TextComponent.of(timesUndone)));
} else {
actor.print(Caption.of("worldedit.undo.none"));
}
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class HistoryCommands method redo.
@Command(name = "redo", aliases = { "/redo" }, desc = "Redoes the last action (from history)")
@CommandPermissions({ "worldedit.history.redo", "worldedit.history.redo.self" })
public void redo(Actor actor, LocalSession session, @Confirm(Confirm.Processor.LIMIT) @Arg(desc = "Number of redoes to perform", def = "1") int times, @Arg(name = "player", desc = "Redo this player's operations", def = "") String playerName) throws WorldEditException {
times = Math.max(1, times);
LocalSession redoSession = session;
if (playerName != null) {
actor.checkPermission("worldedit.history.redo.other");
redoSession = worldEdit.getSessionManager().findByName(playerName);
if (redoSession == null) {
actor.print(Caption.of("worldedit.session.cant-find-session", TextComponent.of(playerName)));
return;
}
}
int timesRedone = 0;
for (int i = 0; i < times; ++i) {
BlockBag blockBag = actor instanceof Player ? redoSession.getBlockBag((Player) actor) : null;
EditSession redone = redoSession.redo(blockBag, actor);
if (redone != null) {
timesRedone++;
worldEdit.flushBlockBag(actor, redone);
} else {
break;
}
}
if (timesRedone > 0) {
actor.print(Caption.of("worldedit.redo.redone", TextComponent.of(timesRedone)));
} else {
actor.print(Caption.of("worldedit.redo.none"));
}
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class BiomeCommands method biomeList.
@Command(name = "biomelist", aliases = { "biomels", "/biomelist", "/listbiomes" }, desc = "Gets all biomes available.")
@CommandPermissions("worldedit.biome.list")
public void biomeList(Actor actor, @ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) {
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
PaginationBox paginationBox = PaginationBox.fromComponents("Available Biomes", "/biomelist -p %page%", BiomeType.REGISTRY.values().stream().map(biomeType -> TextComponent.builder().append(biomeType.getId()).append(" (").append(biomeRegistry.getRichName(biomeType)).append(")").build()).collect(Collectors.toList()));
return paginationBox.create(page);
}, (Component) null);
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method cylinderBrush.
@Command(name = "cylinder", aliases = { "cyl", "c" }, desc = "Choose the cylinder brush")
@CommandPermissions("worldedit.brush.cylinder")
public void cylinderBrush(InjectedValueAccess context, @Arg(desc = "The pattern of blocks to set") Pattern pattern, @Arg(desc = "The radius of the cylinder", def = "2") Expression radius, @Arg(desc = "The height of the cylinder", def = "1") int height, // FAWE start - hcyl thickness
@Arg(desc = "The thickness of the cylinder. Requires -h switch be given. 0 creates a standard hollow cylinder.", def = "0") double thickness, // FAWE end
@Switch(name = 'h', desc = "Create hollow cylinders instead") boolean hollow) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(height);
BrushSettings settings;
if (hollow) {
// FAWE start - hcyl thickness
settings = set(context, new HollowCylinderBrush(height, thickness), "worldedit.brush.cylinder");
// FAWE end
} else {
settings = set(context, new CylinderBrush(height), "worldedit.brush.cylinder");
}
settings.setSize(radius).setFill(pattern);
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method blobBrush.
@Command(name = "rock", aliases = { "blob" }, desc = "Creates a distorted sphere")
@CommandPermissions("worldedit.brush.rock")
public void blobBrush(InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "radii to multiply x,y,z by", def = "10") Vector3 radius, @Arg(name = "roundness", desc = "roundness", def = "100") double sphericity, @Arg(desc = "double", def = "30") double frequency, @Arg(desc = "double", def = "50") double amplitude) throws WorldEditException {
double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ());
worldEdit.checkMaxBrushRadius(max);
Brush brush = new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100);
set(context, brush, "worldedit.brush.rock").setSize(max).setFill(fill);
}
Aggregations