Shulkers Plugin Documentation

A Bukkit/Spigot plugin that replicates Shulker Boxes in Minecraft 1.8

API Features

Basic Usage

Check if an item is a Shulker Box:

if (ShulkersAPI.isShulkerBoxItemStack(item)) {
    // it's a valid shulker box - do something with the Shulker Box
}

Read contents:

ItemStack[] contents = ShulkersAPI.getContents(shulkerItem);

Set contents:

ItemStack[] contents = new ItemStack[27];
contents[0] = new ItemStack(Material.DIAMOND_SWORD);
contents[1] = new ItemStack(Material.APPLE, 5);

ItemStack updated = ShulkersAPI.setContents(shulkerItem, contents);

Usage of API Example

@EventHandler
public void on(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    ItemStack hand = player.getItemInHand();

    if (event.getAction() != Action.RIGHT_CLICK_AIR) return;
    if (!ShulkersAPI.isShulkerBoxItemStack(hand)) return;

    ItemStack[] contents = ShulkersAPI.getContents(hand);
    Inventory preview = Bukkit.createInventory(new ShulkerInventoryHolder, 27,
        hand.getItemMeta().getDisplayName() + ChatColor.RESET + " Preview");

    preview.setContents(contents);
    player.openInventory(preview);
}

API Methods

Below are the public methods available in ShulkersAPI:

isShulkerBoxItemStack(ItemStack)

Returns true if the given ItemStack is a Shulker Box.

isShulkerBox(Block)

Returns true if the given Block is a Shulker Box.

newShulkerBox()

Creates a new empty Shulker Box ItemStack.

getShulkerBoxItemStackColor(ItemStack)

Returns the ShulkerType color of the Shulker Box item.

getShulkerBoxColor(Block)

Returns the ShulkerType color of a placed Shulker Box block.

setShulkerBoxColor(Block, ShulkerType)

Sets the color of a placed Shulker Box block. Accepts all color variants.

setShulkerBoxItemColor(ItemStack, ShulkerType)

Sets the color of a Shulker Box item. Only accepts normal colors (not sideways or open variants).

setDisplayName(ItemStack, String)

Sets the display name of the Shulker Box item.

clearShulkerBoxInventory(Block)

Clears the inventory of a placed Shulker Box block.

clearShulkerBoxItemInventory(ItemStack)

Removes all contents from the Shulker Box item.

clearShulkerBoxEntityInventory(Item)

Removes all contents from a dropped Shulker Box entity.

addItem(ItemStack, ItemStack)

Adds the specified item to the Shulker Box's item inventory. Updates the lore preview.

setItem(ItemStack, ItemStack, int)

Sets an item in the Shulker Box inventory at the given slot.

getContents(ItemStack)

Returns the contents of the Shulker Box item as an array.

setContents(ItemStack, ItemStack[])

Replaces the contents of the Shulker Box with the provided array of ItemStacks.

isShulkerBoxItemFull(ItemStack)

Returns true if the Shulker Box item inventory is full (i.e., no empty slots).

getItem(ItemStack shulkerBox, int slot)

Returns ItemStack from the specified int slot from the specified Shulker Box ItemStack.

translateShulkerTypeToDyeColor(ShulkerType color)

Returns Bukkit API DyeColor enum type translated from the ShulkerType color.

translateDyeColorToShulkerType(DyeColor color)

Returns Shulkers ShulkerType enum type translated from the (Bukkit API) DyeColor color.

Custom Events

Shulkers fires several custom events that you can listen to in your plugin to interact with its lifecycle and behavior.

ShulkerBoxOpenEvent

Fired when a player tries to open a placed Shulker Box.

getPlayer() returns the player who opened it.
getInventory() returns the Shulker Box Inventory.
getShulkerBoxBlock() returns the Shulker Box Block.

This Event can be cancelled via event.setCancelled(true)

ShulkerBoxCloseEvent

Fired when a Shulker Box GUI is closed.

getInventory() returns the Shulker Box Inventory.
getPlayer() returns the player which was last to close the Shulker Box.

ShulkerBoxDispenseEvent

Fired when a Shulker Box is placed by a Dispenser

getDispenser() returns the Dispenser
getShulkerBoxItemStack() returns the Shulker Box ItemStack that will be placed by the Dispenser
getShulkerBox() returns the Shulker Box Block that was placed by the Dispenser

This Event can be cancelled via event.setCancelled(true)

ShulkerBoxDyeEvent

Fired when a player attempts to dye a Shulker Box ItemStack in a crafting inventory.

getPlayer() returns the Player that attempted to dye the Shulker Box in the Crafting Inventory.
getView() returns the InventoryView Bukkit object.
getCraftingInventory() returns the current Crafting Inventory.
getSlot() returns the clicked slot (int).
getClickType() returns the ClickType enum type.
getInventoryAction() returns the InventoryAction enum type.
getOldColor() returns the previous DyeColor enum type of the Shulker Box before dyeing.
getNewColor() returns the new DyeColor enum type that the Shulker Box is being dyed to.

This Event can be cancelled via event.setCancelled(true)

ShulkerBoxUndyeEvent

Fired when a player attempts to undye a Shulker Box ItemStack by right-clicking a Cauldron.
getCauldron() returns the Block Cauldron.
getPreviousWaterLevel() returns the previous (int) Cauldron water level before undyeing.
getCurrentWaterLevel() returns the current (int) Cauldon water level after undeying.
getPlayer() returns the Player that attempted to undye the Shulker Box ItemStack.
getShulkerBox() returns the Shulker Box ItemStack that would be undyed.
getColor() returns ShulkerType enum type of the color of the Shulker Box before undyeing.

This Event can be cancelled via event.setCancelled(true)

ShulkerBoxPlaceEvent

Fired when a player attempts to place a Shulker Box.
getShulkerBox() returns the Block (Shulker Box) which was placed.
getItemInHand() returns the ItemStack in the player's hand at the time of the event.
getPlayer() returns the Player which caused this event to fire.

This Event can be cancelled via event.setCancelled(true)

ShulkerBoxBreakEvent

Fired when a player attempts to place a Shulker Box.
getShulkerBox() returns the Block (Shulker Box) which was broken.
getPlayer() returns the Player which caused this event to fire.

This Event can be cancelled via event.setCancelled(true)