use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method scatterBrush.
@Command(name = "scatter", desc = "Scatter a pattern on a surface", descFooter = "Set a number of blocks randomly on a surface each a certain distance apart.\n" + "Video: https://youtu.be/RPZIaTbqoZw?t=34s")
@CommandPermissions("worldedit.brush.scatter")
public void scatterBrush(InjectedValueAccess context, @Arg(desc = "Pattern") Pattern fill, @Arg(desc = "radius", def = "5") Expression radius, @Arg(desc = "points", def = "5") double points, @Arg(desc = "distance", def = "1") double distance, @Switch(name = 'o', desc = "Overlay the block") boolean overlay) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
Brush brush;
if (overlay) {
brush = new ScatterOverlayBrush((int) points, (int) distance);
} else {
brush = new ScatterBrush((int) points, (int) distance);
}
set(context, brush, "worldedit.brush.scatter").setSize(radius).setFill(fill);
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method snowSmoothBrush.
@Command(name = "snowsmooth", desc = "Choose the snow terrain softener brush", descFooter = "Example: '/brush snowsmooth 5 1 -l 3'")
@CommandPermissions("worldedit.brush.snowsmooth")
public void snowSmoothBrush(Player player, LocalSession session, // FAWE start - Expression > double, default iteration number 1 is much better.
@Arg(desc = "The radius to sample for softening", def = "2") Expression radius, @Arg(desc = "The number of iterations to perform", def = "1") int iterations, // FAWE end
@ArgFlag(name = 'l', desc = "The number of snow blocks under snow", def = "1") int snowBlockCount, @ArgFlag(name = 'm', desc = "The mask of blocks to use for the heightmap") Mask mask, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
// FAWE start
FaweLimit limit = Settings.settings().getLimit(player);
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
// FAWE end
set(context, new SnowSmoothBrush(iterations, mask), "worldedit.brush.snowsmooth").setSize(radius);
player.print(Caption.of("worldedit.brush.smooth.equip", radius, iterations, Caption.of("worldedit.brush.smooth." + (mask == null ? "no" : "") + "filter")));
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method imageBrush.
@Command(name = "image", desc = "Use a height map to paint a surface", descFooter = "Use a height map to paint any surface.\n")
@CommandPermissions("worldedit.brush.image")
public void imageBrush(LocalSession session, InjectedValueAccess context, @Arg(desc = "Image URL (imgur only)") String imageURL, @Arg(desc = "The size of the brush", def = "5") Expression radius, @Arg(def = "1", desc = "scale height") double yscale, @Switch(name = 'a', desc = "Use image Alpha") boolean alpha, @Switch(name = 'f', desc = "Blend the image with existing terrain") boolean fadeOut) throws WorldEditException, IOException {
URL url = new URL(imageURL);
if (!url.getHost().equalsIgnoreCase("i.imgur.com")) {
throw new IOException("Only i.imgur.com links are allowed!");
}
BufferedImage image = MainUtil.readImage(url);
worldEdit.checkMaxBrushRadius(radius);
if (yscale != 1) {
ImageUtil.scaleAlpha(image, yscale);
alpha = true;
}
if (fadeOut) {
ImageUtil.fadeAlpha(image);
alpha = true;
}
ImageBrush brush = new ImageBrush(image, session, alpha);
set(context, brush, "worldedit.brush.image").setSize(radius);
}
use of com.sk89q.worldedit.command.util.CommandPermissions 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!"));
}
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class HistorySubCommands method list.
@Command(name = "list", desc = "List your history")
@CommandPermissions("worldedit.history.list")
public void list(Player player, LocalSession session, RollbackDatabase database, Arguments arguments, @Arg(desc = "Player uuid/name") UUID other, @ArgFlag(name = 'p', desc = "Page to view.", def = "") Integer page) {
int index = session.getHistoryIndex();
List<Supplier<? extends ChangeSet>> history = Lists.transform(session.getHistory(), (Function<ChangeSet, Supplier<ChangeSet>>) input -> () -> input);
Location origin = player.getLocation();
String pageCommand = "/" + arguments.get().replaceAll("-p [0-9]+", "").trim();
Reference<PaginationBox> cached = player.getMeta(pageCommand);
PaginationBox pages = cached == null ? null : cached.get();
if (page == null || pages == null) {
pages = list(database, pageCommand, history, origin.toBlockPoint());
page = 1;
}
player.print(pages.create(page));
}
Aggregations