org.bukkit.block.ShulkerBox Java Examples

The following examples show how to use org.bukkit.block.ShulkerBox. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DisableShulkerboxes.java    From Minepacks with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event)
{
	if(event.getInventory().getHolder() != null && event.getInventory().getHolder().getClass().getName().toLowerCase(Locale.ROOT).contains("shulker"))
	{
		if(removeExisting)
		{
			Block shulkerBlock = ((ShulkerBox) event.getInventory().getHolder()).getBlock();
			if(dropExistingContent)
			{
				Utils.dropInventory(event.getInventory(), shulkerBlock.getLocation());
			}
			event.getInventory().clear();
			shulkerBlock.setType(Material.AIR);
		}
		event.setCancelled(true);
	}
}
 
Example #2
Source File: DisableShulkerboxes.java    From Minepacks with GNU General Public License v3.0 5 votes vote down vote up
private boolean handleShulkerBlock(Block block)
{
	if(SHULKER_BOX_MATERIALS.contains(block.getType()))
	{
		if(removeExisting)
		{
			ShulkerBox shulkerBox = (ShulkerBox) block.getState();
			if(dropExistingContent) Utils.dropInventory(shulkerBox.getInventory(), shulkerBox.getLocation());
			shulkerBox.getInventory().clear();
			block.setType(Material.AIR);
		}
		return true;
	}
	return false;
}