3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00
Dieser Commit ist enthalten in:
Jesse Boyd 2019-06-29 03:10:47 +10:00
Ursprung 8c44c532c4
Commit a2efdbc488
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
18 geänderte Dateien mit 125 neuen und 95 gelöschten Zeilen

Datei anzeigen

@ -19,17 +19,19 @@
package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.extent.inventory.BlockBagException;
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
import com.sk89q.worldedit.extent.inventory.OutOfSpaceException;
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class BukkitPlayerBlockBag extends BlockBag {
public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag {
private Player player;
private ItemStack[] items;
@ -61,6 +63,19 @@ public class BukkitPlayerBlockBag extends BlockBag {
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
public void fetchBlock(BlockState blockState) throws BlockBagException {
if (blockState.getBlockType().getMaterial().isAir()) {

Datei anzeigen

@ -28,6 +28,7 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.command.CommandMapping;
import com.sk89q.worldedit.util.command.Dispatcher;
import com.sk89q.worldedit.world.World;
import org.bukkit.block.Block;
import org.bukkit.event.Event.Result;
@ -108,6 +109,8 @@ public class WorldEditListener implements Listener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerCommand(PlayerCommandSendEvent event) {
Dispatcher dispatcher = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher();
if (dispatcher != null) {
CommandLocals locals = new CommandLocals();
locals.put(Actor.class, plugin.wrapCommandSender(event.getPlayer()));
Set<String> toRemove = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher().getCommands().stream()
@ -115,6 +118,7 @@ public class WorldEditListener implements Listener {
.map(CommandMapping::getPrimaryAlias)
.collect(Collectors.toSet());
event.getCommands().removeIf(toRemove::contains);
}
}
/**

Datei anzeigen

@ -19,6 +19,8 @@
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.bukkit.FaweBukkit;
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
// Register CUI
fail(() -> {
getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL);
}, "Failed to register CUI");
// Now we can register events
getServer().getPluginManager().registerEvents(new WorldEditListener(this), this);

Datei anzeigen

@ -30,67 +30,7 @@ limits:
butcher-radius:
default: -1
maximum: -1
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"
disallowed-blocks: []
use-inventory:
enable: false

Datei anzeigen

@ -153,4 +153,9 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
}
return lines;
}
@Override
public List<BlockVector3> getVerticies() {
return positions;
}
}

Datei anzeigen

@ -229,4 +229,8 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion {
}
}
@Override
public List<BlockVector3> getVerticies() {
return new ArrayList<>(region.getVertices());
}
}

Datei anzeigen

@ -205,7 +205,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
}
@SuppressWarnings("ProtectedField")
protected final World world;
private String worldName;
private FaweQueue queue;
private boolean wrapped;

Datei anzeigen

@ -31,6 +31,7 @@ import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.MobSpawnerBlock;
import com.sk89q.worldedit.blocks.SignBlock;
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.platform.Actor;
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.math.BlockVector3;
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.
*
@ -214,18 +215,37 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
final World world = context.requireWorld();
final BlockVector3 primaryPosition;
try {
primaryPosition = context.requireSession().getRegionSelector(world).getPrimaryPosition();
primaryPosition = context.requireSession().getRegionSelector(world).getVerticies().get(index - 1);
} catch (IncompleteRegionException e) {
throw new InputParseException("Your selection is not complete.");
}
state = world.getBlock(primaryPosition);
} else {
if ("hand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's hand.
state = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
} else if ("offhand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's off hand.
state = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
// Get the block type from the item in the user's hand.
state = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
} else if ("offhand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's 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 {
BlockType type = BlockTypes.parse(typeString.toLowerCase());

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -34,7 +34,7 @@ import java.util.List;
*/
public class CombinedRegionFunction implements RegionFunction {
private final List<RegionFunction> functions = new ArrayList<>();
private RegionFunction[] functions;
/**
* Create a combined region function.
@ -49,7 +49,7 @@ public class CombinedRegionFunction implements RegionFunction {
*/
public CombinedRegionFunction(Collection<RegionFunction> 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
*/
public CombinedRegionFunction(RegionFunction... function) {
this(Arrays.asList(checkNotNull(function)));
this.functions = function;
}
public static CombinedRegionFunction combine(RegionFunction function, RegionFunction add) {
@ -82,7 +82,9 @@ public class CombinedRegionFunction implements RegionFunction {
*/
public void add(Collection<RegionFunction> 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 {
boolean ret = false;
for (RegionFunction function : functions) {
if (function.apply(position)) {
ret = true;
}
ret |= (function.apply(position));
}
return ret;
}

Datei anzeigen

@ -69,12 +69,11 @@ public class ExtentBlockCopy implements RegionFunction {
@Override
public boolean apply(BlockVector3 position) throws WorldEditException {
BaseBlock block = source.getFullBlock(position);
BlockVector3 orig = position.subtract(from);
BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint();
// Apply transformations to NBT data if necessary
block = transformNbtData(block);
BaseBlock block = transformNbtData(source.getFullBlock(position));
return destination.setBlock(transformed.add(to), block);
}

Datei anzeigen

@ -91,7 +91,9 @@ public class BlockTypeMask extends AbstractExtentMask {
* @param block an array of blocks
*/
public void add(BlockType... block) {
add(Arrays.asList(checkNotNull(block)));
for (BlockType type : block) {
this.types[type.getInternalId()] = true;
}
}
/**

Datei anzeigen

@ -68,15 +68,15 @@ public class ChangeSetExecutor implements Operation {
@Override
public Operation resume(RunContext run) throws WorldEditException {
while (iterator.hasNext()) {
Change change = iterator.next();
if (type == Type.UNDO) {
change.undo(context);
} else {
change.redo(context);
if (type == Type.UNDO) {
while (iterator.hasNext()) {
iterator.next().undo(context);
}
} else {
while (iterator.hasNext()) {
iterator.next().redo(context);
}
}
return null;
}

Datei anzeigen

@ -27,6 +27,8 @@ import com.sk89q.worldedit.WorldEditException;
*/
public final class Operations {
private static final RunContext context = new RunContext();
private Operations() {
}
@ -38,7 +40,7 @@ public final class Operations {
*/
public static void complete(Operation op) throws WorldEditException {
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 {
while (op != null) {
try {
op = op.resume(new RunContext());
op = op.resume(context);
} catch (MaxChangedBlocksException e) {
throw e;
} catch (WorldEditException e) {
@ -71,7 +73,7 @@ public final class Operations {
public static void completeBlindly(Operation op) {
while (op != null) {
try {
op = op.resume(new RunContext());
op = op.resume(context);
} catch (WorldEditException e) {
throw new RuntimeException(e);
}

Datei anzeigen

@ -184,8 +184,8 @@ public abstract class BreadthFirstSearch implements Operation {
* @param position the position
*/
public void visit(BlockVector3 position) {
BlockVector3 blockVector = position;
if (!visited.contains(blockVector)) {
if (!visited.contains(position)) {
BlockVector3 blockVector = position;
isVisitable(blockVector, blockVector); // Ignore this, just to initialize mask on this point
queue.add(blockVector);
visited.add(blockVector);
@ -314,7 +314,8 @@ public abstract class BreadthFirstSearch implements Operation {
@Override
public void cancel() {
queue.clear();
visited.clear();
affected = 0;
}
}

Datei anzeigen

@ -156,4 +156,12 @@ public interface RegionSelector {
*/
List<String> getInformationLines();
/**
* Get the verticies
* @return
* @throws IncompleteRegionException
*/
default List<BlockVector3> getVerticies() throws IncompleteRegionException {
return Collections.singletonList(getPrimaryPosition());
}
}

Datei anzeigen

@ -276,4 +276,8 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
}
}
@Override
public List<BlockVector3> getVerticies() {
return new ArrayList<>(region.getVertices());
}
}

Datei anzeigen

@ -40,6 +40,7 @@ import com.sk89q.worldedit.world.World;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@ -308,4 +309,9 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
return "cuboid";
}
@Override
public List<BlockVector3> getVerticies() {
return Arrays.asList(position1, position2);
}
}