geforkt von Mirrors/FastAsyncWorldEdit
Update Upstream
b1c230d Add conditional checking in help command (1888) b4fbbc9 Move clearable checks for Bukkit to adapters (1887)
Dieser Commit ist enthalten in:
Ursprung
cdc3abbc43
Commit
d236470df8
@ -61,7 +61,6 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.DoubleChestInventory;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
@ -242,37 +241,16 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the single block inventory for a potentially double chest.
|
|
||||||
* Handles people who have an old version of Bukkit.
|
|
||||||
* This should be replaced with {@link org.bukkit.block.Chest#getBlockInventory()}
|
|
||||||
* in a few months (now = March 2012) // note from future dev - lol
|
|
||||||
*
|
|
||||||
* @param chest The chest to get a single block inventory for
|
|
||||||
* @return The chest's inventory
|
|
||||||
*/
|
|
||||||
private Inventory getBlockInventory(Chest chest) {
|
|
||||||
try {
|
|
||||||
return chest.getBlockInventory();
|
|
||||||
} catch (Throwable t) {
|
|
||||||
if (chest.getInventory() instanceof DoubleChestInventory) {
|
|
||||||
DoubleChestInventory inven = (DoubleChestInventory) chest.getInventory();
|
|
||||||
if (inven.getLeftSide().getHolder().equals(chest)) {
|
|
||||||
return inven.getLeftSide();
|
|
||||||
} else if (inven.getRightSide().getHolder().equals(chest)) {
|
|
||||||
return inven.getRightSide();
|
|
||||||
} else {
|
|
||||||
return inven;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return chest.getInventory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean clearContainerBlockContents(BlockVector3 pt) {
|
public boolean clearContainerBlockContents(BlockVector3 pt) {
|
||||||
checkNotNull(pt);
|
checkNotNull(pt);
|
||||||
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
|
if (adapter != null) {
|
||||||
|
try {
|
||||||
|
return adapter.clearContainerBlockContents(getWorld(), pt);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!getBlock(pt).getBlockType().getMaterial().hasContainer()) {
|
if (!getBlock(pt).getBlockType().getMaterial().hasContainer()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -286,7 +264,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
InventoryHolder chest = (InventoryHolder) state;
|
InventoryHolder chest = (InventoryHolder) state;
|
||||||
Inventory inven = chest.getInventory();
|
Inventory inven = chest.getInventory();
|
||||||
if (chest instanceof Chest) {
|
if (chest instanceof Chest) {
|
||||||
inven = getBlockInventory((Chest) chest);
|
inven = ((Chest) chest).getBlockInventory();
|
||||||
}
|
}
|
||||||
inven.clear();
|
inven.clear();
|
||||||
return true;
|
return true;
|
||||||
|
@ -258,6 +258,17 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
|||||||
throw new UnsupportedOperationException("This adapter does not support regeneration.");
|
throw new UnsupportedOperationException("This adapter does not support regeneration.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the contents of a Clearable block.
|
||||||
|
*
|
||||||
|
* @param world The world
|
||||||
|
* @param pt The location
|
||||||
|
* @return If a block was cleared
|
||||||
|
*/
|
||||||
|
default boolean clearContainerBlockContents(World world, BlockVector3 pt) {
|
||||||
|
throw new UnsupportedOperationException("This adapter does not support clearing block contents.");
|
||||||
|
}
|
||||||
|
|
||||||
//FAWE start
|
//FAWE start
|
||||||
default BlockMaterial getMaterial(BlockType blockType) {
|
default BlockMaterial getMaterial(BlockType blockType) {
|
||||||
return getMaterial(blockType.getDefaultState());
|
return getMaterial(blockType.getDefaultState());
|
||||||
|
Binäre Datei nicht angezeigt.
@ -30,6 +30,9 @@ import com.sk89q.worldedit.util.formatting.component.InvalidComponentException;
|
|||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import org.enginehub.piston.Command;
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
|
import org.enginehub.piston.inject.InjectedValueStore;
|
||||||
|
import org.enginehub.piston.inject.Key;
|
||||||
|
import org.enginehub.piston.inject.MapBackedValueStore;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -48,6 +51,9 @@ import static java.util.stream.Collectors.toList;
|
|||||||
// Stored in a separate class to prevent import conflicts, and because it's aliased via /we help.
|
// Stored in a separate class to prevent import conflicts, and because it's aliased via /we help.
|
||||||
public class PrintCommandHelp {
|
public class PrintCommandHelp {
|
||||||
|
|
||||||
|
private PrintCommandHelp() {
|
||||||
|
}
|
||||||
|
|
||||||
private static Command detectCommand(CommandManager manager, String command) {
|
private static Command detectCommand(CommandManager manager, String command) {
|
||||||
Optional<Command> mapping;
|
Optional<Command> mapping;
|
||||||
|
|
||||||
@ -140,8 +146,12 @@ public class PrintCommandHelp {
|
|||||||
int page, Stream<Command> commandStream, Actor actor,
|
int page, Stream<Command> commandStream, Actor actor,
|
||||||
List<Command> commandList, String helpRootCommand
|
List<Command> commandList, String helpRootCommand
|
||||||
) throws InvalidComponentException {
|
) throws InvalidComponentException {
|
||||||
|
InjectedValueStore store = MapBackedValueStore.create();
|
||||||
|
store.injectValue(Key.of(Actor.class), context ->
|
||||||
|
Optional.of(actor));
|
||||||
// Get a list of aliases
|
// Get a list of aliases
|
||||||
List<Command> commands = commandStream
|
List<Command> commands = commandStream
|
||||||
|
.filter(command -> command.getCondition().satisfied(store))
|
||||||
.sorted(byCleanName())
|
.sorted(byCleanName())
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
|
||||||
@ -166,7 +176,4 @@ public class PrintCommandHelp {
|
|||||||
actor.print(box.create(page));
|
actor.print(box.create(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
private PrintCommandHelp() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren