mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Merge remote-tracking branch 'upstream/master' into breaking
This commit is contained in:
@ -53,15 +53,17 @@ import com.sk89q.worldedit.util.Countable;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Implements biome-related commands such as "/biomelist".
|
||||
@ -102,11 +104,11 @@ public class BiomeCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
BiomeRegistry biomeRegistry = getBiomeRegistry();
|
||||
List<BaseBiome> biomes = biomeRegistry.getBiomes();
|
||||
List<BiomeType> biomes = biomeRegistry.getBiomes();
|
||||
int totalPages = biomes.size() / 19 + 1;
|
||||
Message msg = BBC.BIOME_LIST_HEADER.m(page, totalPages);
|
||||
String setBiome = Commands.getAlias(BiomeCommands.class, "/setbiome");
|
||||
for (BaseBiome biome : biomes) {
|
||||
for (BiomeType biome : biomes) {
|
||||
if (offset > 0) {
|
||||
offset--;
|
||||
} else {
|
||||
@ -150,12 +152,12 @@ public class BiomeCommands extends MethodCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
BaseBiome biome = player.getWorld().getBiome(blockPosition.toBlockPoint().toBlockVector2());
|
||||
biomes[biome.getId()]++;
|
||||
BiomeType biome = player.getWorld().getBiome(blockPosition.toBlockPoint().toBlockVector2());
|
||||
biomes[biome.getInternalId()]++;
|
||||
size = 1;
|
||||
} else if (args.hasFlag('p')) {
|
||||
BaseBiome biome = player.getWorld().getBiome(player.getLocation().toBlockPoint().toBlockVector2());
|
||||
biomes[biome.getId()]++;
|
||||
BiomeType biome = player.getWorld().getBiome(player.getLocation().toBlockPoint().toBlockVector2());
|
||||
biomes[biome.getInternalId()]++;
|
||||
size = 1;
|
||||
} else {
|
||||
World world = player.getWorld();
|
||||
@ -181,15 +183,15 @@ public class BiomeCommands extends MethodCommands {
|
||||
|
||||
BBC.BIOME_LIST_HEADER.send(player, 1, 1);
|
||||
|
||||
List<Countable<BaseBiome>> distribution = new ArrayList<>();
|
||||
List<Countable<BiomeType>> distribution = new ArrayList<>();
|
||||
for (int i = 0; i < biomes.length; i++) {
|
||||
int count = biomes[i];
|
||||
if (count != 0) {
|
||||
distribution.add(new Countable<>(new BaseBiome(i), count));
|
||||
distribution.add(new Countable<>(new BiomeType(i), count));
|
||||
}
|
||||
}
|
||||
Collections.sort(distribution);
|
||||
for (Countable<BaseBiome> c : distribution) {
|
||||
for (Countable<BiomeType> c : distribution) {
|
||||
BiomeData data = biomeRegistry.getData(c.getID());
|
||||
String str = String.format("%-7s (%.3f%%) %s #%d",
|
||||
String.valueOf(c.getAmount()),
|
||||
@ -212,7 +214,7 @@ public class BiomeCommands extends MethodCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.biome.set")
|
||||
public void setBiome(Player player, LocalSession session, EditSession editSession, BaseBiome target, @Switch('p') boolean atPosition) throws WorldEditException {
|
||||
public void setBiome(Player player, LocalSession session, EditSession editSession, BiomeType target, @Switch('p') boolean atPosition) throws WorldEditException {
|
||||
World world = player.getWorld();
|
||||
Region region;
|
||||
Mask mask = editSession.getMask();
|
||||
|
@ -37,8 +37,6 @@ import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Step;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.command.tool.brush.*;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -633,7 +631,7 @@ public class BrushCommands extends BrushProcessor {
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.smooth")
|
||||
public BrushSettings smoothBrush(Player player, LocalSession session, EditSession editSession,
|
||||
@Optional("2") Expression radius, @Optional("4") int iterations, CommandContext context) throws WorldEditException {
|
||||
@Optional("2") Expression radius, @Optional("4") int iterations, @Optional Mask mask, CommandContext context) throws WorldEditException {
|
||||
|
||||
getWorldEdit().checkMaxBrushRadius(radius);
|
||||
|
||||
@ -642,7 +640,7 @@ public class BrushCommands extends BrushProcessor {
|
||||
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
|
||||
|
||||
return set(session, context,
|
||||
new SmoothBrush(iterations))
|
||||
new SmoothBrush(iterations, mask))
|
||||
.setSize(radius);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
@ -106,7 +105,7 @@ public class ChunkCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.delchunks")
|
||||
@Logging(REGION)
|
||||
public void deleteChunks(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void deleteChunks(Player player, LocalSession session) throws WorldEditException {
|
||||
player.print(BBC.getPrefix() + "Note that this command does not yet support the mcregion format.");
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
|
@ -579,7 +579,7 @@ public class ClipboardCommands extends MethodCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.flip")
|
||||
public void flip(Player player, LocalSession session, EditSession editSession,
|
||||
public void flip(Player player, LocalSession session,
|
||||
@Optional(Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException {
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
AffineTransform transform = new AffineTransform();
|
||||
@ -597,7 +597,7 @@ public class ClipboardCommands extends MethodCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.clear")
|
||||
public void clearClipboard(Player player, LocalSession session, EditSession editSession) throws WorldEditException {
|
||||
public void clearClipboard(Player player, LocalSession session) throws WorldEditException {
|
||||
session.setClipboard(null);
|
||||
BBC.CLIPBOARD_CLEARED.send(player);
|
||||
}
|
||||
|
@ -26,8 +26,6 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.CombinedTransform;
|
||||
@ -96,20 +94,18 @@ public class FlattenedClipboardTransform {
|
||||
|
||||
MutableVector3 newMinimum = new MutableVector3(corners[0]);
|
||||
MutableVector3 newMaximum = new MutableVector3(corners[0]);
|
||||
// MutableVector3 cbv = new MutableVector3();
|
||||
for (int i = 1; i < corners.length; i++) {
|
||||
MutableVector3 cbv = new MutableVector3(corners[i]);
|
||||
Vector3 cbv = corners[i];
|
||||
newMinimum = newMinimum.setComponents(newMinimum.getMinimum(cbv));
|
||||
newMaximum = newMaximum.setComponents(newMaximum.getMaximum(cbv));
|
||||
}
|
||||
|
||||
// After transformation, the points may not really sit on a block,
|
||||
// so we should expand the region for edge cases
|
||||
newMinimum.mutX(Math.ceil(Math.floor(newMinimum.getX())));
|
||||
newMinimum.mutY(Math.ceil(Math.floor(newMinimum.getY())));
|
||||
newMinimum.mutZ(Math.ceil(Math.floor(newMinimum.getZ())));
|
||||
newMinimum = newMinimum.floor();
|
||||
newMaximum = newMaximum.ceil();
|
||||
|
||||
return new CuboidRegion(BlockVector3.at(newMinimum.getX(), newMinimum.getY(), newMinimum.getZ()), BlockVector3.at(newMaximum.getX(), newMaximum.getY(), newMaximum.getZ()));
|
||||
return new CuboidRegion(newMinimum.toBlockPoint(), newMaximum.toBlockPoint());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ public class GeneralCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.limit")
|
||||
public void limit(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void limit(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
boolean mayDisable = player.hasPermission("worldedit.limit.unrestricted");
|
||||
@ -74,13 +74,43 @@ public class GeneralCommands {
|
||||
|
||||
session.setBlockChangeLimit(limit);
|
||||
|
||||
if (limit != -1) {
|
||||
player.print("Block change limit set to " + limit + ". (Use //limit -1 to go back to the default.)");
|
||||
if (limit != config.defaultChangeLimit) {
|
||||
player.print("Block change limit set to " + limit + ". (Use //limit to go back to the default.)");
|
||||
} else {
|
||||
player.print("Block change limit set to " + limit + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/timeout" },
|
||||
usage = "[time]",
|
||||
desc = "Modify evaluation timeout time.",
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.timeout")
|
||||
public void timeout(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
boolean mayDisable = player.hasPermission("worldedit.timeout.unrestricted");
|
||||
|
||||
int limit = args.argsLength() == 0 ? config.calculationTimeout : Math.max(-1, args.getInteger(0));
|
||||
if (!mayDisable && config.maxCalculationTimeout > -1) {
|
||||
if (limit > config.maxCalculationTimeout) {
|
||||
player.printError("Your maximum allowable timeout is " + config.maxCalculationTimeout + " ms.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
session.setTimeout(limit);
|
||||
|
||||
if (limit != config.calculationTimeout) {
|
||||
player.print("Timeout time set to " + limit + " ms. (Use //timeout to go back to the default.)");
|
||||
} else {
|
||||
player.print("Timeout time set to " + limit + " ms.");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/fast" },
|
||||
usage = "[on|off]",
|
||||
@ -89,7 +119,7 @@ public class GeneralCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.fast")
|
||||
public void fast(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void fast(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
String newState = args.getString(0, null);
|
||||
if (session.hasFastMode()) {
|
||||
@ -111,6 +141,41 @@ public class GeneralCommands {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/drawsel" },
|
||||
usage = "[on|off]",
|
||||
desc = "Toggle drawing the current selection",
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.drawsel")
|
||||
public void drawSelection(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
if (!WorldEdit.getInstance().getConfiguration().serverSideCUI) {
|
||||
throw new DisallowedUsageException("This functionality is disabled in the configuration!");
|
||||
}
|
||||
String newState = args.getString(0, null);
|
||||
if (session.shouldUseServerCUI()) {
|
||||
if ("on".equals(newState)) {
|
||||
player.printError("Server CUI already enabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
session.setUseServerCUI(false);
|
||||
session.updateServerCUI(player);
|
||||
player.print("Server CUI disabled.");
|
||||
} else {
|
||||
if ("off".equals(newState)) {
|
||||
player.printError("Server CUI already disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
session.setUseServerCUI(true);
|
||||
session.updateServerCUI(player);
|
||||
player.print("Server CUI enabled. This only supports cuboid regions, with a maximum size of 32x32x32.");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/gmask", "gmask" },
|
||||
usage = "[mask]",
|
||||
@ -119,7 +184,7 @@ public class GeneralCommands {
|
||||
max = -1
|
||||
)
|
||||
@CommandPermissions("worldedit.global-mask")
|
||||
public void gmask(Player player, LocalSession session, EditSession editSession, @Optional Mask mask) throws WorldEditException {
|
||||
public void gmask(Player player, LocalSession session, @Optional Mask mask) throws WorldEditException {
|
||||
if (mask == null) {
|
||||
session.setMask((Mask) null);
|
||||
player.print("Global mask disabled.");
|
||||
@ -136,7 +201,7 @@ public class GeneralCommands {
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
public void togglePlace(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void togglePlace(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
if (session.togglePlacementPosition()) {
|
||||
player.print("Now placing at pos #1.");
|
||||
|
@ -54,19 +54,7 @@ import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.binding.Text;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
/**
|
||||
* Commands for the generation of shapes and other objects.
|
||||
@ -287,7 +275,7 @@ public class GenerationCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.generation.forest")
|
||||
@Logging(POSITION)
|
||||
@SuppressWarnings("deprecation")
|
||||
public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size, @Optional("tree") TreeType type, @Optional("5") double density) throws WorldEditException, ParameterException {
|
||||
public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size, @Optional("tree") TreeType type, @Optional("5") @Range(min = 0, max = 100) double density) throws WorldEditException, ParameterException {
|
||||
density = density / 100;
|
||||
int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, type);
|
||||
player.print(BBC.getPrefix() + affected + " trees created.");
|
||||
@ -430,16 +418,16 @@ public class GenerationCommands extends MethodCommands {
|
||||
min = 2,
|
||||
max = -1
|
||||
)
|
||||
@CommandPermissions({"worldedit.generation.shape", "worldedit.biome.set"})
|
||||
@CommandPermissions("worldedit.generation.shape.biome")
|
||||
@Logging(ALL)
|
||||
public void generateBiome(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
BaseBiome target,
|
||||
BiomeType target,
|
||||
@Text String expression,
|
||||
@Switch('h') boolean hollow,
|
||||
@Switch('r') boolean useRawCoords,
|
||||
@Switch('o') boolean offset,
|
||||
@Switch('c') boolean offsetCenter, CommandContext context) throws WorldEditException {
|
||||
@Switch('c') boolean offsetCenter) throws WorldEditException {
|
||||
final Vector3 zero;
|
||||
Vector3 unit;
|
||||
|
||||
|
@ -265,7 +265,6 @@ public class HistoryCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.history.redo")
|
||||
public void redo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
int times = Math.max(1, args.getInteger(0, 1));
|
||||
|
||||
EditSession redone = null;
|
||||
|
@ -27,7 +27,6 @@ import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
@ -134,7 +133,7 @@ public class NavigationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.ceiling")
|
||||
@Logging(POSITION)
|
||||
public void ceiling(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void ceiling(Player player, CommandContext args) throws WorldEditException {
|
||||
|
||||
final int clearance = args.argsLength() > 0 ?
|
||||
Math.max(0, args.getInteger(0)) : 0;
|
||||
@ -155,7 +154,7 @@ public class NavigationCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.thru.command")
|
||||
public void thru(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void thru(Player player) throws WorldEditException {
|
||||
if (player.passThroughForwardWall(6)) {
|
||||
BBC.WHOOSH.send(player);
|
||||
} else {
|
||||
@ -207,7 +206,7 @@ public class NavigationCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.navigation.up")
|
||||
@Logging(POSITION)
|
||||
public void up(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void up(Player player, CommandContext args) throws WorldEditException {
|
||||
final int distance = args.getInteger(0);
|
||||
|
||||
final boolean alwaysGlass = getAlwaysGlass(args);
|
||||
|
@ -53,7 +53,6 @@ import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||
@ -67,10 +66,6 @@ import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.binding.Text;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.biome.Biomes;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@ -454,20 +449,19 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/smooth"},
|
||||
usage = "[iterations]",
|
||||
flags = "n",
|
||||
desc = "Smooth the elevation in the selection",
|
||||
help =
|
||||
"Smooths the elevation in the selection.\n" +
|
||||
"The -n flag makes it only consider naturally occuring blocks.\n" +
|
||||
"The -s flag makes it only consider snow.",
|
||||
min = 0,
|
||||
max = 2
|
||||
aliases = { "/smooth" },
|
||||
usage = "[iterations] [filter]",
|
||||
desc = "Smooth the elevation in the selection",
|
||||
help =
|
||||
"Smooths the elevation in the selection.\n" +
|
||||
"Optionally, restricts the height map to a set of blocks specified with mask syntax.\n" +
|
||||
"For example, '//smooth 1 grass_block,dirt,stone' would only smooth natural surface terrain.",
|
||||
min = 0,
|
||||
max = 2
|
||||
)
|
||||
@CommandPermissions("worldedit.region.smoothsnow")
|
||||
@Logging(REGION)
|
||||
public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Switch('n') boolean affectNatural, @Switch('s') boolean snow, CommandContext context) throws WorldEditException {
|
||||
public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Optional Mask mask, @Switch('s') boolean snow, CommandContext context) throws WorldEditException {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||
@ -477,8 +471,8 @@ public class RegionCommands extends MethodCommands {
|
||||
}
|
||||
player.checkConfirmationRegion(() -> {
|
||||
try {
|
||||
HeightMap heightMap = new HeightMap(editSession, region, affectNatural, snow);
|
||||
HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1));
|
||||
HeightMap heightMap = new HeightMap(editSession, region, mask, snow);
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||
int affected = heightMap.applyFilter(filter, iterations);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
} catch (Throwable e) {
|
||||
@ -523,7 +517,7 @@ public class RegionCommands extends MethodCommands {
|
||||
@Command(
|
||||
aliases = {"/move"},
|
||||
usage = "[count] [direction] [leave-id]",
|
||||
flags = "s",
|
||||
flags = "sbea",
|
||||
desc = "Move the contents of the selection",
|
||||
help =
|
||||
"Moves the contents of the selection.\n" +
|
||||
@ -707,10 +701,10 @@ public class RegionCommands extends MethodCommands {
|
||||
Mask sourceMask = session.getSourceMask();
|
||||
session.setMask((Mask) null);
|
||||
session.setSourceMask((Mask) null);
|
||||
BaseBiome biome = null;
|
||||
BiomeType biome = null;
|
||||
if (context.argsLength() >= 1) {
|
||||
BiomeRegistry biomeRegistry = worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
||||
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
|
||||
List<BiomeType> knownBiomes = biomeRegistry.getBiomes();
|
||||
biome = Biomes.findBiomeByName(knownBiomes, context.getString(0), biomeRegistry);
|
||||
}
|
||||
Long seed = context.argsLength() != 2 || !MathMan.isInteger(context.getString(1)) ? null : Long.parseLong(context.getString(1));
|
||||
@ -766,19 +760,10 @@ public class RegionCommands extends MethodCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.forest")
|
||||
@Logging(REGION)
|
||||
public void forest(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type,
|
||||
@Optional("5") @Range(min = 0, max = 100) double density,
|
||||
CommandContext context) throws WorldEditException {
|
||||
player.checkConfirmationRegion(() -> {
|
||||
ForestGenerator generator = new ForestGenerator(editSession, type);
|
||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
|
||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
||||
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density / 100));
|
||||
Operations.completeLegacy(visitor);
|
||||
|
||||
BBC.COMMAND_TREE.send(player, ground.getAffected());
|
||||
}, getArguments(context), region, context);
|
||||
|
||||
public void forest(Player player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type,
|
||||
@Optional("5") @Range(min = 0, max = 100) double density) throws WorldEditException {
|
||||
int affected = editSession.makeForest(region, density / 100, type);
|
||||
player.print(affected + " trees created.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -32,6 +32,7 @@ import com.boydti.fawe.object.schematic.StructureFormat;
|
||||
import com.boydti.fawe.object.schematic.visualizer.SchemVis;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.chat.Message;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
@ -55,23 +56,30 @@ import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.*;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
import static com.boydti.fawe.util.ReflectionUtils.as;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Commands that work with schematic files.
|
||||
@ -79,7 +87,12 @@ import static com.boydti.fawe.util.ReflectionUtils.as;
|
||||
@Command(aliases = {"schematic", "schem", "/schematic", "/schem", "clipboard", "/clipboard"}, desc = "Commands that work with schematic files")
|
||||
public class SchematicCommands extends MethodCommands {
|
||||
|
||||
private static final Logger log = Logger.getLogger(SchematicCommands.class.getCanonicalName());
|
||||
/**
|
||||
* 9 schematics per page fits in the MC chat window.
|
||||
*/
|
||||
private static final int SCHEMATICS_PER_PAGE = 9;
|
||||
private static final Logger log = LoggerFactory.getLogger(SchematicCommands.class);
|
||||
private final WorldEdit worldEdit;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -280,7 +293,7 @@ public class SchematicCommands extends MethodCommands {
|
||||
@Command(aliases = {"save"}, usage = "[format] <filename>", desc = "Save a schematic into your clipboard", help = "The default format for 1.13 is schem")
|
||||
@Deprecated
|
||||
@CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"})
|
||||
public void save(final Player player, final LocalSession session, @Optional("schem") final String formatName, String filename, @Switch('g') boolean global) throws CommandException, WorldEditException {
|
||||
public void save(final Player player, final LocalSession session, @Optional("schem") final String formatName, String filename, @Switch('g') boolean global, @Switch('f') boolean allowOverwrite) throws CommandException, WorldEditException {
|
||||
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
||||
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
if (format == null) {
|
||||
@ -324,6 +337,8 @@ public class SchematicCommands extends MethodCommands {
|
||||
try {
|
||||
if (!f.exists()) {
|
||||
f.createNewFile();
|
||||
} else if (!allowOverwrite) {
|
||||
BBC.SCHEMATIC_MOVE_EXISTS.send(player, f.getName());
|
||||
}
|
||||
try (FileOutputStream fos = new FileOutputStream(f)) {
|
||||
final ClipboardHolder holder = session.getClipboard();
|
||||
@ -363,7 +378,7 @@ public class SchematicCommands extends MethodCommands {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
player.printError("Schematic could not written: " + e.getMessage());
|
||||
log.log(Level.WARNING, "Failed to write a saved clipboard", e);
|
||||
log.warn("Failed to write a saved clipboard", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -645,6 +660,4 @@ public class SchematicCommands extends MethodCommands {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -192,8 +192,9 @@ public class ScriptingCommands {
|
||||
@Command(aliases = {".s"}, usage = "[args...]", desc = "Execute last CraftScript", min = 0, max = -1)
|
||||
@CommandPermissions("worldedit.scripting.execute")
|
||||
@Logging(ALL)
|
||||
public void executeLast(final Player player, final LocalSession session, final CommandContext args) throws WorldEditException {
|
||||
final String lastScript = session.getLastScript();
|
||||
public void executeLast(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
String lastScript = session.getLastScript();
|
||||
|
||||
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
|
||||
player.printError("You don't have permission to use that script.");
|
||||
|
@ -42,6 +42,9 @@ import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.block.BlockDistributionCounter;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -63,6 +66,8 @@ import com.sk89q.worldedit.util.formatting.Style;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
import java.io.File;
|
||||
@ -96,8 +101,9 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.pos")
|
||||
public void pos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
BlockVector3 pos;
|
||||
public void pos1(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
Location pos;
|
||||
|
||||
if (args.argsLength() == 1) {
|
||||
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
|
||||
@ -128,8 +134,9 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.pos")
|
||||
public void pos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
BlockVector3 pos;
|
||||
public void pos2(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
Location pos;
|
||||
if (args.argsLength() == 1) {
|
||||
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
|
||||
String[] coords = args.getString(0).split(",");
|
||||
@ -161,7 +168,7 @@ public class SelectionCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.selection.hpos")
|
||||
public void hpos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void hpos1(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
BlockVector3 pos = player.getBlockTrace(300).toBlockPoint();
|
||||
|
||||
if (pos != null) {
|
||||
@ -185,7 +192,7 @@ public class SelectionCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.selection.hpos")
|
||||
public void hpos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void hpos2(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
BlockVector3 pos = player.getBlockTrace(300).toBlockPoint();
|
||||
|
||||
if (pos != null) {
|
||||
@ -219,7 +226,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(POSITION)
|
||||
@CommandPermissions("worldedit.selection.chunk")
|
||||
public void chunk(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void chunk(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
final BlockVector3 min;
|
||||
final BlockVector3 max;
|
||||
final World world = player.getWorld();
|
||||
@ -278,7 +285,7 @@ public class SelectionCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.wand")
|
||||
public void wand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void wand(Player player) throws WorldEditException {
|
||||
player.giveItem(new BaseItemStack(ItemTypes.parse(we.getConfiguration().wandItem), 1));
|
||||
BBC.SELECTION_WAND.send(player);
|
||||
if (!FawePlayer.wrap(player).hasPermission("fawe.tips"))
|
||||
@ -294,6 +301,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.wand.toggle")
|
||||
public void toggleWand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
session.setToolControl(!session.isToolControlEnabled());
|
||||
|
||||
if (session.isToolControlEnabled()) {
|
||||
@ -312,7 +320,8 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.expand")
|
||||
public void expand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void expand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
// Special syntax (//expand vert) to expand the selection between
|
||||
// sky and bedrock.
|
||||
if (args.getString(0).equalsIgnoreCase("vert") || args.getString(0).equalsIgnoreCase("vertical")) {
|
||||
@ -402,7 +411,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.contract")
|
||||
public void contract(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void contract(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
List<BlockVector3> dirs = new ArrayList<>();
|
||||
int change = args.getInteger(0);
|
||||
@ -476,7 +485,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.shift")
|
||||
public void shift(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void shift(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
List<BlockVector3> dirs = new ArrayList<>();
|
||||
int change = args.getInteger(0);
|
||||
@ -523,7 +532,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.outset")
|
||||
public void outset(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void outset(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
region.expand(getChangesForEachDir(args));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
@ -546,7 +555,7 @@ public class SelectionCommands {
|
||||
)
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.selection.inset")
|
||||
public void inset(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void inset(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
region.contract(getChangesForEachDir(args));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
@ -726,7 +735,7 @@ public class SelectionCommands {
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
public void select(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void select(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
final World world = player.getWorld();
|
||||
if (args.argsLength() == 0) {
|
||||
session.getRegionSelector(world).clear();
|
||||
|
@ -39,7 +39,6 @@ import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Snapshot commands.
|
||||
@ -47,7 +46,6 @@ import java.util.logging.Logger;
|
||||
@Command(aliases = {"snapshot", "snap"}, desc = "List, load and view information related to snapshots")
|
||||
public class SnapshotCommands {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||
|
||||
private final WorldEdit we;
|
||||
@ -64,7 +62,7 @@ public class SnapshotCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.snapshots.list")
|
||||
public void list(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void list(Player player, CommandContext args) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
@ -93,10 +91,10 @@ public class SnapshotCommands {
|
||||
File dir = config.snapshotRepo.getDirectory();
|
||||
|
||||
try {
|
||||
logger.info("WorldEdit found no snapshots: looked in: "
|
||||
WorldEdit.logger.info("WorldEdit found no snapshots: looked in: "
|
||||
+ dir.getCanonicalPath());
|
||||
} catch (IOException e) {
|
||||
logger.info("WorldEdit found no snapshots: looked in "
|
||||
WorldEdit.logger.info("WorldEdit found no snapshots: looked in "
|
||||
+ "(NON-RESOLVABLE PATH - does it exist?): "
|
||||
+ dir.getPath());
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
import com.sk89q.worldedit.world.storage.MissingWorldException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
@ -47,8 +46,6 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
@Command(aliases = {}, desc = "[More Info](http://wiki.sk89q.com/wiki/WorldEdit/Snapshots)")
|
||||
public class SnapshotUtilCommands {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||
|
||||
private final WorldEdit we;
|
||||
|
||||
public SnapshotUtilCommands(WorldEdit we) {
|
||||
@ -99,10 +96,10 @@ public class SnapshotUtilCommands {
|
||||
File dir = config.snapshotRepo.getDirectory();
|
||||
|
||||
try {
|
||||
logger.info("FAWE found no snapshots: looked in: "
|
||||
WorldEdit.logger.info("FAWE found no snapshots: looked in: "
|
||||
+ dir.getCanonicalPath());
|
||||
} catch (IOException e) {
|
||||
logger.info("FAWE found no snapshots: looked in "
|
||||
WorldEdit.logger.info("FAWE found no snapshots: looked in "
|
||||
+ "(NON-RESOLVABLE PATH - does it exist?): "
|
||||
+ dir.getPath());
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class SuperPickaxeCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void single(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void single(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
session.setSuperPickaxe(new SinglePickaxe());
|
||||
session.enableSuperPickAxe();
|
||||
|
@ -24,7 +24,6 @@ import com.boydti.fawe.object.brush.InspectBrush;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -67,7 +66,7 @@ public class ToolCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.info")
|
||||
public void info(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void info(Player player, LocalSession session) throws WorldEditException {
|
||||
session.setTool(new QueryTool(), player);
|
||||
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
BBC.TOOL_INFO.send(player, itemStack.getType().getName());
|
||||
@ -123,7 +122,7 @@ public class ToolCommands {
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.tool.data-cycler")
|
||||
public void cycler(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void cycler(Player player, LocalSession session) throws WorldEditException {
|
||||
|
||||
session.setTool(new BlockDataCyler(), player);
|
||||
BBC.TOOL_CYCLER.send(player, player.getItemInHand(HandSide.MAIN_HAND).getType().getName());
|
||||
|
@ -22,7 +22,9 @@ package com.sk89q.worldedit.command;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
@ -48,7 +50,7 @@ public class ToolUtilCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.superpickaxe")
|
||||
public void togglePickaxe(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void togglePickaxe(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
String newState = args.getString(0, null);
|
||||
if (session.hasSuperPickAxe()) {
|
||||
@ -78,7 +80,7 @@ public class ToolUtilCommands {
|
||||
max = -1
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.mask")
|
||||
public void mask(Player player, LocalSession session, EditSession editSession, @Optional Mask mask) throws WorldEditException {
|
||||
public void mask(Player player, LocalSession session, @Optional Mask mask) throws WorldEditException {
|
||||
if (mask == null) {
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setMask(null);
|
||||
player.print("Brush mask disabled.");
|
||||
@ -96,7 +98,7 @@ public class ToolUtilCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.material")
|
||||
public void material(Player player, LocalSession session, EditSession editSession, Pattern pattern) throws WorldEditException {
|
||||
public void material(Player player, LocalSession session, Pattern pattern) throws WorldEditException {
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setFill(pattern);
|
||||
player.print("Brush material set.");
|
||||
}
|
||||
@ -109,7 +111,7 @@ public class ToolUtilCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.range")
|
||||
public void range(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
public void range(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
int range = args.getInteger(0);
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setRange(range);
|
||||
player.print("Brush range set.");
|
||||
@ -123,7 +125,9 @@ public class ToolUtilCommands {
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.size")
|
||||
public void size(Player player, LocalSession session, EditSession editSession, Expression radius) throws WorldEditException {
|
||||
public void size(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
|
||||
int radius = args.getInteger(0);
|
||||
we.checkMaxBrushRadius(radius);
|
||||
session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType()).setSize(radius);
|
||||
player.print("Brush size set.");
|
||||
|
@ -77,8 +77,12 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.command.*;
|
||||
import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.session.SessionOwner;
|
||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.util.command.PrimaryAliasComparator;
|
||||
import com.sk89q.worldedit.util.command.binding.Text;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParameterData;
|
||||
@ -283,28 +287,6 @@ public class UtilityCommands extends MethodCommands {
|
||||
if (depth == -1) depth = Integer.MAX_VALUE;
|
||||
int affected = editSession.fillXZ(pos, pattern, radius, (int) depth, true);
|
||||
player.print(BBC.getPrefix() + affected + " block(s) have been created.");
|
||||
//=======
|
||||
// public void fillr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
//
|
||||
// ParserContext context = new ParserContext();
|
||||
// context.setActor(player);
|
||||
// context.setWorld(player.getWorld());
|
||||
// context.setSession(session);
|
||||
// Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context);
|
||||
//
|
||||
// double radius = Math.max(1, args.getDouble(1));
|
||||
// we.checkMaxRadius(radius);
|
||||
// int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : Integer.MAX_VALUE;
|
||||
//
|
||||
// BlockVector3 pos = session.getPlacementPosition(player);
|
||||
// int affected = 0;
|
||||
// if (pattern instanceof BlockPattern) {
|
||||
// affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, true);
|
||||
// } else {
|
||||
// affected = editSession.fillXZ(pos, pattern, radius, depth, true);
|
||||
// }
|
||||
// player.print(affected + " block(s) have been created.");
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -435,8 +417,8 @@ public class UtilityCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.snow")
|
||||
@Logging(PLACEMENT)
|
||||
public void snow(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.simulateSnow(session.getPlacementPosition(player), size);
|
||||
player.print(BBC.getPrefix() + affected + " surfaces covered. Let it snow~");
|
||||
@ -452,8 +434,8 @@ public class UtilityCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.thaw")
|
||||
@Logging(PLACEMENT)
|
||||
public void thaw(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.thaw(session.getPlacementPosition(player), size);
|
||||
player.print(BBC.getPrefix() + affected + " surfaces thawed.");
|
||||
@ -463,6 +445,7 @@ public class UtilityCommands extends MethodCommands {
|
||||
aliases = {"/green", "green"},
|
||||
usage = "[radius]",
|
||||
desc = "Greens the area",
|
||||
help = "Converts dirt to grass blocks. -f also converts coarse dirt.",
|
||||
flags = "f",
|
||||
min = 0,
|
||||
max = 1
|
||||
@ -470,8 +453,8 @@ public class UtilityCommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.green")
|
||||
@Logging(PLACEMENT)
|
||||
public void green(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
final double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
|
||||
we.checkMaxRadius(size);
|
||||
final boolean onlyNormalDirt = !args.hasFlag('f');
|
||||
|
||||
final int affected = editSession.green(session.getPlacementPosition(player), size);
|
||||
@ -559,11 +542,7 @@ public class UtilityCommands extends MethodCommands {
|
||||
List<? extends Entity> entities;
|
||||
if (radius >= 0) {
|
||||
CylinderRegion region = CylinderRegion.createRadius(editSession, center, radius);
|
||||
entities = editSession.getEntities(region);
|
||||
} else {
|
||||
entities = editSession.getEntities();
|
||||
}
|
||||
visitors.add(new EntityVisitor(entities.iterator(), flags.createFunction()));
|
||||
} else {
|
||||
Platform platform = worldEdit.getPlatformManager().queryCapability(Capability.WORLD_EDITING);
|
||||
for (World world : platform.getWorlds()) {
|
||||
@ -582,7 +561,7 @@ public class UtilityCommands extends MethodCommands {
|
||||
|
||||
if (editSession != null) {
|
||||
session.remember(editSession);
|
||||
editSession.flushQueue();
|
||||
editSession.flushSession();
|
||||
}
|
||||
}
|
||||
|
||||
@ -642,7 +621,7 @@ public class UtilityCommands extends MethodCommands {
|
||||
|
||||
if (editSession != null) {
|
||||
session.remember(editSession);
|
||||
editSession.flushQueue();
|
||||
editSession.flushSession();
|
||||
}
|
||||
}
|
||||
|
||||
@ -674,10 +653,10 @@ public class UtilityCommands extends MethodCommands {
|
||||
actor.print(BBC.getPrefix() + "= " + result);
|
||||
} catch (EvaluationException e) {
|
||||
actor.printError(String.format(
|
||||
"'%s' could not be parsed as a valid expression", input));
|
||||
"'%s' could not be evaluated (error: %s)", input, e.getMessage()));
|
||||
} catch (ExpressionException e) {
|
||||
actor.printError(String.format(
|
||||
"'%s' could not be evaluated (error: %s)", input, e.getMessage()));
|
||||
"'%s' could not be parsed as a valid expression", input));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,6 +124,31 @@ public class WorldEditCommands {
|
||||
actor.print(BBC.getPrefix() + "Reloaded WorldEdit " + we.getVersion() + " and FAWE (" + Fawe.get().getVersion() + ")");
|
||||
}
|
||||
|
||||
@Command(aliases = {"report"}, desc = "Writes a report on WorldEdit", flags = "p", max = 0)
|
||||
@CommandPermissions({"worldedit.report"})
|
||||
public void report(Actor actor, CommandContext args) throws WorldEditException {
|
||||
ReportList report = new ReportList("Report");
|
||||
report.add(new SystemInfoReport());
|
||||
report.add(new ConfigReport());
|
||||
String result = report.toString();
|
||||
|
||||
try {
|
||||
File dest = new File(we.getWorkingDirectoryFile(we.getConfiguration().saveDir), "report.txt");
|
||||
Files.write(result, dest, Charset.forName("UTF-8"));
|
||||
actor.print("WorldEdit report written to " + dest.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
actor.printError("Failed to write report: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (args.hasFlag('p')) {
|
||||
actor.checkPermission("worldedit.report.pastebin");
|
||||
ActorCallbackPaste.pastebin(
|
||||
we.getSupervisor(), actor, result, "WorldEdit report: %s.report",
|
||||
WorldEdit.getInstance().getPlatformManager().getCommandManager().getExceptionConverter()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"update"},
|
||||
usage = "",
|
||||
@ -252,7 +277,7 @@ public class WorldEditCommands {
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
public void cui(Player player, LocalSession session, CommandContext args) throws WorldEditException {
|
||||
public void cui(Player player, LocalSession session) throws WorldEditException {
|
||||
session.setCUISupport(true);
|
||||
session.dispatchCUISetup(player);
|
||||
}
|
||||
|
@ -89,12 +89,14 @@ public class SelectionCommand extends SimpleCommand<Operation> {
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(player);
|
||||
Region selection = session.getSelection(player.getWorld());
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
editSession.enableQueue();
|
||||
editSession.enableStandardMode();
|
||||
locals.put(EditSession.class, editSession);
|
||||
session.tellVersion(player);
|
||||
EditContext editContext = new EditContext();
|
||||
editContext.setDestination(locals.get(EditSession.class));
|
||||
editContext.setRegion(selection);
|
||||
editContext.setSession(session);
|
||||
|
||||
Operation operation = operationFactory.createFromContext(editContext);
|
||||
// Shortcut
|
||||
if (selection instanceof CuboidRegion && editSession.hasFastMode() && operation instanceof RegionVisitor) {
|
||||
|
@ -76,7 +76,8 @@ public class ShapedBrushCommand extends SimpleCommand<Object> {
|
||||
WorldEdit.getInstance().checkMaxBrushRadius(radius);
|
||||
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||
tool.setSize(radius);
|
||||
tool.setBrush(new OperationFactoryBrush(factory, regionFactory), permission);
|
||||
tool.setFill(null);
|
||||
tool.setBrush(new OperationFactoryBrush(factory, regionFactory, session), permission);
|
||||
} catch (MaxBrushRadiusException | InvalidToolBindException e) {
|
||||
WorldEdit.getInstance().getPlatformManager().getCommandManager().getExceptionConverter().convert(e);
|
||||
}
|
||||
|
@ -6,6 +6,9 @@ import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
@ -40,33 +43,21 @@ public class AreaPickaxe implements BlockTool {
|
||||
return true;
|
||||
}
|
||||
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||
|
||||
for (int x = ox - range; x <= ox + range; ++x) {
|
||||
for (int z = oz - range; z <= oz + range; ++z) {
|
||||
for (int y = oy + range; y >= oy - range; --y) {
|
||||
if (initialType.equals(editSession.getLazyBlock(x, y, z))) {
|
||||
continue;
|
||||
// try (EditSession editSession = session.createEditSession(player)) {
|
||||
// editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||
//
|
||||
// try {
|
||||
// for (int x = ox - range; x <= ox + range; ++x) {
|
||||
// for (int y = oy - range; y <= oy + range; ++y) {
|
||||
// for (int z = oz - range; z <= oz + range; ++z) {
|
||||
// BlockVector3 pos = new BlockVector3(x, y, z);
|
||||
// if (editSession.getBlock(pos).getBlockType() != initialType) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// ((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toBlockPoint().distanceSq(pos));
|
||||
//
|
||||
// editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
|
||||
// }
|
||||
}
|
||||
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
|
||||
}
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
}
|
||||
editSession.flushQueue();
|
||||
|
@ -25,13 +25,15 @@ import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
/**
|
||||
* A mode that replaces one block.
|
||||
*/
|
||||
public class BlockReplacer implements DoubleActionBlockTool {
|
||||
|
||||
@ -58,7 +60,6 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
||||
if (bag != null) {
|
||||
bag.flushChanges();
|
||||
}
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -472,14 +472,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
||||
MaskIntersection newMask = new MaskIntersection(existingMask);
|
||||
newMask.add(mask);
|
||||
editSession.setMask(newMask);
|
||||
//=======
|
||||
// try {
|
||||
// brush.build(editSession, target.toBlockPoint(), material, size);
|
||||
// } catch (MaxChangedBlocksException e) {
|
||||
// player.printError("Max blocks change limit reached.");
|
||||
// } finally {
|
||||
// session.remember(editSession);
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
}
|
||||
Mask sourceMask = current.getSourceMask();
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.command.tool;
|
||||
|
||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -75,80 +76,26 @@ public class FloatingTreeRemover implements BlockTool {
|
||||
player.printError("That's not a tree.");
|
||||
return true;
|
||||
}
|
||||
final EditSession editSession = session.createEditSession(player);
|
||||
try /*(EditSession editSession = session.createEditSession(player))*/ {
|
||||
final Set<BlockVector3> blockSet = bfs(world, clicked.toBlockPoint());
|
||||
if (blockSet == null) {
|
||||
player.printError("That's not a floating tree.");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (BlockVector3 blockVector : blockSet) {
|
||||
final BlockState otherState = editSession.getBlock(blockVector);
|
||||
if (isTreeBlock(otherState.getBlockType())) {
|
||||
editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState());
|
||||
}
|
||||
}
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
try {
|
||||
Pattern replace = BlockTypes.AIR;
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(new BlockMask(editSession, logs, leaves), replace, 64, editSession);
|
||||
visitor.visit(pos);
|
||||
Operations.completeBlindly(visitor);
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private BlockVector3[] recurseDirections = {
|
||||
Direction.NORTH.toBlockVector(),
|
||||
Direction.EAST.toBlockVector(),
|
||||
Direction.SOUTH.toBlockVector(),
|
||||
Direction.WEST.toBlockVector(),
|
||||
Direction.UP.toBlockVector(),
|
||||
Direction.DOWN.toBlockVector(),
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper method.
|
||||
*
|
||||
* @param world the world that contains the tree
|
||||
* @param origin any point contained in the floating tree
|
||||
* @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom.
|
||||
*/
|
||||
private Set<BlockVector3> bfs(World world, BlockVector3 origin) throws MaxChangedBlocksException {
|
||||
final Set<BlockVector3> visited = new HashSet<>();
|
||||
final LinkedList<BlockVector3> queue = new LinkedList<>();
|
||||
|
||||
queue.addLast(origin);
|
||||
visited.add(origin);
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
final BlockVector3 current = queue.removeFirst();
|
||||
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||
final BlockVector3 next = current.add(recurseDirection);
|
||||
if (origin.distanceSq(next) > rangeSq) {
|
||||
// Maximum range exceeded => stop walking
|
||||
continue;
|
||||
}
|
||||
|
||||
if (visited.add(next)) {
|
||||
BlockState state = world.getBlock(next);
|
||||
if (state.getBlockType().getMaterial().isAir() || state.getBlockType() == BlockTypes.SNOW) {
|
||||
continue;
|
||||
}
|
||||
if (isTreeBlock(state.getBlockType())) {
|
||||
queue.addLast(next);
|
||||
} else {
|
||||
// we hit something solid - evaluate where we came from
|
||||
final BlockType currentType = world.getBlock(current).getBlockType();
|
||||
if (!BlockCategories.LEAVES.contains(currentType) && currentType != BlockTypes.VINE) {
|
||||
// log/shroom touching a wall/the ground => this is not a floating tree, bail out
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return visited;
|
||||
}
|
||||
}
|
||||
|
@ -69,17 +69,16 @@ public class FloodFillTool implements BlockTool {
|
||||
return true;
|
||||
}
|
||||
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
try {
|
||||
recurse(editSession, origin, origin, range, initialType, new HashSet<>());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
try {
|
||||
TODO fillDirection (but replace)
|
||||
recurse(editSession, origin, origin, range, initialType, new HashSet<>());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
}
|
||||
|
||||
editSession.flushQueue();
|
||||
session.remember(editSession);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -55,10 +55,8 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||
Location pos = getTargetFace(player);
|
||||
if (pos == null) return false;
|
||||
EditSession eS = session.createEditSession(player);
|
||||
try {
|
||||
// eS.disableBuffering();
|
||||
BlockVector3 blockPoint = pos.toBlockPoint();
|
||||
try (EditSession eS = session.createEditSession(player)) {
|
||||
BlockVector3 blockPoint = pos.toVector().toBlockPoint();
|
||||
BaseBlock applied = secondary.apply(blockPoint);
|
||||
if (applied.getBlockType().getMaterial().isAir()) {
|
||||
eS.setBlock(blockPoint, secondary);
|
||||
@ -74,12 +72,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
||||
|
||||
@Override
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||
Location pos = getTargetFace(player);
|
||||
if (pos == null) return false;
|
||||
EditSession eS = session.createEditSession(player);
|
||||
|
||||
try {
|
||||
// eS.disableBuffering();
|
||||
try (EditSession eS = session.createEditSession(player)) {
|
||||
BlockVector3 blockPoint = pos.toBlockPoint();
|
||||
BaseBlock applied = primary.apply(blockPoint);
|
||||
if (applied.getBlockType().getMaterial().isAir()) {
|
||||
|
@ -53,7 +53,6 @@ public class RecursivePickaxe implements BlockTool {
|
||||
|
||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
|
||||
|
||||
//<<<<<<< HEAD
|
||||
final int radius = (int) range;
|
||||
final BlockReplace replace = new BlockReplace(editSession, (editSession.nullBlock));
|
||||
editSession.setMask((Mask) null);
|
||||
@ -63,51 +62,6 @@ public class RecursivePickaxe implements BlockTool {
|
||||
|
||||
editSession.flushQueue();
|
||||
session.remember(editSession);
|
||||
//=======
|
||||
// try {
|
||||
// recurse(server, editSession, world, clicked.toBlockPoint(),
|
||||
// clicked.toBlockPoint(), range, initialType, new HashSet<>());
|
||||
// } catch (MaxChangedBlocksException e) {
|
||||
// player.printError("Max blocks change limit reached.");
|
||||
// } finally {
|
||||
// session.remember(editSession);
|
||||
// }
|
||||
// }
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// private static void recurse(Platform server, EditSession editSession, World world, BlockVector3 pos,
|
||||
// BlockVector3 origin, double size, BlockType initialType, Set<BlockVector3> visited) throws MaxChangedBlocksException {
|
||||
//
|
||||
// final double distanceSq = origin.distanceSq(pos);
|
||||
// if (distanceSq > size*size || visited.contains(pos)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// visited.add(pos);
|
||||
//
|
||||
// if (editSession.getBlock(pos).getBlockType() != initialType) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// world.queueBlockBreakEffect(server, pos, initialType, distanceSq);
|
||||
//
|
||||
// editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());
|
||||
//
|
||||
// recurse(server, editSession, world, pos.add(1, 0, 0),
|
||||
// origin, size, initialType, visited);
|
||||
// recurse(server, editSession, world, pos.add(-1, 0, 0),
|
||||
// origin, size, initialType, visited);
|
||||
// recurse(server, editSession, world, pos.add(0, 0, 1),
|
||||
// origin, size, initialType, visited);
|
||||
// recurse(server, editSession, world, pos.add(0, 0, -1),
|
||||
// origin, size, initialType, visited);
|
||||
// recurse(server, editSession, world, pos.add(0, 1, 0),
|
||||
// origin, size, initialType, visited);
|
||||
// recurse(server, editSession, world, pos.add(0, -1, 0),
|
||||
// origin, size, initialType, visited);
|
||||
// }
|
||||
|
||||
}
|
@ -50,24 +50,12 @@ public class SinglePickaxe implements BlockTool {
|
||||
&& !player.canDestroyBedrock()) {
|
||||
return true;
|
||||
}
|
||||
final EditSession editSession = session.createEditSession(player);
|
||||
try {
|
||||
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
|
||||
editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
}
|
||||
|
||||
try {
|
||||
if (editSession.setBlock(clicked.getBlockX(), clicked.getBlockY(), clicked.getBlockZ(), EditSession.nullBlock)) {
|
||||
// TODO FIXME play effect
|
||||
// world.playEffect(clicked, 2001, blockType);
|
||||
}
|
||||
} finally {
|
||||
editSession.flushQueue();
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -48,16 +48,15 @@ public class TreePlanter implements BlockTool {
|
||||
@Override
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
|
||||
try {
|
||||
try (EditSession editSession = session.createEditSession(player)) {
|
||||
boolean successful = false;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (treeType.generate(editSession, clicked.add(0, 1, 0).toBlockPoint())) {
|
||||
successful = true;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (treeType.generate(editSession, clicked.add(0, 1, 0).toBlockPoint())) {
|
||||
successful = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!successful) {
|
||||
player.printError("A tree can't go there.");
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class CylinderBrush implements Brush {
|
||||
|
||||
|
@ -21,12 +21,14 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class GravityBrush implements Brush {
|
||||
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class HollowCylinderBrush implements Brush {
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class HollowSphereBrush implements Brush {
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.EditContext;
|
||||
@ -33,10 +34,16 @@ public class OperationFactoryBrush implements Brush {
|
||||
|
||||
private final Contextual<? extends Operation> operationFactory;
|
||||
private final RegionFactory regionFactory;
|
||||
private final LocalSession session;
|
||||
|
||||
public OperationFactoryBrush(Contextual<? extends Operation> operationFactory, RegionFactory regionFactory) {
|
||||
this(operationFactory, regionFactory, null);
|
||||
}
|
||||
|
||||
public OperationFactoryBrush(Contextual<? extends Operation> operationFactory, RegionFactory regionFactory, LocalSession session) {
|
||||
this.operationFactory = operationFactory;
|
||||
this.regionFactory = regionFactory;
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,6 +52,7 @@ public class OperationFactoryBrush implements Brush {
|
||||
context.setDestination(editSession);
|
||||
context.setRegion(regionFactory.createCenteredAt(position, size));
|
||||
context.setFill(pattern);
|
||||
context.setSession(session);
|
||||
Operation operation = operationFactory.createFromContext(context);
|
||||
Operations.completeLegacy(operation);
|
||||
}
|
||||
|
@ -21,9 +21,10 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMap;
|
||||
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
||||
@ -31,12 +32,20 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class SmoothBrush implements Brush {
|
||||
|
||||
private final Mask mask;
|
||||
private int iterations;
|
||||
|
||||
public SmoothBrush(int iterations) {
|
||||
this(iterations, null);
|
||||
}
|
||||
|
||||
public SmoothBrush(int iterations, @Nullable Mask mask) {
|
||||
this.iterations = iterations;
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,7 +54,7 @@ public class SmoothBrush implements Brush {
|
||||
Location min = new Location(editSession.getWorld(), posDouble.subtract(size, size, size));
|
||||
BlockVector3 max = posDouble.add(size, size + 10, size).toBlockPoint();
|
||||
Region region = new CuboidRegion(editSession.getWorld(), min.toBlockPoint(), max);
|
||||
HeightMap heightMap = new HeightMap(editSession, region);
|
||||
HeightMap heightMap = new HeightMap(editSession, region, mask);
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||
heightMap.applyFilter(filter, iterations);
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.command.tool.brush;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class SphereBrush implements Brush {
|
||||
|
Reference in New Issue
Block a user