FAVS
- Support for //gmask
- Support for //gsmask
- Support for //gtransform
- Suport for /v <pattern>
improved ingame changelog info
Increase tick limiter default item spawn limit
Fixes #632
Fixes #629
Fixes #627
Fixes #628
This commit is contained in:
Jesse Boyd 2017-07-09 22:54:04 +10:00
parent 41833188c5
commit 03b4aaad3c
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
35 changed files with 935 additions and 405 deletions

View File

@ -2,8 +2,10 @@ repositories {
flatDir {dirs 'lib'}
}
dependencies {
compile 'com.destroystokyo.paper:paper-api:1.12-R0.1-SNAPSHOT'
compile project(':core')
compile('com.destroystokyo.paper:paper-api:1.12-R0.1-SNAPSHOT') {
exclude group: 'net.md-5'
}
compile 'org.bukkit.craftbukkitv1_10:craftbukkitv1_10:1.10'
compile 'org.bukkit.craftbukkitv1_11:Craftbukkit:1.11'
compile 'org.bukkit.craftbukkitv1_12:Craftbukkit:1.12'

View File

@ -1,18 +1,6 @@
package com.boydti.fawe.bukkit;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
import com.boydti.fawe.bukkit.v0.BukkitQueue_All;
import com.boydti.fawe.bukkit.v1_10.BukkitQueue_1_10;
import com.boydti.fawe.bukkit.v1_11.BukkitQueue_1_11;
import com.boydti.fawe.bukkit.v1_12.BukkitQueue_1_12;
import com.boydti.fawe.bukkit.v1_12.NMSRegistryDumper;
import com.boydti.fawe.bukkit.v1_7.BukkitQueue17;
import com.boydti.fawe.bukkit.v1_8.BukkitQueue18R3;
import com.boydti.fawe.bukkit.v1_9.BukkitQueue_1_9_R1;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.util.MainUtil;
import com.sk89q.worldedit.world.World;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
@ -59,80 +47,8 @@ public class BukkitMain extends JavaPlugin {
}
}
private Version version = Version.NONE;
@Override
public void onEnable() {
FaweBukkit imp = new FaweBukkit(this);
for (Version v : Version.values()) {
try {
BukkitQueue_0.checkVersion(v.name());
this.version = v;
if (version == Version.v1_12_R1) {
try {
Fawe.debug("Running 1.12 registry dumper!");
NMSRegistryDumper dumper = new NMSRegistryDumper(MainUtil.getFile(getDataFolder(), "extrablocks.json"));
dumper.run();
} catch (Throwable e) {
e.printStackTrace();
}
}
break;
} catch (IllegalStateException e) {}
}
}
public Version getVersion() {
return version;
}
public enum Version {
v1_7_R4,
v1_8_R3,
v1_9_R2,
v1_10_R1,
v1_11_R1,
v1_12_R1,
NONE,
}
public FaweQueue getQueue(World world) {
switch (version) {
case v1_7_R4:
return new BukkitQueue17(world);
case v1_8_R3:
return new BukkitQueue18R3(world);
case v1_9_R2:
return new BukkitQueue_1_9_R1(world);
case v1_10_R1:
return new BukkitQueue_1_10(world);
case v1_11_R1:
return new BukkitQueue_1_11(world);
case v1_12_R1:
return new BukkitQueue_1_12(world);
default:
case NONE:
return new BukkitQueue_All(world);
}
}
public FaweQueue getQueue(String world) {
switch (version) {
case v1_7_R4:
return new BukkitQueue17(world);
case v1_8_R3:
return new BukkitQueue18R3(world);
case v1_9_R2:
return new BukkitQueue_1_9_R1(world);
case v1_10_R1:
return new BukkitQueue_1_10(world);
case v1_11_R1:
return new BukkitQueue_1_11(world);
case v1_12_R1:
return new BukkitQueue_1_12(world);
default:
case NONE:
return new BukkitQueue_All(world);
}
}
}

View File

@ -11,8 +11,16 @@ import com.boydti.fawe.bukkit.regions.PreciousStonesFeature;
import com.boydti.fawe.bukkit.regions.ResidenceFeature;
import com.boydti.fawe.bukkit.regions.TownyFeature;
import com.boydti.fawe.bukkit.regions.Worldguard;
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
import com.boydti.fawe.bukkit.v0.BukkitQueue_All;
import com.boydti.fawe.bukkit.v0.ChunkListener;
import com.boydti.fawe.bukkit.v1_10.BukkitQueue_1_10;
import com.boydti.fawe.bukkit.v1_11.BukkitQueue_1_11;
import com.boydti.fawe.bukkit.v1_12.BukkitQueue_1_12;
import com.boydti.fawe.bukkit.v1_12.NMSRegistryDumper;
import com.boydti.fawe.bukkit.v1_7.BukkitQueue17;
import com.boydti.fawe.bukkit.v1_8.BukkitQueue18R3;
import com.boydti.fawe.bukkit.v1_9.BukkitQueue_1_9_R1;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweCommand;
@ -214,8 +222,6 @@ public class FaweBukkit implements IFawe, Listener {
return new BukkitTaskMan(plugin);
}
private int[] version;
private boolean hasNMS = true;
private boolean playerChunk = false;
@ -234,7 +240,7 @@ public class FaweBukkit implements IFawe, Listener {
} catch (Throwable ignore) {}
}
try {
return plugin.getQueue(world);
return getQueue(world);
} catch (Throwable ignore) {
// Disable incompatible settings
Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level
@ -289,7 +295,7 @@ public class FaweBukkit implements IFawe, Listener {
}
Throwable error = null;
try {
return plugin.getQueue(world);
return getQueue(world);
} catch (Throwable ignore) {
error = ignore;
}
@ -465,4 +471,79 @@ public class FaweBukkit implements IFawe, Listener {
}
return ((BlocksHubBukkit) blocksHubPlugin).getApi();
}
private Version version = null;
public Version getVersion() {
Version tmp = this.version;
if (tmp == null) {
for (Version v : Version.values()) {
try {
BukkitQueue_0.checkVersion(v.name());
this.version = tmp = v;
if (tmp == Version.v1_12_R1) {
try {
Fawe.debug("Running 1.12 registry dumper!");
NMSRegistryDumper dumper = new NMSRegistryDumper(MainUtil.getFile(plugin.getDataFolder(), "extrablocks.json"));
dumper.run();
} catch (Throwable e) {
e.printStackTrace();
}
}
break;
} catch (IllegalStateException e) {}
}
}
return tmp;
}
public enum Version {
v1_7_R4,
v1_8_R3,
v1_9_R2,
v1_10_R1,
v1_11_R1,
v1_12_R1,
NONE,
}
private FaweQueue getQueue(World world) {
switch (getVersion()) {
case v1_7_R4:
return new BukkitQueue17(world);
case v1_8_R3:
return new BukkitQueue18R3(world);
case v1_9_R2:
return new BukkitQueue_1_9_R1(world);
case v1_10_R1:
return new BukkitQueue_1_10(world);
case v1_11_R1:
return new BukkitQueue_1_11(world);
case v1_12_R1:
return new BukkitQueue_1_12(world);
default:
case NONE:
return new BukkitQueue_All(world);
}
}
private FaweQueue getQueue(String world) {
switch (getVersion()) {
case v1_7_R4:
return new BukkitQueue17(world);
case v1_8_R3:
return new BukkitQueue18R3(world);
case v1_9_R2:
return new BukkitQueue_1_9_R1(world);
case v1_10_R1:
return new BukkitQueue_1_10(world);
case v1_11_R1:
return new BukkitQueue_1_11(world);
case v1_12_R1:
return new BukkitQueue_1_12(world);
default:
case NONE:
return new BukkitQueue_All(world);
}
}
}

View File

@ -117,6 +117,7 @@ public class BukkitQueue_1_12 extends BukkitQueue_0<net.minecraft.server.v1_12_R
static {
try {
emptySection = new ChunkSection(0, true);
Arrays.fill(emptySection.getSkyLightArray().asBytes(), (byte) 255);
fieldSection = ChunkSection.class.getDeclaredField("blockIds");
fieldTickingBlockCount = ChunkSection.class.getDeclaredField("tickingBlockCount");
fieldNonEmptyBlockCount = ChunkSection.class.getDeclaredField("nonEmptyBlockCount");

View File

@ -11,6 +11,7 @@ import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.world.biome.BaseBiome;
import java.io.File;
import java.lang.reflect.Field;
@ -62,7 +63,7 @@ import org.bukkit.util.Vector;
* @see #wrap(org.bukkit.World)
* @see #create(org.bukkit.WorldCreator)
*/
public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue{
public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue {
private World parent;
private FaweQueue queue;
@ -165,8 +166,9 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
return wrap(world);
}
public void commit() {
public Operation commit() {
flush();
return null;
}
public void flush() {
@ -584,7 +586,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
}
@Override
public List<Entity> getEntities() {
public List getEntities() {
return TaskManager.IMP.sync(new RunnableVal<List<Entity>>() {
@Override
public void run(List<Entity> value) {

View File

@ -118,7 +118,7 @@ public class BukkitWorld extends LocalWorld {
private void addEntities(Entity ent, Collection<com.sk89q.worldedit.entity.Entity> ents) {
ents.add(adapt(ent));
switch (Fawe.<FaweBukkit>imp().getPlugin().getVersion()) {
switch (Fawe.<FaweBukkit>imp().getVersion()) {
case v1_7_R4:
case v1_8_R3:
case v1_9_R2:
@ -538,14 +538,6 @@ public class BukkitWorld extends LocalWorld {
}
}
/**
* @deprecated Use {@link #setBlock(Vector, BaseBlock, boolean)}
*/
@Deprecated
public boolean setBlock(Vector pt, com.sk89q.worldedit.foundation.Block block, boolean notifyAdjacent) throws WorldEditException {
return setBlock(pt, (BaseBlock) block, notifyAdjacent);
}
public static Class<?> inject() {
return BukkitWorld.class;
}

View File

@ -4,8 +4,11 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.extent.NullExtent;
import com.boydti.fawe.object.extent.ResettableExtent;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
@ -14,6 +17,7 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.command.binding.Range;
import com.sk89q.worldedit.util.command.binding.Text;
import com.sk89q.worldedit.util.command.binding.Validate;
@ -42,8 +46,7 @@ public class FawePrimitiveBinding extends BindingHelper {
}
}
private static void validate(long number, Annotation[] modifiers)
throws ParameterException {
private static void validate(long number, Annotation[] modifiers) throws ParameterException {
for (Annotation modifier : modifiers) {
if (modifier instanceof Range) {
Range range = (Range) modifier;
@ -62,6 +65,26 @@ public class FawePrimitiveBinding extends BindingHelper {
}
}
@BindingMatch(
type = {Extent.class},
behavior = BindingBehavior.PROVIDES
)
public Extent getExtent(ArgumentStack context) throws ParameterException {
Extent extent = context.getContext().getLocals().get(EditSession.class);
if (extent != null) return extent;
extent = Request.request().getExtent();
if (extent != null) return extent;
Actor actor = context.getContext().getLocals().get(Actor.class);
if (actor == null) throw new ParameterException("No player to get a session for");
if (!(actor instanceof Player)) throw new ParameterException("Caller is not a player");
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor);
EditSession editSession = session.createEditSession((Player) actor);
editSession.enableQueue();
context.getContext().getLocals().put(EditSession.class, editSession);
session.tellVersion(actor);
return editSession;
}
/**
* Gets an {@link com.boydti.fawe.object.FawePlayer} from a {@link ArgumentStack}.
*

View File

@ -341,7 +341,7 @@ public class Settings extends Config {
@Comment("Max physics per interval (per chunk)")
public int PHYSICS = 8192;
@Comment("Max item spawns per interval (per chunk)")
public int ITEMS = 64;
public int ITEMS = 256;
}
public static class CLIPBOARD {

View File

@ -8,6 +8,7 @@ import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.IntegerPair;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.extent.LightingExtent;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.SetQueue;
@ -23,7 +24,7 @@ import java.util.UUID;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> extends FaweQueue {
public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> extends FaweQueue implements LightingExtent {
private WORLD impWorld;
@ -86,37 +87,18 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> exte
@Override
public void optimize() {
final ForkJoinPool pool = TaskManager.IMP.getPublicForkJoinPool();
// if (Fawe.get().isJava8())
{
map.forEachChunk(new RunnableVal<FaweChunk>() {
@Override
public void run(final FaweChunk chunk) {
pool.submit(new Runnable() {
@Override
public void run() {
chunk.optimize();
}
});
}
});
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
// else {
// final ArrayList<Runnable> tasks = new ArrayList<Runnable>(map.size());
// map.forEachChunk(new RunnableVal<FaweChunk>() {
// @Override
// public void run(final FaweChunk chunk) {
// tasks.add(new Runnable() {
// @Override
// public void run() {
// chunk.optimize();
// }
// });
// }
// });
// TaskManager.IMP.parallel(tasks);
// }
map.forEachChunk(new RunnableVal<FaweChunk>() {
@Override
public void run(final FaweChunk chunk) {
pool.submit(new Runnable() {
@Override
public void run() {
chunk.optimize();
}
});
}
});
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
public abstract WORLD getImpWorld();
@ -460,6 +442,11 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> exte
return getSkyLight(lastSection, x, y, z);
}
@Override
public int getBlockLight(int x, int y, int z) {
return getEmmittedLight(x, y, z);
}
@Override
public int getEmmittedLight(int x, int y, int z) {
int cx = x >> 4;

View File

@ -130,7 +130,7 @@ public class NMSRelighter implements Relighter {
}
}
public synchronized void updateBlockLight(Map<Long, long[][][]> map) {
public void updateBlockLight(Map<Long, long[][][]> map) {
int size = map.size();
if (size == 0) {
return;

View File

@ -28,6 +28,7 @@ public class PlotTrimFilter extends DeleteUninhabitedFilter {
private final MCAChunk reference;
private final LongHashSet occupiedRegions;
private final LongHashSet unoccupiedChunks;
private boolean referenceIsVoid;
public static boolean shouldSuggest(PlotArea area) {
IndependentPlotGenerator gen = area.getGenerator();
@ -48,7 +49,7 @@ public class PlotTrimFilter extends DeleteUninhabitedFilter {
}
this.hg = (HybridGen) gen;
this.hpw = (HybridPlotWorld) area;
if (!hpw.PLOT_BEDROCK || hpw.PLOT_SCHEMATIC || hpw.MAIN_BLOCK.length != 1 || hpw.TOP_BLOCK.length != 1) {
if (hpw.PLOT_SCHEMATIC || hpw.MAIN_BLOCK.length != 1 || hpw.TOP_BLOCK.length != 1) {
throw new UnsupportedOperationException("WIP - will implement later");
}
this.occupiedRegions = new LongHashSet();
@ -61,7 +62,11 @@ public class PlotTrimFilter extends DeleteUninhabitedFilter {
private MCAChunk calculateReference() {
MCAChunk reference = new MCAChunk(null, 0, 0);
reference.fillCuboid(0, 15, 0, 0, 0, 15, 7, (byte) 0);
if (hpw.PLOT_BEDROCK) {
reference.fillCuboid(0, 15, 0, 0, 0, 15, 7, (byte) 0);
} else if (hpw.MAIN_BLOCK[0].id == 0 && hpw.TOP_BLOCK[0].id == 0) {
referenceIsVoid = true;
}
reference.fillCuboid(0, 15, 1, hpw.PLOT_HEIGHT - 1, 0, 15, hpw.MAIN_BLOCK[0].id, (byte) 0);
reference.fillCuboid(0, 15, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, 0, 15, hpw.TOP_BLOCK[0].id, (byte) 0);
return reference;
@ -153,11 +158,21 @@ public class PlotTrimFilter extends DeleteUninhabitedFilter {
get().add(16 * 16 * 256);
return;
}
if (reference.idsEqual(chunk, false)) {
chunk.setDeleted(true);
get().add(16 * 16 * 256);
if (referenceIsVoid) {
for (int i = 0; i < chunk.ids.length; i++) {
byte[] arr = chunk.ids[i];
if (arr != null) {
for (byte b : arr) {
if (b != 0) return;
}
}
}
}
else if (!reference.idsEqual(chunk, false)) {
return;
}
chunk.setDeleted(true);
get().add(16 * 16 * 256);
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -129,16 +129,42 @@ public abstract class FawePlayer<T> extends Metadatable {
}
}
public void checkConfirmation(String command) throws RegionOperationException {
public void checkConfirmationRadius(String command, int radius) throws RegionOperationException {
if (getMeta("cmdConfirmRunning", false)) {
return;
}
Region sel = getSelection();
if (sel != null) {
Vector min = sel.getMinimumPoint();
Vector max = sel.getMaximumPoint();
int area = (int) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1));
if (area > 2 << 22) {
if (radius > 0) {
if (radius > 448) {
setMeta("cmdConfirm", command);
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(0, radius, command));
}
}
}
public void checkConfirmationStack(String command, Region region, int times) throws RegionOperationException {
if (getMeta("cmdConfirmRunning", false)) {
return;
}
if (region != null) {
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
if (area > 2 << 18) {
setMeta("cmdConfirm", command);
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command));
}
}
}
public void checkConfirmationRegion(String command, Region region) throws RegionOperationException {
if (getMeta("cmdConfirmRunning", false)) {
return;
}
if (region != null) {
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1));
if (area > 2 << 18) {
setMeta("cmdConfirm", command);
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.f(min, max, command));
}

View File

@ -16,8 +16,11 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome;
@ -30,7 +33,7 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedDeque;
import javax.annotation.Nullable;
public abstract class FaweQueue implements HasFaweQueue {
public abstract class FaweQueue implements HasFaweQueue, Extent {
private World weWorld;
private String world;
@ -56,6 +59,61 @@ public abstract class FaweQueue implements HasFaweQueue {
return NullRelighter.INSTANCE;
}
@Override
public Vector getMinimumPoint() {
return new Vector(-30000000, 0, -30000000);
}
@Override
public Vector getMaximumPoint() {
return new Vector(30000000, getMaxY(), 30000000);
}
@Override
public BaseBlock getLazyBlock(int x, int y, int z) {
int combinedId4Data = getCachedCombinedId4Data(x, y, z, 0);
int id = FaweCache.getId(combinedId4Data);
if (!FaweCache.hasNBT(id)) {
return FaweCache.CACHE_BLOCK[combinedId4Data];
}
try {
CompoundTag tile = getTileEntity(x, y, z);
if (tile != null) {
return new BaseBlock(id, FaweCache.getData(combinedId4Data), tile);
} else {
return FaweCache.CACHE_BLOCK[combinedId4Data];
}
} catch (Throwable e) {
MainUtil.handleError(e);
return FaweCache.CACHE_BLOCK[combinedId4Data];
}
}
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
return setBlock(x, y, z, block.getId(), block.getData(), block.getNbtData());
}
@Override
public BaseBlock getBlock(Vector position) {
return getLazyBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
}
@Override
public BaseBiome getBiome(Vector2D position) {
return null;
}
@Override
public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
return setBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ(), block);
}
@Override
public boolean setBiome(Vector2D position, BaseBiome biome) {
return setBiome(position.getBlockX(), position.getBlockZ(), biome);
}
public enum ProgressType {
QUEUE,
DISPATCH,
@ -204,10 +262,15 @@ public abstract class FaweQueue implements HasFaweQueue {
public boolean setBlock(int x, int y, int z, int id, int data, CompoundTag nbt) {
if (nbt != null) {
MainUtil.setPosition(nbt, x, y, z);
setTile(x, y, z, nbt);
if (setBlock(x, y, z, id, data)) {
MainUtil.setPosition(nbt, x, y, z);
setTile(x, y, z, nbt);
return true;
}
return false;
} else {
return setBlock(x, y, z, id, data);
}
return setBlock(x, y, z, id, data);
}
public abstract void setTile(int x, int y, int z, CompoundTag tag);

View File

@ -145,11 +145,12 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
@Override
public boolean setBlock(int x, int y, int z, final BaseBlock block) throws WorldEditException {
final short id = (short) block.getId();
int id = block.getId();
switch (id) {
case 63:
// Fix for signs
return queue.setBlock(x, y, z, id, (byte) block.getData(), block.hasNbtData() && !MainUtil.isValidSign(block.getNbtData()) ? null : block.getNbtData());
CompoundTag nbt = block.getNbtData();
return queue.setBlock(x, y, z, id, block.getData(), nbt != null && !MainUtil.isValidSign(nbt) ? null : nbt);
case 65:
case 68:
case 54:
@ -213,7 +214,7 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
case 233:
case 234:
// Tile
return queue.setBlock(x, y, z, id, (byte) block.getData(), block.getNbtData());
return queue.setBlock(x, y, z, id, block.getData(), block.getNbtData());
case 0:
case 2:
case 4:
@ -276,7 +277,7 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
// No data
return queue.setBlock(x, y, z, id);
default: {
return queue.setBlock(x, y, z, id, (byte) block.getData());
return queue.setBlock(x, y, z, id, block.getData());
}
}
}

View File

@ -0,0 +1,112 @@
package com.boydti.fawe.object.queue;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.DelegateFaweQueue;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.MutableBlockVector2D;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.biome.BaseBiome;
import static com.google.common.base.Preconditions.checkNotNull;
public class FaweQueueDelegateExtent extends DelegateFaweQueue {
private final FaweQueue parentQueue;
private final Extent parentExtent;
private final MutableBlockVector2D mutable2d = new MutableBlockVector2D();
public FaweQueueDelegateExtent(FaweQueue parentQueue, Extent parentExtent) {
super(parentQueue);
checkNotNull(parentExtent);
checkNotNull(parentQueue);
this.parentQueue = parentQueue;
this.parentExtent = parentExtent;
}
@Override
public boolean setBlock(int x, int y, int z, int id, int data) {
try {
return setBlock(x, y, z, FaweCache.getBlock(id, data));
} catch (WorldEditException e) {
return false;
}
}
@Override
public boolean setBlock(int x, int y, int z, int id, int data, CompoundTag nbt) {
BaseBlock block;
if (nbt != null) {
block = new BaseBlock(id, data, nbt);
} else {
block = FaweCache.getBlock(id, data);
}
try {
return setBlock(x, y, z, block);
} catch (WorldEditException e) {
return false;
}
}
@Override
public int getCachedCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getCombinedId4Data(x, y, z);
}
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getLazyBlock(x, y, z).getCombined();
}
@Override
public CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getLazyBlock(x, y, z).getNbtData();
}
@Override
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
return parentExtent.getBiome(mutable2d.setComponents(x, z)).getId();
}
@Override
public boolean setBiome(Vector2D position, BaseBiome biome) {
return parentExtent.setBiome(position, biome);
}
@Override
public BaseBlock getBlock(Vector position) {
return parentExtent.getBlock(position);
}
@Override
public BaseBiome getBiome(Vector2D position) {
return parentExtent.getBiome(position);
}
@Override
public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
return parentExtent.setBlock(position, block);
}
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
return parentExtent.setBlock(x, y, z, block);
}
@Override
public BaseBlock getLazyBlock(Vector position) {
return parentExtent.getLazyBlock(position);
}
@Override
public BaseBlock getLazyBlock(int x, int y, int z) {
return parentExtent.getLazyBlock(x, y, z);
}
}

View File

@ -197,11 +197,12 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
String stateName = stateEntry.getKey();
String stateValue = value.getKey();
properties.put(stateName, stateValue);
break loop;
}
}
}
paletteEntry.put("Properties", properties);
if (!properties.isEmpty()) {
paletteEntry.put("Properties", properties);
}
}
palette.add(paletteEntry);
}

View File

@ -131,11 +131,15 @@ public class WEManager {
}
for (final FaweMaskManager manager : managers) {
if (player.hasPermission("fawe." + manager.getKey())) {
final FaweMask fm = manager.getMask(player);
if (fm != null) {
HashSet<RegionWrapper> cur = fm.getRegions();
regions.addAll(cur);
masks.add(fm);
try {
final FaweMask fm = manager.getMask(player);
if (fm != null) {
HashSet<RegionWrapper> cur = fm.getRegions();
regions.addAll(cur);
masks.add(fm);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}

View File

@ -29,7 +29,6 @@ import com.sk89q.worldedit.CuboidClipboard.FlipDirection;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.foundation.Block;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.registry.WorldData;
@ -63,7 +62,7 @@ import javax.annotation.Nullable;
* more appropriate.</p>
*/
@SuppressWarnings("deprecation")
public class BaseBlock extends Block implements TileEntityBlock, Pattern, Serializable {
public class BaseBlock implements TileEntityBlock, Pattern, Serializable {
/**
* Indicates the highest possible block ID (inclusive) that can be used.
@ -151,7 +150,6 @@ public class BaseBlock extends Block implements TileEntityBlock, Pattern, Serial
*
* @return ID (between 0 and {@link #MAX_ID})
*/
@Override
public int getId() {
return id;
}
@ -177,7 +175,6 @@ public class BaseBlock extends Block implements TileEntityBlock, Pattern, Serial
*
* @param id block id (between 0 and {@link #MAX_ID}).
*/
@Override
public void setId(int id) {
internalSetId(id);
}
@ -192,7 +189,6 @@ public class BaseBlock extends Block implements TileEntityBlock, Pattern, Serial
*
* @return data value (0-15)
*/
@Override
public int getData() {
return data;
}
@ -221,7 +217,6 @@ public class BaseBlock extends Block implements TileEntityBlock, Pattern, Serial
*
* @param data block data value (between 0 and {@link #MAX_DATA}).
*/
@Override
public void setData(int data) {
internalSetData(data);
}
@ -234,7 +229,6 @@ public class BaseBlock extends Block implements TileEntityBlock, Pattern, Serial
* @see #setId(int)
* @see #setData(int)
*/
@Override
public void setIdAndData(int id, int data) {
setId(id);
setData(data);
@ -246,7 +240,6 @@ public class BaseBlock extends Block implements TileEntityBlock, Pattern, Serial
*
* @return true if the data value is -1
*/
@Override
public boolean hasWildcardData() {
return getData() == -1;
}

View File

@ -32,6 +32,7 @@ import com.boydti.fawe.object.schematic.Schematic;
import com.boydti.fawe.util.ImgurUtility;
import com.boydti.fawe.util.MaskTraverser;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.minecraft.util.commands.Logging;
@ -66,7 +67,6 @@ import java.io.IOException;
import java.net.URL;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
@ -74,9 +74,7 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
* Clipboard commands.
*/
@Command(aliases = {}, desc = "Related commands to copy and pasting blocks: [More Info](https://goo.gl/z2ScQR)")
public class ClipboardCommands {
private final WorldEdit worldEdit;
public class ClipboardCommands extends MethodCommands {
/**
* Create a new instance.
@ -84,8 +82,7 @@ public class ClipboardCommands {
* @param worldEdit reference to WorldEdit
*/
public ClipboardCommands(WorldEdit worldEdit) {
checkNotNull(worldEdit);
this.worldEdit = worldEdit;
super(worldEdit);
}
@ -140,9 +137,10 @@ public class ClipboardCommands {
max = 0
)
@CommandPermissions("worldedit.clipboard.copy")
public void copy(Player player, LocalSession session, EditSession editSession,
public void copy(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
@Selection Region region, @Switch('e') boolean copyEntities,
@Switch('m') Mask mask) throws WorldEditException {
@Switch('m') Mask mask, CommandContext context) throws WorldEditException {
fp.checkConfirmationRegion(getArguments(context), region);
Vector min = region.getMinimumPoint();
Vector 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));
@ -223,9 +221,10 @@ public class ClipboardCommands {
)
@CommandPermissions("worldedit.clipboard.cut")
@Logging(REGION)
public void cut(Player player, LocalSession session, EditSession editSession,
public void cut(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
@Selection Region region, @Optional("air") Pattern leavePattern, @Switch('e') boolean copyEntities,
@Switch('m') Mask mask) throws WorldEditException {
@Switch('m') Mask mask, CommandContext context) throws WorldEditException {
fp.checkConfirmationRegion(getArguments(context), region);
Vector min = region.getMinimumPoint();
Vector 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));

View File

@ -25,8 +25,10 @@ import com.boydti.fawe.config.BBC;
import com.boydti.fawe.jnbt.anvil.generator.CavesGen;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TextureUtil;
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;
@ -60,7 +62,6 @@ import java.net.URL;
import javax.imageio.ImageIO;
import static com.google.common.base.Preconditions.checkNotNull;
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;
@ -69,9 +70,7 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
* Commands for the generation of shapes and other objects.
*/
@Command(aliases = {}, desc = "Create structures and features: [More Info](https://goo.gl/KuLFRW)")
public class GenerationCommands {
private final WorldEdit worldEdit;
public class GenerationCommands extends MethodCommands {
/**
* Create a new instance.
@ -79,8 +78,7 @@ public class GenerationCommands {
* @param worldEdit reference to WorldEdit
*/
public GenerationCommands(WorldEdit worldEdit) {
checkNotNull(worldEdit);
this.worldEdit = worldEdit;
super(worldEdit);
}
@Command(
@ -91,10 +89,11 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.caves")
@Logging(PLACEMENT)
public void caves(Player player, LocalSession session, EditSession editSession, @Selection Region region, @Optional("8") int size, @Optional("40") int frequency, @Optional("7") int rarity, @Optional("8") int minY, @Optional("127") int maxY, @Optional("1") int systemFrequency, @Optional("25") int individualRarity, @Optional("0") int pocketChance, @Optional("0") int pocketMin, @Optional("3") int pocketMax) throws WorldEditException, ParameterException {
public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, @Optional("8") int size, @Optional("40") int frequency, @Optional("7") int rarity, @Optional("8") int minY, @Optional("127") int maxY, @Optional("1") int systemFrequency, @Optional("25") int individualRarity, @Optional("0") int pocketChance, @Optional("0") int pocketMin, @Optional("3") int pocketMax, CommandContext context) throws WorldEditException, ParameterException {
fp.checkConfirmationRegion(getArguments(context), region);
CavesGen gen = new CavesGen(size, frequency, rarity, minY, maxY, systemFrequency, individualRarity, pocketChance, pocketMin, pocketMax);
editSession.generate(region, gen);
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
}
// public void addOre(Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
@ -108,7 +107,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT)
public void ores(Player player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask) throws WorldEditException, ParameterException {
public void ores(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, CommandContext context) throws WorldEditException, ParameterException {
player.checkConfirmationRegion(getArguments(context), region);
editSession.addOres(region, mask);
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
}
@ -164,7 +164,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT)
public void ore(Player player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, int size, int freq, int rarity, int minY, int maxY) throws WorldEditException, ParameterException {
public void ore(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, int size, int freq, int rarity, int minY, int maxY, CommandContext context) throws WorldEditException, ParameterException {
player.checkConfirmationRegion(getArguments(context), region);
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
BBC.VISITOR_BLOCK.send(player, editSession.getBlockChangeCount());
}
@ -183,8 +184,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT)
public void hcyl(Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("1") int height) throws WorldEditException, ParameterException {
cyl(player, session, editSession, pattern, radiusString, height, true);
public void hcyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("1") int height, CommandContext context) throws WorldEditException, ParameterException {
cyl(fp, player, session, editSession, pattern, radiusString, height, true, context);
}
@Command(
@ -202,7 +203,7 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT)
public void cyl(Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("1") int height, @Switch('h') boolean hollow) throws WorldEditException, ParameterException {
public void cyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("1") int height, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
String[] radii = radiusString.split(",");
final double radiusX, radiusZ;
switch (radii.length) {
@ -216,17 +217,20 @@ public class GenerationCommands {
break;
default:
player.printError("You must either specify 1 or 2 radius values.");
fp.sendMessage(BBC.getPrefix() + "You must either specify 1 or 2 radius values.");
return;
}
height = Math.min(256, height);
worldEdit.checkMaxRadius(radiusX);
worldEdit.checkMaxRadius(radiusZ);
worldEdit.checkMaxRadius(height);
double max = MathMan.max(radiusX, radiusZ, height);
fp.checkConfirmationRadius(getArguments(context), (int) max);
Vector pos = session.getPlacementPosition(player);
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
BBC.VISITOR_BLOCK.send(player, affected);
BBC.VISITOR_BLOCK.send(fp, affected);
}
@Command(
@ -243,8 +247,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT)
public void hsphere(Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("false") boolean raised) throws WorldEditException, ParameterException {
sphere(player, session, editSession, pattern, radiusString, raised, true);
public void hsphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("false") boolean raised, CommandContext context) throws WorldEditException, ParameterException {
sphere(fp, player, session, editSession, pattern, radiusString, raised, true, context);
}
@Command(
@ -262,7 +266,7 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT)
public void sphere(Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("false") boolean raised, @Switch('h') boolean hollow) throws WorldEditException, ParameterException {
public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, String radiusString, @Optional("false") boolean raised, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
String[] radii = radiusString.split(",");
final double radiusX, radiusY, radiusZ;
switch (radii.length) {
@ -277,14 +281,16 @@ public class GenerationCommands {
break;
default:
player.printError("You must either specify 1 or 3 radius values.");
fp.sendMessage(BBC.getPrefix() + "You must either specify 1 or 3 radius values.");
return;
}
worldEdit.checkMaxRadius(radiusX);
worldEdit.checkMaxRadius(radiusY);
worldEdit.checkMaxRadius(radiusZ);
double max = MathMan.max(radiusX, radiusY, radiusZ);
fp.checkConfirmationRadius(getArguments(context), (int) max);
Vector pos = session.getPlacementPosition(player);
if (raised) {
pos = pos.add(0, radiusY, 0);
@ -292,7 +298,7 @@ public class GenerationCommands {
int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow);
player.findFreePosition();
BBC.VISITOR_BLOCK.send(player, affected);
BBC.VISITOR_BLOCK.send(fp, affected);
}
@Command(
@ -334,8 +340,8 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT)
public void hollowPyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size) throws WorldEditException, ParameterException {
pyramid(player, session, editSession, pattern, size, true);
public void hollowPyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, CommandContext context) throws WorldEditException, ParameterException {
pyramid(fp, player, session, editSession, pattern, size, true, context);
}
@Command(
@ -348,12 +354,13 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT)
public void pyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow) throws WorldEditException, ParameterException {
public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException, ParameterException {
fp.checkConfirmationRadius(getArguments(context), size);
Vector pos = session.getPlacementPosition(player);
worldEdit.checkMaxRadius(size);
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
player.findFreePosition();
BBC.VISITOR_BLOCK.send(player, affected);
BBC.VISITOR_BLOCK.send(fp, affected);
}
@Command(
@ -377,15 +384,16 @@ public class GenerationCommands {
)
@CommandPermissions("worldedit.generation.shape")
@Logging(ALL)
public void generate(Player player, LocalSession session, EditSession editSession,
public void generate(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
@Selection Region region,
Pattern pattern,
@Text String expression,
@Switch('h') boolean hollow,
@Switch('r') boolean useRawCoords,
@Switch('o') boolean offset,
@Switch('c') boolean offsetCenter) throws WorldEditException, ParameterException {
@Switch('c') boolean offsetCenter,
CommandContext context) throws WorldEditException, ParameterException {
fp.checkConfirmationRegion(getArguments(context), region);
final Vector zero;
Vector unit;
@ -416,9 +424,9 @@ public class GenerationCommands {
try {
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
player.findFreePosition();
BBC.VISITOR_BLOCK.send(player, affected);
BBC.VISITOR_BLOCK.send(fp, affected);
} catch (ExpressionException e) {
player.printError(e.getMessage());
fp.sendMessage(BBC.getPrefix() + e.getMessage());
}
}
@ -443,14 +451,16 @@ public class GenerationCommands {
)
@CommandPermissions({"worldedit.generation.shape", "worldedit.biome.set"})
@Logging(ALL)
public void generateBiome(Player player, LocalSession session, EditSession editSession,
public void generateBiome(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
@Selection Region region,
BaseBiome target,
@Text String expression,
@Switch('h') boolean hollow,
@Switch('r') boolean useRawCoords,
@Switch('o') boolean offset,
@Switch('c') boolean offsetCenter) throws WorldEditException, ParameterException {
@Switch('c') boolean offsetCenter,
CommandContext context) throws WorldEditException, ParameterException {
fp.checkConfirmationRegion(getArguments(context), region);
final Vector zero;
Vector unit;
@ -481,9 +491,9 @@ public class GenerationCommands {
try {
final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow);
player.findFreePosition();
BBC.VISITOR_FLAT.send(player, affected);
BBC.VISITOR_FLAT.send(fp, affected);
} catch (ExpressionException e) {
player.printError(e.getMessage());
fp.sendMessage(BBC.getPrefix() + e.getMessage());
}
}

View File

@ -20,13 +20,13 @@ import com.boydti.fawe.object.mask.XAxisMask;
import com.boydti.fawe.object.mask.YAxisMask;
import com.boydti.fawe.object.mask.ZAxisMask;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.ExpressionMask;
@ -74,8 +74,8 @@ public class MaskCommands extends MethodCommands {
min = 2,
max = 2
)
public Mask light(EditSession editSession, double min, double max) {
return new LightMask(editSession, (int) min, (int) max);
public Mask light(Extent extent, double min, double max) {
return new LightMask(extent, (int) min, (int) max);
}
@Command(
@ -85,8 +85,8 @@ public class MaskCommands extends MethodCommands {
min = 2,
max = 2
)
public Mask skylight(EditSession editSession, double min, double max) {
return new SkyLightMask(editSession, (int) min, (int) max);
public Mask skylight(Extent extent, double min, double max) {
return new SkyLightMask(extent, (int) min, (int) max);
}
@Command(
@ -96,8 +96,8 @@ public class MaskCommands extends MethodCommands {
min = 2,
max = 2
)
public Mask blocklight(EditSession editSession, double min, double max) {
return new BlockLightMask(editSession, (int) min, (int) max);
public Mask blocklight(Extent extent, double min, double max) {
return new BlockLightMask(extent, (int) min, (int) max);
}
@Command(
@ -107,8 +107,8 @@ public class MaskCommands extends MethodCommands {
min = 2,
max = 2
)
public Mask opacity(EditSession editSession, double min, double max) {
return new OpacityMask(editSession, (int) min, (int) max);
public Mask opacity(Extent extent, double min, double max) {
return new OpacityMask(extent, (int) min, (int) max);
}
@Command(
@ -118,8 +118,8 @@ public class MaskCommands extends MethodCommands {
min = 2,
max = 2
)
public Mask brightness(EditSession editSession, double min, double max) {
return new BrightnessMask(editSession, (int) min, (int) max);
public Mask brightness(Extent extent, double min, double max) {
return new BrightnessMask(extent, (int) min, (int) max);
}
@Command(
@ -137,7 +137,7 @@ public class MaskCommands extends MethodCommands {
aliases = {"#haslight"},
desc = "Restricts to blocks with light (sky or emitted)"
)
public Mask haslight(EditSession extent) {
public Mask haslight(Extent extent) {
return new LightMask(extent, 1, Integer.MAX_VALUE);
}
@ -145,7 +145,7 @@ public class MaskCommands extends MethodCommands {
aliases = {"#nolight"},
desc = "Restrict to blocks without light (sky or emitted)"
)
public Mask nolight(EditSession extent) {
public Mask nolight(Extent extent) {
return new LightMask(extent, 0, 0);
}
@ -153,7 +153,7 @@ public class MaskCommands extends MethodCommands {
aliases = {"#existing"},
desc = "If there is a non air block"
)
public Mask existing(EditSession extent) {
public Mask existing(Extent extent) {
return new ExistingBlockMask(extent);
}
@ -161,7 +161,7 @@ public class MaskCommands extends MethodCommands {
aliases = {"#solid"},
desc = "If there is a solid block"
)
public Mask solid(EditSession extent) {
public Mask solid(Extent extent) {
return new SolidBlockMask(extent);
}
@ -169,7 +169,7 @@ public class MaskCommands extends MethodCommands {
aliases = {"#dregion", "#dselection", "#dsel"},
desc = "inside the player's selection"
)
public Mask dregion(EditSession extent) {
public Mask dregion() {
return new RegionMask(new RequestSelection());
}
@ -209,31 +209,31 @@ public class MaskCommands extends MethodCommands {
aliases = {"#id"},
desc = "Restrict to initial id"
)
public Mask id(EditSession editSession) {
return new IdMask(editSession);
public Mask id(Extent extent) {
return new IdMask(extent);
}
@Command(
aliases = {"#data"},
desc = "Restrict to initial data"
)
public Mask data(EditSession editSession) {
return new DataMask(editSession);
public Mask data(Extent extent) {
return new DataMask(extent);
}
@Command(
aliases = {"#iddata"},
desc = "Restrict to initial block id and data"
)
public Mask iddata(EditSession editSession) {
return new IdDataMask(editSession);
public Mask iddata(Extent extent) {
return new IdDataMask(extent);
}
@Command(
aliases = {"#wall"},
desc = "Restrict to walls (any block n,e,s,w of air)"
)
public Mask wall(EditSession extent) {
public Mask wall(Extent extent) {
BlockMask blockMask = new BlockMask(extent, new BaseBlock(0));
return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8));
}
@ -242,7 +242,7 @@ public class MaskCommands extends MethodCommands {
aliases = {"#surface"},
desc = "Restrict to surfaces (any solid block touching air)"
)
public Mask surface(EditSession extent) {
public Mask surface(Extent extent) {
return new MaskUnion(new ExistingBlockMask(extent), new AdjacentAnyMask(new BlockMask(extent, new BaseBlock(0))));
}
@ -259,7 +259,7 @@ public class MaskCommands extends MethodCommands {
min = 2,
max = 2
)
public Mask angle(EditSession extent, String min, String max, @Switch('o') boolean overlay) throws ExpressionException {
public Mask angle(Extent extent, String min, String max, @Switch('o') boolean overlay) throws ExpressionException {
double y1, y2;
boolean override;
if (max.endsWith("d")) {
@ -346,8 +346,8 @@ public class MaskCommands extends MethodCommands {
min = 1,
max = 1
)
public Mask biome(EditSession editSession, BaseBiome biome) throws ExpressionException {
return new BiomeMask(editSession, biome);
public Mask biome(Extent extent, BaseBiome biome) throws ExpressionException {
return new BiomeMask(extent, biome);
}
@Command(
@ -369,10 +369,9 @@ public class MaskCommands extends MethodCommands {
min = 1,
max = 1
)
public Mask expression(EditSession editSession, String input) throws ExpressionException {
public Mask expression(Extent extent, String input) throws ExpressionException {
Expression exp = Expression.compile(input, "x", "y", "z");
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(
editSession, Vector.ONE, Vector.ZERO);
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector.ONE, Vector.ZERO);
exp.setEnvironment(env);
return new ExpressionMask(exp);
}

View File

@ -34,13 +34,14 @@ import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern;
import com.boydti.fawe.object.random.SimplexRandom;
import com.boydti.fawe.util.TextureUtil;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.function.mask.Mask;
@ -68,8 +69,8 @@ public class PatternCommands extends MethodCommands {
@Command(
aliases = {"#existing", "#*"},
desc = "Use the block that is already there")
public Pattern existing(EditSession editSession) {
return new ExistingPattern(editSession);
public Pattern existing(Extent extent) {
return new ExistingPattern(extent);
}
@Command(
@ -117,17 +118,17 @@ public class PatternCommands extends MethodCommands {
min = 0,
max = 2
)
public Pattern anglecolor(EditSession editSession, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
public Pattern anglecolor(Extent extent, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
TextureUtil util = Fawe.get().getCachedTextureUtil(randomize, 0, (int) maxComplexity);
return new AngleColorPattern(editSession, (int) maxComplexity, randomize);
return new AngleColorPattern(extent, (int) maxComplexity, randomize);
}
@Command(
aliases = {"#angledata"},
desc = "Block data based on the existing terrain angle"
)
public Pattern angledata(EditSession editSession) {
return new DataAngleMask(editSession);
public Pattern angledata(Extent extent) {
return new DataAngleMask(extent);
}
@Command(
@ -137,11 +138,11 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 3
)
public Pattern saturate(EditSession editSession, String arg, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
public Pattern saturate(Extent extent, String arg, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
TextureUtil util = Fawe.get().getCachedTextureUtil(randomize, 0, (int) maxComplexity);
Color color = Color.web(arg);
java.awt.Color awtColor = new java.awt.Color((float) color.getRed(), (float) color.getGreen(), (float) color.getBlue(), (float) color.getOpacity());
return new SaturatePattern(editSession, awtColor.getRGB(), (int) maxComplexity, randomize);
return new SaturatePattern(extent, awtColor.getRGB(), (int) maxComplexity, randomize);
}
@Command(
@ -151,11 +152,11 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 3
)
public Pattern averagecolor(EditSession editSession, String arg, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
public Pattern averagecolor(Extent extent, String arg, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
TextureUtil util = Fawe.get().getCachedTextureUtil(randomize, 0, (int) maxComplexity);
Color color = Color.web(arg);
java.awt.Color awtColor = new java.awt.Color((float) color.getRed(), (float) color.getGreen(), (float) color.getBlue(), (float) color.getOpacity());
return new AverageColorPattern(editSession, awtColor.getRGB(), (int) maxComplexity, randomize);
return new AverageColorPattern(extent, awtColor.getRGB(), (int) maxComplexity, randomize);
}
@Command(
@ -165,9 +166,9 @@ public class PatternCommands extends MethodCommands {
min = 0,
max = 3
)
public Pattern desaturate(EditSession editSession, @Optional("100") double percent, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
public Pattern desaturate(Extent extent, @Optional("100") double percent, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
TextureUtil util = Fawe.get().getCachedTextureUtil(randomize, 0, (int) maxComplexity);
return new DesaturatePattern(editSession, percent / 100d, (int) maxComplexity, randomize);
return new DesaturatePattern(extent, percent / 100d, (int) maxComplexity, randomize);
}
@Command(
@ -177,9 +178,9 @@ public class PatternCommands extends MethodCommands {
min = 0,
max = 2
)
public Pattern lighten(EditSession editSession, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
public Pattern lighten(Extent extent, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
TextureUtil util = Fawe.get().getCachedTextureUtil(randomize, 0, (int) maxComplexity);
return new ShadePattern(editSession, false, (int) maxComplexity, randomize);
return new ShadePattern(extent, false, (int) maxComplexity, randomize);
}
@Command(
@ -189,9 +190,9 @@ public class PatternCommands extends MethodCommands {
min = 0,
max = 2
)
public Pattern darken(EditSession editSession, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
public Pattern darken(Extent extent, @Optional("true") boolean randomize, @Optional("100") double maxComplexity) {
TextureUtil util = Fawe.get().getCachedTextureUtil(randomize, 0, (int) maxComplexity);
return new ShadePattern(editSession, true, (int) maxComplexity, randomize);
return new ShadePattern(extent, true, (int) maxComplexity, randomize);
}
@Command(
@ -201,7 +202,7 @@ public class PatternCommands extends MethodCommands {
min = 0,
max = 2
)
public Pattern fullcopy(Actor actor, EditSession editSession, LocalSession session, @Optional("#copy") String location, @Optional("false") boolean rotate, @Optional("false") boolean flip) throws EmptyClipboardException, InputParseException, IOException {
public Pattern fullcopy(Player player, Extent extent, LocalSession session, @Optional("#copy") String location, @Optional("false") boolean rotate, @Optional("false") boolean flip) throws EmptyClipboardException, InputParseException, IOException {
ClipboardHolder[] clipboards;
switch (location.toLowerCase()) {
case "#copy":
@ -211,18 +212,18 @@ public class PatternCommands extends MethodCommands {
throw new InputParseException("To use #fullcopy, please first copy something to your clipboard");
}
if (!rotate && !flip) {
return new FullClipboardPattern(editSession, clipboard.getClipboard());
return new FullClipboardPattern(extent, clipboard.getClipboard());
}
clipboards = new ClipboardHolder[]{clipboard};
break;
default:
clipboards = ClipboardFormat.SCHEMATIC.loadAllFromInput(actor, editSession.getWorldData(), location, true);
clipboards = ClipboardFormat.SCHEMATIC.loadAllFromInput(player, player.getWorld().getWorldData(), location, true);
break;
}
if (clipboards == null) {
throw new InputParseException("#fullcopy:<source>");
}
return new RandomFullClipboardPattern(editSession, editSession.getWorldData(), clipboards, rotate, flip);
return new RandomFullClipboardPattern(extent, player.getWorld().getWorldData(), clipboards, rotate, flip);
}
@Command(
@ -258,8 +259,8 @@ public class PatternCommands extends MethodCommands {
min = 2,
max = 2
)
public Pattern iddatamask(Actor actor, LocalSession session, EditSession editSession, int bitmask, Pattern pattern) {
return new IdDataMaskPattern(editSession, pattern, bitmask);
public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, int bitmask, Pattern pattern) {
return new IdDataMaskPattern(extent, pattern, bitmask);
}
@Command(
@ -269,8 +270,8 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern id(Actor actor, LocalSession session, EditSession editSession, Pattern pattern) {
return new IdPattern(editSession, pattern);
public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new IdPattern(extent, pattern);
}
@Command(
@ -280,8 +281,8 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern data(Actor actor, LocalSession session, EditSession editSession, Pattern pattern) {
return new DataPattern(editSession, pattern);
public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new DataPattern(extent, pattern);
}
@Command(
@ -291,8 +292,8 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern data(Actor actor, LocalSession session, EditSession editSession, BaseBiome biome) {
return new BiomePattern(editSession, biome);
public Pattern data(Actor actor, LocalSession session, Extent extent, BaseBiome biome) {
return new BiomePattern(extent, biome);
}
@Command(
@ -302,7 +303,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern relative(Actor actor, LocalSession session, EditSession editSession, Pattern pattern) {
public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new RelativePattern(pattern);
}
@ -315,7 +316,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern nox(Actor actor, LocalSession session, EditSession editSession, Pattern pattern) {
public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new NoXPattern(pattern);
}
@ -326,7 +327,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern noy(Actor actor, LocalSession session, EditSession editSession, Pattern pattern) {
public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new NoYPattern(pattern);
}
@ -337,7 +338,7 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern noz(Actor actor, LocalSession session, EditSession editSession, Pattern pattern) {
public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
return new NoZPattern(pattern);
}
@ -434,9 +435,9 @@ public class PatternCommands extends MethodCommands {
min = 1,
max = 1
)
public Pattern expression(Actor actor, LocalSession session, EditSession editSession, String input) throws ExpressionException {
public Pattern expression(Actor actor, LocalSession session, Extent extent, String input) throws ExpressionException {
Expression exp = Expression.compile(input, "x", "y", "z");
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(editSession, Vector.ONE, Vector.ZERO);
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector.ONE, Vector.ZERO);
exp.setEnvironment(env);
return new ExpressionPattern(exp);
}

View File

@ -278,15 +278,20 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.curve")
@Logging(REGION)
public void curve(Player player, EditSession editSession,
public void curve(FawePlayer player, EditSession editSession,
@Selection Region region,
Pattern pattern,
@Optional("0") @Range(min = 0) int thickness,
@Switch('h') boolean shell) throws WorldEditException {
@Switch('h') boolean shell,
CommandContext context) throws WorldEditException {
if (!(region instanceof ConvexPolyhedralRegion)) {
player.printError("//curve only works with convex polyhedral selections");
player.sendMessage(BBC.getPrefix() + "//curve only works with convex polyhedral selections");
return;
}
worldEdit.checkMaxRadius(thickness);
player.checkConfirmationRegion(getArguments(context), region);
player.checkConfirmationRadius(getArguments(context), thickness);
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices());
@ -307,7 +312,7 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.region.replace")
@Logging(REGION)
public void replace(FawePlayer player, EditSession editSession, @Selection Region region, @Optional Mask from, Pattern to, CommandContext context) throws WorldEditException {
player.checkConfirmation(getArguments(context));
player.checkConfirmationRegion(getArguments(context), region);
if (from == null) {
from = new ExistingBlockMask(editSession);
}
@ -327,7 +332,7 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.region.set")
@Logging(REGION)
public void set(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region selection, Pattern to, CommandContext context) throws WorldEditException {
player.checkConfirmation(getArguments(context));
player.checkConfirmationRegion(getArguments(context), selection);
int affected;
affected = editSession.setBlocks(selection, to);
if (affected != 0) {
@ -346,7 +351,8 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.overlay")
@Logging(REGION)
public void overlay(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
public void overlay(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), region);
int affected = editSession.overlayCuboidBlocks(region, pattern);
BBC.VISITOR_BLOCK.send(player, affected);
}
@ -360,7 +366,8 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.overlay")
@Logging(REGION)
public void lay(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
public void lay(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), region);
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
int maxY = max.getBlockY();
@ -407,7 +414,8 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.naturalize")
@Logging(REGION)
public void naturalize(Player player, EditSession editSession, @Selection Region region) throws WorldEditException {
public void naturalize(FawePlayer player, EditSession editSession, @Selection Region region, CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), region);
int affected = editSession.naturalizeCuboidBlocks(region);
BBC.VISITOR_BLOCK.send(player, affected);
}
@ -421,7 +429,8 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.walls")
@Logging(REGION)
public void walls(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
public void walls(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), region);
int affected = editSession.makeCuboidWalls(region, pattern);
BBC.VISITOR_BLOCK.send(player, affected);
}
@ -435,7 +444,8 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.faces")
@Logging(REGION)
public void faces(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
public void faces(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), region);
int affected = editSession.makeCuboidFaces(region, pattern);
BBC.VISITOR_BLOCK.send(player, affected);
}
@ -454,7 +464,7 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.smoothsnow")
@Logging(REGION)
public void smooth(Player player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Switch('n') boolean affectNatural, @Switch('s') boolean snow) throws WorldEditException {
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 {
try {
Vector min = region.getMinimumPoint();
Vector max = region.getMaximumPoint();
@ -463,6 +473,7 @@ public class RegionCommands extends MethodCommands {
if (volume >= limit.MAX_CHECKS) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
}
player.checkConfirmationRegion(getArguments(context), region);
HeightMap heightMap = new HeightMap(editSession, region, affectNatural, snow);
HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1));
int affected = heightMap.applyFilter(filter, iterations);
@ -519,12 +530,14 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.move")
@Logging(ORIENTATION_REGION)
public void move(Player player, LocalSession session, EditSession editSession,
public void move(FawePlayer player, LocalSession session, EditSession editSession,
@Selection Region region,
@Optional("1") @Range(min = 1) int count,
@Optional(Direction.AIM) @Direction Vector direction,
@Optional("air") BaseBlock replace,
@Switch('s') boolean moveSelection) throws WorldEditException {
@Switch('s') boolean moveSelection,
CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), region);
int affected = editSession.moveRegion(region, direction, count, true, replace);
@ -533,9 +546,9 @@ public class RegionCommands extends MethodCommands {
region.shift(direction.multiply(count));
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
} catch (RegionOperationException e) {
player.printError(e.getMessage());
player.sendMessage(BBC.getPrefix() + e.getMessage());
}
}
@ -555,11 +568,12 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.fall")
@Logging(ORIENTATION_REGION)
public void fall(Player player, EditSession editSession, LocalSession session,
public void fall(FawePlayer player, EditSession editSession, LocalSession session,
@Selection Region region,
@Optional("air") BaseBlock replace,
@Switch('m') boolean notFullHeight) throws WorldEditException {
@Switch('m') boolean notFullHeight,
CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), region);
int affected = editSession.fall(region, !notFullHeight, replace);
BBC.VISITOR_BLOCK.send(player, affected);
}
@ -579,12 +593,13 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.stack")
@Logging(ORIENTATION_REGION)
public void stack(Player player, LocalSession session, EditSession editSession,
public void stack(FawePlayer player, LocalSession session, EditSession editSession,
@Selection Region region,
@Optional("1") @Range(min = 1) int count,
@Optional(Direction.AIM) @Direction Vector direction,
@Switch('s') boolean moveSelection,
@Switch('a') boolean ignoreAirBlocks, @Switch('m') Mask sourceMask) throws WorldEditException {
@Switch('a') boolean ignoreAirBlocks, @Switch('m') Mask sourceMask, CommandContext context) throws WorldEditException {
player.checkConfirmationStack(getArguments(context), region, count);
if (sourceMask != null) {
editSession.addSourceMask(sourceMask);
}
@ -598,56 +613,15 @@ public class RegionCommands extends MethodCommands {
region.shift(shiftVector);
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player.getPlayer(), session);
} catch (RegionOperationException e) {
player.printError(e.getMessage());
player.sendMessage(BBC.getPrefix() + e.getMessage());
}
}
BBC.VISITOR_BLOCK.send(player, affected);
}
@Command(
aliases = {"/regen"},
usage = "[biome] [seed]",
desc = "Regenerates the contents of the selection",
help =
"Regenerates the contents of the current selection.\n" +
"This command might affect things outside the selection,\n" +
"if they are within the same chunk.",
min = 0,
max = 2
)
@CommandPermissions("worldedit.regen")
@Logging(REGION)
public void regenerateChunk(Player player, LocalSession session, EditSession editSession, @Selection Region region, CommandContext args) throws WorldEditException {
Mask mask = session.getMask();
Mask sourceMask = session.getSourceMask();
session.setMask((Mask) null);
session.setSourceMask((Mask) null);
BaseBiome biome = null;
if (args.argsLength() >= 1) {
BiomeRegistry biomeRegistry = player.getWorld().getWorldData().getBiomeRegistry();
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
biome = Biomes.findBiomeByName(knownBiomes, args.getString(0), biomeRegistry);
}
Long seed = args.argsLength() != 2 || !MathMan.isInteger(args.getString(1)) ? null : Long.parseLong(args.getString(1));
editSession.regenerate(region, biome, seed);
session.setMask(mask);
session.setSourceMask(mask);
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) {
BBC.COMMAND_REGEN_2.send(player);
} else if (biome == null) {
BBC.COMMAND_REGEN_0.send(player);
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_REGEN_0.send(player);
} else if (seed == null) {
BBC.COMMAND_REGEN_1.send(player);
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_REGEN_1.send(player);
} else {
BBC.COMMAND_REGEN_2.send(player);
}
}
@Command(
aliases = {"/deform"},
usage = "<expression>",
@ -663,11 +637,13 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.deform")
@Logging(ALL)
public void deform(Player player, LocalSession session, EditSession editSession,
public void deform(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
@Selection Region region,
@Text String expression,
@Switch('r') boolean useRawCoords,
@Switch('o') boolean offset) throws WorldEditException {
@Switch('o') boolean offset,
CommandContext context) throws WorldEditException {
fp.checkConfirmationRegion(getArguments(context), region);
final Vector zero;
Vector unit;
@ -692,9 +668,52 @@ public class RegionCommands extends MethodCommands {
try {
final int affected = editSession.deformRegion(region, zero, unit, expression);
player.findFreePosition();
BBC.VISITOR_BLOCK.send(player, affected);
BBC.VISITOR_BLOCK.send(fp, affected);
} catch (ExpressionException e) {
player.printError(e.getMessage());
fp.sendMessage(BBC.getPrefix() + e.getMessage());
}
}
@Command(
aliases = {"/regen"},
usage = "[biome] [seed]",
desc = "Regenerates the contents of the selection",
help =
"Regenerates the contents of the current selection.\n" +
"This command might affect things outside the selection,\n" +
"if they are within the same chunk.",
min = 0,
max = 2
)
@CommandPermissions("worldedit.regen")
@Logging(REGION)
public void regenerateChunk(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, CommandContext args) throws WorldEditException {
player.checkConfirmationRegion(getArguments(args), region);
Mask mask = session.getMask();
Mask sourceMask = session.getSourceMask();
session.setMask((Mask) null);
session.setSourceMask((Mask) null);
BaseBiome biome = null;
if (args.argsLength() >= 1) {
BiomeRegistry biomeRegistry = player.getWorld().getWorldData().getBiomeRegistry();
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
biome = Biomes.findBiomeByName(knownBiomes, args.getString(0), biomeRegistry);
}
Long seed = args.argsLength() != 2 || !MathMan.isInteger(args.getString(1)) ? null : Long.parseLong(args.getString(1));
editSession.regenerate(region, biome, seed);
session.setMask(mask);
session.setSourceMask(mask);
if (!player.hasPermission("fawe.tips")) {
BBC.COMMAND_REGEN_2.send(player);
} else if (biome == null) {
BBC.COMMAND_REGEN_0.send(player);
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_REGEN_0.send(player);
} else if (seed == null) {
BBC.COMMAND_REGEN_1.send(player);
if (!FawePlayer.wrap(player).hasPermission("fawe.tips")) BBC.TIP_REGEN_1.send(player);
} else {
BBC.COMMAND_REGEN_2.send(player);
}
}
@ -711,11 +730,12 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.hollow")
@Logging(REGION)
public void hollow(Player player, EditSession editSession,
public void hollow(FawePlayer player, EditSession editSession,
@Selection Region region,
@Optional("0") @Range(min = 0) int thickness,
@Optional("air") Pattern pattern) throws WorldEditException {
@Optional("air") Pattern pattern,
CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), region);
int affected = editSession.hollowOutRegion(region, thickness, pattern);
BBC.VISITOR_BLOCK.send(player, affected);
}
@ -729,8 +749,11 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.forest")
@Logging(REGION)
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 {
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(getArguments(context), region);
density = density / 100;
ForestGenerator generator = new ForestGenerator(editSession, new TreeGenerator(type));
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
@ -750,7 +773,8 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.flora")
@Logging(REGION)
public void flora(Player player, EditSession editSession, @Selection Region region, @Optional("10") @Range(min = 0, max = 100) double density) throws WorldEditException {
public void flora(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("10") @Range(min = 0, max = 100) double density, CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), region);
density = density / 100;
FloraGenerator generator = new FloraGenerator(editSession);
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);

View File

@ -89,17 +89,7 @@ public class ToolCommands {
)
@CommandPermissions("worldedit.tool.tree")
@SuppressWarnings("deprecation")
public void tree(Player player, LocalSession session, CommandContext args) throws WorldEditException {
TreeGenerator.TreeType type = args.argsLength() > 0 ?
type = TreeGenerator.lookup(args.getString(0))
: TreeGenerator.TreeType.TREE;
if (type == null) {
BBC.TOOL_TREE_ERROR.send(player, args.getString(0));
return;
}
public void tree(Player player, LocalSession session, @Optional("tree") TreeGenerator.TreeType type, CommandContext args) throws WorldEditException {
session.setTool(new TreePlanter(new TreeGenerator(type)), player);
BBC.TOOL_TREE.send(player, ItemType.toHeldName(player.getItemInHand()));
}

View File

@ -135,6 +135,7 @@ public class WorldEditCommands {
changes = scanner.useDelimiter("\\A").next();
}
}
changes = changes.replaceAll("#([0-9]+)", "github.com/boy0001/FastAsyncWorldedit//$1");
actor.print(BBC.getPrefix() + changes);
} catch (IOException e) {
throw new RuntimeException(e);

View File

@ -34,7 +34,6 @@ import com.google.common.base.Joiner;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
import com.sk89q.minecraft.util.commands.WrappedCommandException;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
@ -368,6 +367,7 @@ public final class CommandManager {
}
};
}
Request.reset();
locals.put(Actor.class, actor);
final Actor finalActor = actor;
@ -384,12 +384,12 @@ public final class CommandManager {
// Use the exception converter to convert the exception if any of its causes
// can be converted, otherwise throw the original exception
Throwable next = t;
do {
exceptionConverter.convert(next);
exceptionConverter.convert(next);
while (next.getCause() != null) {
next = next.getCause();
} while (next != null);
throw t;
exceptionConverter.convert(next);
}
throw next;
}
} catch (CommandPermissionsException e) {
BBC.NO_PERM.send(finalActor, StringMan.join(failedPermissions, " "));
@ -405,7 +405,15 @@ public final class CommandManager {
finalActor.printRaw(BBC.getPrefix() + (message != null ? message : "The command was not used properly (no more help available)."));
BBC.COMMAND_SYNTAX.send(finalActor, e.getSimpleUsageString("/"));
}
} catch (WrappedCommandException e) {
} catch (CommandException e) {
String message = e.getMessage();
if (message != null) {
actor.printError(e.getMessage());
} else {
actor.printError("An unknown FAWE error has occurred! Please see console.");
log.log(Level.SEVERE, "An unknown FAWE error occurred", e);
}
} catch (Throwable e) {
Exception faweException = FaweException.get(e);
String message = e.getMessage();
if (faweException != null) {
@ -415,14 +423,6 @@ public final class CommandManager {
finalActor.printRaw(e.getClass().getName() + ": " + e.getMessage());
log.log(Level.SEVERE, "An unexpected error occurred while handling a FAWE command", e);
}
} catch (CommandException e) {
String message = e.getMessage();
if (message != null) {
actor.printError(e.getMessage());
} else {
actor.printError("An unknown FAWE error has occurred! Please see console.");
log.log(Level.SEVERE, "An unknown FAWE error occurred", e);
}
} finally {
final EditSession editSession = locals.get(EditSession.class);
if (editSession != null) {

View File

@ -48,6 +48,7 @@ import com.sk89q.worldedit.event.platform.PlayerInputEvent;
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
import com.sk89q.worldedit.internal.ServerInterfaceAdapter;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.world.World;
@ -351,6 +352,7 @@ public class PlatformManager {
public void handleBlockInteract(BlockInteractEvent event) {
// Create a proxy actor with a potentially different world for
// making changes to the world
Request.reset();
final Actor actor = createProxyActor(event.getCause());
try {
final Location location = event.getLocation();

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.regions.shape;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
@ -29,10 +30,14 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
private final Vector unit;
private final Vector zero2;
private Vector current = new Vector();
private EditSession editSession;
private Extent extent;
public WorldEditExpressionEnvironment(EditSession editSession, Vector unit, Vector zero) {
this.editSession = editSession;
this((Extent) editSession, unit, zero);
}
public WorldEditExpressionEnvironment(Extent extent, Vector unit, Vector zero) {
this.extent = extent;
this.unit = unit;
this.zero2 = zero.add(0.5, 0.5, 0.5);
}
@ -42,12 +47,12 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
x = x * unit.getX() + zero2.getX();
y = y * unit.getY() + zero2.getY();
z = z * unit.getZ() + zero2.getZ();
return editSession.getBlock((int) x, (int) y, (int) z);
return extent.getLazyBlock((int) x, (int) y, (int) z);
}
@Override
public BaseBlock getBlockAbs(double x, double y, double z) {
return editSession.getBlock((int) x, (int) y, (int) z);
return extent.getLazyBlock((int) x, (int) y, (int) z);
}
@Override
@ -55,7 +60,7 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
x = x + current.getBlockX();
y = y + current.getBlockY();
z = z + current.getBlockZ();
return editSession.getBlock((int) x, (int) y, (int) z);
return extent.getLazyBlock((int) x, (int) y, (int) z);
}
public void setCurrentBlock(Vector current) {

View File

@ -4,8 +4,11 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.BukkitCommand;
import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FawePlayer;
import com.thevoxelbox.voxelsniper.RangeBlockHelper;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Sniper;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import com.thevoxelbox.voxelsniper.command.VoxelVoxelCommand;
import java.io.File;
import java.io.FileOutputStream;
import java.net.URL;
@ -42,6 +45,9 @@ public class Favs extends JavaPlugin {
}
SnipeData.inject();
Sniper.inject();
VoxelVoxelCommand.inject();
PerformBrush.inject();
RangeBlockHelper.inject();
// Forward the commands so //p and //d will work
setupCommand("/p", new FaweCommand("voxelsniper.sniper") {
@Override

View File

@ -250,4 +250,8 @@ public class RangeBlockHelper {
this.lastY = this.targetY;
this.lastZ = this.targetZ;
}
public static Class<?> inject() {
return RangeBlockHelper.class;
}
}

View File

@ -1,5 +1,7 @@
package com.thevoxelbox.voxelsniper;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.thevoxelbox.voxelsniper.util.VoxelList;
import org.bukkit.World;
@ -53,6 +55,9 @@ public class SnipeData {
private int range = 0;
private boolean ranged = false;
private boolean lightning = false;
private Extent extent;
private Pattern pattern;
private String patternInfo;
/**
* @param vs
@ -61,6 +66,40 @@ public class SnipeData {
this.owner = vs;
}
/**
* Get the extent currently being used to set blocks
* @return
*/
public Extent getExtent() {
return extent;
}
/**
* Set the extent currently being used to set blocks
* @param extent
*/
public void setExtent(Extent extent) {
this.extent = extent;
}
public void setPattern(Pattern pattern, String info) {
if (pattern != null) {
if (info == null) info = "";
} else {
info = null;
}
this.pattern = pattern;
this.patternInfo = info;
}
public Pattern getPattern() {
return pattern;
}
public String getPatternInfo() {
return patternInfo;
}
/**
* @return the brushSize
*/

View File

@ -13,6 +13,10 @@ import com.boydti.fawe.object.MaskedFaweQueue;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.boydti.fawe.object.extent.ResettableExtent;
import com.boydti.fawe.object.extent.SourceMaskExtent;
import com.boydti.fawe.object.queue.FaweQueueDelegateExtent;
import com.boydti.fawe.util.MaskTraverser;
import com.boydti.fawe.util.SetQueue;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.WEManager;
@ -23,6 +27,10 @@ import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.MutableClassToInstanceMap;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.extent.MaskingExtent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.session.request.Request;
import com.thevoxelbox.voxelsniper.brush.IBrush;
import com.thevoxelbox.voxelsniper.brush.SnipeBrush;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
@ -42,9 +50,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.material.MaterialData;
/**
*
*/
public class Sniper {
private VoxelSniper plugin;
private final UUID player;
@ -177,6 +182,25 @@ public class Sniper {
} else {
changeQueue = new ChangeSetFaweQueue(changeSet, maskQueue);
}
LocalSession session = fp.getSession();
{ // Set mask etc
Mask destMask = session.getMask();
if (!Masks.isNull(destMask)) {
new MaskTraverser(destMask).reset(changeQueue);
changeQueue = new FaweQueueDelegateExtent(changeQueue, new MaskingExtent(changeQueue, destMask));
}
Mask sourceMask = session.getSourceMask();
if (!Masks.isNull(sourceMask)) {
new MaskTraverser(sourceMask).reset(changeQueue);
changeQueue = new FaweQueueDelegateExtent(changeQueue, new SourceMaskExtent(changeQueue, sourceMask));
}
ResettableExtent transform = session.getTransform();
if (transform != null) {
transform.setExtent(changeQueue);
changeQueue = new FaweQueueDelegateExtent(changeQueue, transform);
}
}
AsyncWorld world = getWorld();
world.changeWorld(bukkitWorld, changeQueue);
@ -321,23 +345,31 @@ public class Sniper {
}
final IBrush brush = sniperTool.getCurrentBrush();
if (sniperTool.getCurrentBrush() instanceof PerformBrush) {
PerformBrush performerBrush = (PerformBrush) sniperTool.getCurrentBrush();
performerBrush.initP(snipeData);
}
switch (brush.getClass().getSimpleName()) {
case "JockeyBrush":
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
brush.perform(snipeAction, snipeData, targetBlock, lastBlock);
try {
snipeData.setExtent(world);
Request.reset();
Request.request().setExtent(world);
switch (brush.getClass().getSimpleName()) {
case "JockeyBrush":
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
brush.perform(snipeAction, snipeData, targetBlock, lastBlock);
}
});
break;
default:
if (sniperTool.getCurrentBrush() instanceof PerformBrush) {
PerformBrush performerBrush = (PerformBrush) sniperTool.getCurrentBrush();
performerBrush.initP(snipeData);
}
});
break;
default:
brush.perform(snipeAction, snipeData, targetBlock, lastBlock);
break;
brush.perform(snipeAction, snipeData, targetBlock, lastBlock);
break;
}
} finally {
snipeData.setExtent(null);
Request.reset();
}
if (Fawe.isMainThread()) {
SetQueue.IMP.flush(changeQueue);
@ -350,7 +382,6 @@ public class Sniper {
} else {
changeSet.close();
}
LocalSession session = fp.getSession();
session.remember(changeSet.toEditSession(fp));
}
return true;

View File

@ -0,0 +1,42 @@
package com.thevoxelbox.voxelsniper.brush.perform;
import com.boydti.fawe.object.pattern.PatternTraverser;
import com.sk89q.worldedit.MutableBlockVector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import org.bukkit.block.Block;
public class PatternPerformer extends vPerformer {
private String info;
private Pattern pattern;
private Extent extent;
private MutableBlockVector mutable = new MutableBlockVector();
@Override
public void info(Message vm) {
vm.performerName(this.name + ": " + info);
vm.voxel();
}
@Override
public void init(SnipeData snipeData) {
this.w = snipeData.getWorld();
this.extent = snipeData.getExtent();
this.info = snipeData.getPatternInfo();
this.pattern = snipeData.getPattern();
new PatternTraverser(pattern).reset(extent);
}
@Override
public void perform(Block block) {
mutable.setComponents(block.getX(), block.getY(), block.getZ());
try {
pattern.apply(extent, mutable, mutable);
} catch (WorldEditException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,76 @@
package com.thevoxelbox.voxelsniper.brush.perform;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.brush.Brush;
import com.thevoxelbox.voxelsniper.event.SniperBrushChangedEvent;
import java.util.Arrays;
import org.bukkit.Bukkit;
public abstract class PerformBrush extends Brush implements Performer {
protected vPerformer current = new pMaterial();
public PerformBrush() {
}
public vPerformer getCurrentPerformer() {
return this.current;
}
public void parse(String[] args, SnipeData v) {
String handle = args[0];
if(PerformerE.has(handle)) {
vPerformer p = PerformerE.getPerformer(handle);
if(p != null) {
this.current = p;
SniperBrushChangedEvent event = new SniperBrushChangedEvent(v.owner(), v.owner().getCurrentToolId(), this, this);
Bukkit.getPluginManager().callEvent(event);
this.info(v.getVoxelMessage());
this.current.info(v.getVoxelMessage());
if(args.length > 1) {
String[] additionalArguments = (String[])Arrays.copyOfRange(args, 1, args.length);
this.parameters(this.hackTheArray(additionalArguments), v);
}
} else {
this.parameters(this.hackTheArray(args), v);
}
} else {
this.parameters(this.hackTheArray(args), v);
}
}
private String[] hackTheArray(String[] args) {
String[] returnValue = new String[args.length + 1];
int i = 0;
for(int argsLength = args.length; i < argsLength; ++i) {
String arg = args[i];
returnValue[i + 1] = arg;
}
return returnValue;
}
public void initP(SnipeData v) {
Pattern pattern = v.getPattern();
if (pattern != null) {
if (!(current instanceof PatternPerformer)) {
current = new PatternPerformer();
}
} else if (current instanceof PatternPerformer) {
current = new pMaterial();
}
this.current.init(v);
this.current.setUndo();
}
public void showInfo(Message vm) {
this.current.info(vm);
}
public static Class<?> inject() {
return PerformBrush.class;
}
}

View File

@ -0,0 +1,82 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.thevoxelbox.voxelsniper.command;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.thevoxelbox.voxelsniper.RangeBlockHelper;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Sniper;
import com.thevoxelbox.voxelsniper.VoxelSniper;
import com.thevoxelbox.voxelsniper.api.command.VoxelCommand;
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public class VoxelVoxelCommand extends VoxelCommand {
public VoxelVoxelCommand(VoxelSniper plugin) {
super("VoxelVoxel", plugin);
this.setIdentifier("v");
this.setPermission("voxelsniper.sniper");
}
public boolean onCommand(Player player, String[] args) {
Sniper sniper = this.plugin.getSniperManager().getSniperForPlayer(player);
SnipeData snipeData = sniper.getSnipeData(sniper.getCurrentToolId());
if(args.length == 0) {
Block material1 = (new RangeBlockHelper(player, player.getWorld())).getTargetBlock();
if(material1 != null) {
if(!player.hasPermission("voxelsniper.ignorelimitations") && this.plugin.getVoxelSniperConfiguration().getLiteSniperRestrictedItems().contains(Integer.valueOf(material1.getTypeId()))) {
player.sendMessage("You are not allowed to use " + material1.getType().name() + ".");
return true;
}
snipeData.setVoxelId(material1.getTypeId());
snipeData.getVoxelMessage().voxel();
snipeData.setPattern(null, null);
}
return true;
} else {
Material material = Material.matchMaterial(args[0]);
if(material != null && material.isBlock()) {
if(!player.hasPermission("voxelsniper.ignorelimitations") && this.plugin.getVoxelSniperConfiguration().getLiteSniperRestrictedItems().contains(Integer.valueOf(material.getId()))) {
player.sendMessage("You are not allowed to use " + material.name() + ".");
return true;
} else {
snipeData.setVoxelId(material.getId());
snipeData.getVoxelMessage().voxel();
snipeData.setPattern(null, null);
return true;
}
} else {
ParserContext context = new ParserContext();
FawePlayer<Object> fp = FawePlayer.wrap(player);
context.setActor(fp.getPlayer());
context.setWorld(fp.getWorld());
context.setSession(fp.getSession());
try {
Pattern pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(args[0], context);
snipeData.setPattern(pattern, args[0]);
snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + args[0]);
} catch (InputParseException e) {
fp.sendMessage(BBC.getPrefix() + e.getMessage());
}
return true;
}
}
}
public static Class<?> inject() {
return VoxelVoxelCommand.class;
}
}