geforkt von Mirrors/FastAsyncWorldEdit
Dieser Commit ist enthalten in:
Ursprung
8c44c532c4
Commit
a2efdbc488
@ -19,17 +19,19 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBagException;
|
import com.sk89q.worldedit.extent.inventory.BlockBagException;
|
||||||
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
|
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
|
||||||
import com.sk89q.worldedit.extent.inventory.OutOfSpaceException;
|
import com.sk89q.worldedit.extent.inventory.OutOfSpaceException;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class BukkitPlayerBlockBag extends BlockBag {
|
public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag {
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private ItemStack[] items;
|
private ItemStack[] items;
|
||||||
@ -61,6 +63,19 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseItem getItem(int slot) {
|
||||||
|
loadInventory();
|
||||||
|
return BukkitAdapter.adapt(items[slot]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setItem(int slot, BaseItem block) {
|
||||||
|
loadInventory();
|
||||||
|
BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(block.getType(), block.getNbtData(), 1);
|
||||||
|
items[slot] = BukkitAdapter.adapt(stack);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fetchBlock(BlockState blockState) throws BlockBagException {
|
public void fetchBlock(BlockState blockState) throws BlockBagException {
|
||||||
if (blockState.getBlockType().getMaterial().isAir()) {
|
if (blockState.getBlockType().getMaterial().isAir()) {
|
||||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.entity.Player;
|
|||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||||
|
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.Event.Result;
|
import org.bukkit.event.Event.Result;
|
||||||
@ -108,6 +109,8 @@ public class WorldEditListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onPlayerCommand(PlayerCommandSendEvent event) {
|
public void onPlayerCommand(PlayerCommandSendEvent event) {
|
||||||
|
Dispatcher dispatcher = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher();
|
||||||
|
if (dispatcher != null) {
|
||||||
CommandLocals locals = new CommandLocals();
|
CommandLocals locals = new CommandLocals();
|
||||||
locals.put(Actor.class, plugin.wrapCommandSender(event.getPlayer()));
|
locals.put(Actor.class, plugin.wrapCommandSender(event.getPlayer()));
|
||||||
Set<String> toRemove = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher().getCommands().stream()
|
Set<String> toRemove = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher().getCommands().stream()
|
||||||
@ -116,6 +119,7 @@ public class WorldEditListener implements Listener {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
event.getCommands().removeIf(toRemove::contains);
|
event.getCommands().removeIf(toRemove::contains);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player interacts
|
* Called when a player interacts
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import com.bekvon.bukkit.residence.commands.message;
|
||||||
|
import com.bekvon.bukkit.residence.containers.cmd;
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||||
import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2;
|
import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2;
|
||||||
@ -183,8 +185,10 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
|||||||
PermissionsResolverManager.initialize(this); // Setup permission resolver
|
PermissionsResolverManager.initialize(this); // Setup permission resolver
|
||||||
|
|
||||||
// Register CUI
|
// Register CUI
|
||||||
|
fail(() -> {
|
||||||
getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
|
getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
|
||||||
getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL);
|
getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL);
|
||||||
|
}, "Failed to register CUI");
|
||||||
|
|
||||||
// Now we can register events
|
// Now we can register events
|
||||||
getServer().getPluginManager().registerEvents(new WorldEditListener(this), this);
|
getServer().getPluginManager().registerEvents(new WorldEditListener(this), this);
|
||||||
|
@ -30,67 +30,7 @@ limits:
|
|||||||
butcher-radius:
|
butcher-radius:
|
||||||
default: -1
|
default: -1
|
||||||
maximum: -1
|
maximum: -1
|
||||||
disallowed-blocks:
|
disallowed-blocks: []
|
||||||
- "minecraft:oak_sapling"
|
|
||||||
- "minecraft:jungle_sapling"
|
|
||||||
- "minecraft:dark_oak_sapling:"
|
|
||||||
- "minecraft:spruce_sapling"
|
|
||||||
- "minecraft:birch_sapling"
|
|
||||||
- "minecraft:acacia_sapling"
|
|
||||||
- "minecraft:black_bed"
|
|
||||||
- "minecraft:blue_bed"
|
|
||||||
- "minecraft:brown_bed"
|
|
||||||
- "minecraft:cyan_bed"
|
|
||||||
- "minecraft:gray_bed"
|
|
||||||
- "minecraft:green_bed"
|
|
||||||
- "minecraft:light_blue_bed"
|
|
||||||
- "minecraft:light_gray_bed"
|
|
||||||
- "minecraft:lime_bed"
|
|
||||||
- "minecraft:magenta_bed"
|
|
||||||
- "minecraft:orange_bed"
|
|
||||||
- "minecraft:pink_bed"
|
|
||||||
- "minecraft:purple_bed"
|
|
||||||
- "minecraft:red_bed"
|
|
||||||
- "minecraft:white_bed"
|
|
||||||
- "minecraft:yellow_bed"
|
|
||||||
- "minecraft:powered_rail"
|
|
||||||
- "minecraft:detector_rail"
|
|
||||||
- "minecraft:grass"
|
|
||||||
- "minecraft:dead_bush"
|
|
||||||
- "minecraft:moving_piston"
|
|
||||||
- "minecraft:piston_head"
|
|
||||||
- "minecraft:sunflower"
|
|
||||||
- "minecraft:rose_bush"
|
|
||||||
- "minecraft:dandelion"
|
|
||||||
- "minecraft:poppy"
|
|
||||||
- "minecraft:brown_mushroom"
|
|
||||||
- "minecraft:red_mushroom"
|
|
||||||
- "minecraft:tnt"
|
|
||||||
- "minecraft:torch"
|
|
||||||
- "minecraft:fire"
|
|
||||||
- "minecraft:redstone_wire"
|
|
||||||
- "minecraft:wheat"
|
|
||||||
- "minecraft:potatoes"
|
|
||||||
- "minecraft:carrots"
|
|
||||||
- "minecraft:melon_stem"
|
|
||||||
- "minecraft:pumpkin_stem"
|
|
||||||
- "minecraft:beetroots"
|
|
||||||
- "minecraft:rail"
|
|
||||||
- "minecraft:lever"
|
|
||||||
- "minecraft:redstone_torch"
|
|
||||||
- "minecraft:redstone_wall_torch"
|
|
||||||
- "minecraft:repeater"
|
|
||||||
- "minecraft:comparator"
|
|
||||||
- "minecraft:stone_button"
|
|
||||||
- "minecraft:birch_button"
|
|
||||||
- "minecraft:acacia_button"
|
|
||||||
- "minecraft:dark_oak_button"
|
|
||||||
- "minecraft:jungle_button"
|
|
||||||
- "minecraft:oak_button"
|
|
||||||
- "minecraft:spruce_button"
|
|
||||||
- "minecraft:cactus"
|
|
||||||
- "minecraft:sugar_cane"
|
|
||||||
- "minecraft:bedrock"
|
|
||||||
|
|
||||||
use-inventory:
|
use-inventory:
|
||||||
enable: false
|
enable: false
|
||||||
|
@ -153,4 +153,9 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
|
|||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BlockVector3> getVerticies() {
|
||||||
|
return positions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,4 +229,8 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BlockVector3> getVerticies() {
|
||||||
|
return new ArrayList<>(region.getVertices());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ProtectedField")
|
@SuppressWarnings("ProtectedField")
|
||||||
protected final World world;
|
|
||||||
private String worldName;
|
private String worldName;
|
||||||
private FaweQueue queue;
|
private FaweQueue queue;
|
||||||
private boolean wrapped;
|
private boolean wrapped;
|
||||||
|
@ -31,6 +31,7 @@ import com.sk89q.worldedit.IncompleteRegionException;
|
|||||||
import com.sk89q.worldedit.NotABlockException;
|
import com.sk89q.worldedit.NotABlockException;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.blocks.MobSpawnerBlock;
|
import com.sk89q.worldedit.blocks.MobSpawnerBlock;
|
||||||
import com.sk89q.worldedit.blocks.SignBlock;
|
import com.sk89q.worldedit.blocks.SignBlock;
|
||||||
import com.sk89q.worldedit.blocks.SkullBlock;
|
import com.sk89q.worldedit.blocks.SkullBlock;
|
||||||
@ -42,6 +43,8 @@ import com.sk89q.worldedit.extension.input.NoMatchException;
|
|||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
@ -107,8 +110,6 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] EMPTY_STRING_ARRAY = new String[]{};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Backwards compatibility for wool colours in block syntax.
|
* Backwards compatibility for wool colours in block syntax.
|
||||||
*
|
*
|
||||||
@ -214,7 +215,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
final World world = context.requireWorld();
|
final World world = context.requireWorld();
|
||||||
final BlockVector3 primaryPosition;
|
final BlockVector3 primaryPosition;
|
||||||
try {
|
try {
|
||||||
primaryPosition = context.requireSession().getRegionSelector(world).getPrimaryPosition();
|
primaryPosition = context.requireSession().getRegionSelector(world).getVerticies().get(index - 1);
|
||||||
} catch (IncompleteRegionException e) {
|
} catch (IncompleteRegionException e) {
|
||||||
throw new InputParseException("Your selection is not complete.");
|
throw new InputParseException("Your selection is not complete.");
|
||||||
}
|
}
|
||||||
@ -226,6 +227,25 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
||||||
// Get the block type from the item in the user's off hand.
|
// Get the block type from the item in the user's off hand.
|
||||||
state = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
|
state = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
|
||||||
|
} else if (typeString.matches("slot[0-9]+")) {
|
||||||
|
int slot = Integer.parseInt(typeString.substring(4)) - 1;
|
||||||
|
Actor actor = context.requireActor();
|
||||||
|
if (!(actor instanceof Player)) {
|
||||||
|
throw new InputParseException("The user is not a player!");
|
||||||
|
}
|
||||||
|
Player player = (Player) actor;
|
||||||
|
BlockBag bag = player.getInventoryBlockBag();
|
||||||
|
if (bag == null || !(bag instanceof SlottableBlockBag)) {
|
||||||
|
throw new InputParseException("Unsupported!");
|
||||||
|
}
|
||||||
|
SlottableBlockBag slottable = (SlottableBlockBag) bag;
|
||||||
|
BaseItem item = slottable.getItem(slot);
|
||||||
|
|
||||||
|
if (!item.getType().hasBlockType()) {
|
||||||
|
throw new InputParseException("You're not holding a block!");
|
||||||
|
}
|
||||||
|
state = item.getType().getBlockType().getDefaultState();
|
||||||
|
nbt = item.getNbtData();
|
||||||
} else {
|
} else {
|
||||||
BlockType type = BlockTypes.parse(typeString.toLowerCase());
|
BlockType type = BlockTypes.parse(typeString.toLowerCase());
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
|
|
||||||
|
public interface SlottableBlockBag {
|
||||||
|
BaseItem getItem(int slot);
|
||||||
|
|
||||||
|
void setItem(int slot, BaseItem block);
|
||||||
|
|
||||||
|
default int size() {
|
||||||
|
return 36;
|
||||||
|
}
|
||||||
|
|
||||||
|
default int getSelectedSlot() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
@ -34,7 +34,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class CombinedRegionFunction implements RegionFunction {
|
public class CombinedRegionFunction implements RegionFunction {
|
||||||
|
|
||||||
private final List<RegionFunction> functions = new ArrayList<>();
|
private RegionFunction[] functions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a combined region function.
|
* Create a combined region function.
|
||||||
@ -49,7 +49,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
|||||||
*/
|
*/
|
||||||
public CombinedRegionFunction(Collection<RegionFunction> functions) {
|
public CombinedRegionFunction(Collection<RegionFunction> functions) {
|
||||||
checkNotNull(functions);
|
checkNotNull(functions);
|
||||||
this.functions.addAll(functions);
|
this.functions = functions.toArray(new RegionFunction[functions.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,7 +58,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
|||||||
* @param function an array of functions to match
|
* @param function an array of functions to match
|
||||||
*/
|
*/
|
||||||
public CombinedRegionFunction(RegionFunction... function) {
|
public CombinedRegionFunction(RegionFunction... function) {
|
||||||
this(Arrays.asList(checkNotNull(function)));
|
this.functions = function;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CombinedRegionFunction combine(RegionFunction function, RegionFunction add) {
|
public static CombinedRegionFunction combine(RegionFunction function, RegionFunction add) {
|
||||||
@ -82,7 +82,9 @@ public class CombinedRegionFunction implements RegionFunction {
|
|||||||
*/
|
*/
|
||||||
public void add(Collection<RegionFunction> functions) {
|
public void add(Collection<RegionFunction> functions) {
|
||||||
checkNotNull(functions);
|
checkNotNull(functions);
|
||||||
this.functions.addAll(functions);
|
ArrayList<RegionFunction> functionsList = new ArrayList<>(Arrays.asList(this.functions));
|
||||||
|
functionsList.addAll(functions);
|
||||||
|
this.functions = functionsList.toArray(new RegionFunction[functionsList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,9 +100,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
|||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
boolean ret = false;
|
boolean ret = false;
|
||||||
for (RegionFunction function : functions) {
|
for (RegionFunction function : functions) {
|
||||||
if (function.apply(position)) {
|
ret |= (function.apply(position));
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -69,12 +69,11 @@ public class ExtentBlockCopy implements RegionFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
BaseBlock block = source.getFullBlock(position);
|
|
||||||
BlockVector3 orig = position.subtract(from);
|
BlockVector3 orig = position.subtract(from);
|
||||||
BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint();
|
BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint();
|
||||||
|
|
||||||
// Apply transformations to NBT data if necessary
|
// Apply transformations to NBT data if necessary
|
||||||
block = transformNbtData(block);
|
BaseBlock block = transformNbtData(source.getFullBlock(position));
|
||||||
|
|
||||||
return destination.setBlock(transformed.add(to), block);
|
return destination.setBlock(transformed.add(to), block);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,9 @@ public class BlockTypeMask extends AbstractExtentMask {
|
|||||||
* @param block an array of blocks
|
* @param block an array of blocks
|
||||||
*/
|
*/
|
||||||
public void add(BlockType... block) {
|
public void add(BlockType... block) {
|
||||||
add(Arrays.asList(checkNotNull(block)));
|
for (BlockType type : block) {
|
||||||
|
this.types[type.getInternalId()] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,15 +68,15 @@ public class ChangeSetExecutor implements Operation {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation resume(RunContext run) throws WorldEditException {
|
public Operation resume(RunContext run) throws WorldEditException {
|
||||||
while (iterator.hasNext()) {
|
|
||||||
Change change = iterator.next();
|
|
||||||
if (type == Type.UNDO) {
|
if (type == Type.UNDO) {
|
||||||
change.undo(context);
|
while (iterator.hasNext()) {
|
||||||
|
iterator.next().undo(context);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
change.redo(context);
|
while (iterator.hasNext()) {
|
||||||
|
iterator.next().redo(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
*/
|
*/
|
||||||
public final class Operations {
|
public final class Operations {
|
||||||
|
|
||||||
|
private static final RunContext context = new RunContext();
|
||||||
|
|
||||||
private Operations() {
|
private Operations() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +40,7 @@ public final class Operations {
|
|||||||
*/
|
*/
|
||||||
public static void complete(Operation op) throws WorldEditException {
|
public static void complete(Operation op) throws WorldEditException {
|
||||||
while (op != null) {
|
while (op != null) {
|
||||||
op = op.resume(new RunContext());
|
op = op.resume(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ public final class Operations {
|
|||||||
public static void completeLegacy(Operation op) throws MaxChangedBlocksException {
|
public static void completeLegacy(Operation op) throws MaxChangedBlocksException {
|
||||||
while (op != null) {
|
while (op != null) {
|
||||||
try {
|
try {
|
||||||
op = op.resume(new RunContext());
|
op = op.resume(context);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
@ -71,7 +73,7 @@ public final class Operations {
|
|||||||
public static void completeBlindly(Operation op) {
|
public static void completeBlindly(Operation op) {
|
||||||
while (op != null) {
|
while (op != null) {
|
||||||
try {
|
try {
|
||||||
op = op.resume(new RunContext());
|
op = op.resume(context);
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -184,8 +184,8 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
* @param position the position
|
* @param position the position
|
||||||
*/
|
*/
|
||||||
public void visit(BlockVector3 position) {
|
public void visit(BlockVector3 position) {
|
||||||
|
if (!visited.contains(position)) {
|
||||||
BlockVector3 blockVector = position;
|
BlockVector3 blockVector = position;
|
||||||
if (!visited.contains(blockVector)) {
|
|
||||||
isVisitable(blockVector, blockVector); // Ignore this, just to initialize mask on this point
|
isVisitable(blockVector, blockVector); // Ignore this, just to initialize mask on this point
|
||||||
queue.add(blockVector);
|
queue.add(blockVector);
|
||||||
visited.add(blockVector);
|
visited.add(blockVector);
|
||||||
@ -314,7 +314,8 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
|
queue.clear();
|
||||||
|
visited.clear();
|
||||||
|
affected = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -156,4 +156,12 @@ public interface RegionSelector {
|
|||||||
*/
|
*/
|
||||||
List<String> getInformationLines();
|
List<String> getInformationLines();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the verticies
|
||||||
|
* @return
|
||||||
|
* @throws IncompleteRegionException
|
||||||
|
*/
|
||||||
|
default List<BlockVector3> getVerticies() throws IncompleteRegionException {
|
||||||
|
return Collections.singletonList(getPrimaryPosition());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,4 +276,8 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BlockVector3> getVerticies() {
|
||||||
|
return new ArrayList<>(region.getVertices());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ import com.sk89q.worldedit.world.World;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -308,4 +309,9 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
return "cuboid";
|
return "cuboid";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BlockVector3> getVerticies() {
|
||||||
|
return Arrays.asList(position1, position2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren