mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Update Upstream
b1c230d Add conditional checking in help command (1888) b4fbbc9 Move clearable checks for Bukkit to adapters (1887)
This commit is contained in:
@ -61,7 +61,6 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.DoubleChestInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
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
|
||||
public boolean clearContainerBlockContents(BlockVector3 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()) {
|
||||
return false;
|
||||
}
|
||||
@ -286,7 +264,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
InventoryHolder chest = (InventoryHolder) state;
|
||||
Inventory inven = chest.getInventory();
|
||||
if (chest instanceof Chest) {
|
||||
inven = getBlockInventory((Chest) chest);
|
||||
inven = ((Chest) chest).getBlockInventory();
|
||||
}
|
||||
inven.clear();
|
||||
return true;
|
||||
|
@ -258,6 +258,17 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
||||
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
|
||||
default BlockMaterial getMaterial(BlockType blockType) {
|
||||
return getMaterial(blockType.getDefaultState());
|
||||
|
Reference in New Issue
Block a user