Skip to content
Michael Smith edited this page Dec 8, 2017 · 10 revisions

Examples

See this page for a quick example on usage.

Table of Contents

Events

virtualchest_closed - A player closed a virtual chest.

Event data:

  • player - Name of the player viewing the chest.

  • chest - @chestdata


virtualchest_opened - A player had a virtual chest shown to them.

Event data:

  • player - Name of the player viewing the chest.

  • chest - @chestdata


General Functions

all_virtualchests() - Get a list of all the known cached virtualchest ids.

Returns: non-associative array of strings relating to chest ids


clear_virtualchest(@id[, @slot]) - Remove all items from a virtual chest, or clears one item slot.

If @slot is specified, only that slot is cleared.

Returns: nothing


close_virtualchest(@id) - Close a virtual chest for all of it's viewers.

Returns: nothing


create_virtualchest(@chestdata) - Create a virtual chest with specified parameters.

Returns: nothing


del_virtualchest(@id) - Delete a virtual chest from cache.

This will also close the virtualchest for any viewers.

Returns: nothing


get_virtualchest(@id) - Get the contents and identifier variables for a chest with String identifier @id.

Returns: [@chestdata][chestdata]


set_virtualchest(@id, @chestdata) - Set a chest whose id is @id to contain the items from @itemarray.

The original contents are replaced entirely.

Returns: nothing


set_virtualchest(@chestdata) - Alternate syntax for set_virtualchest(@id, @itemarray).

Returns: nothing


update_virtualchest(@id, @itemarray) - Set a chest whose id is @id to include the items from @itemarray.

The original contents are still present if not replaced by the new array.

Returns: nothing


update_virtualchest(@chestdata) - Alternate syntax for update_virtualchest(@id, @itemarray).

Returns: nothing


addto_virtualchest(@id, @itemid, @qty, [, @meta]) - Add item with @itemid to a chest whose id is @id. You must specify quantity as integer in @qty. You can also add meta info in @meta.

Returns: @qty minus the number of items actually given, can be 0 if succeeded to add the whole quantity of items


takefrom_virtualchest(@id, @itemid, @qty) - Take item with @itemid from a chest whose id is @id. You must specify quantity as integer in @qty.

Returns: the number of items actually taken, which will be from 0 to @qty


Player Functions

pget_virtualchest([@playername]) - Get the chest the player is viewing.

Returns: id of chest being viewed, or null if the player is not viewing a virtual chest


popen_virtualchest([@playername,] @id) - Show a player a given virtual chest.

Returns: nothing


pviewing_virtualchest(@id) - Get the viewers watching a given chest.

Returns: non-associative array of strings relating to player names


Glossary

  • id - String - The id of a virtual chest.

    Always required when working with a chest.

  • type - String - The inventory type.

    This supports most Bukkit Inventory types, most notably BREWING, CHEST, DISPENSER, FURNACE, HOPPER, WORKBENCH, ANVIL, and BEACON.

  • size - Integer - A capacity for a virtual chest.

    Only applies to CHEST inventory type. Must be a multiple of 9. Values greater than 54 will have graphical issues, but otherwise are accepted and functional. Defaults to 54.

  • title - String - Displayed title when viewing a virtual chest.

    Defaults to Virtual Chest.

  • chestdata - Associative Array - An array describing a virtual chest in a form that can be used with get_value() and store_value().

    Contains id and optionally type, size and title, as well as entries for @itemdata whose keys refer to the slot number. Functions that return this will return null values in empty slots.

    size defaults to 54, type defaults to CHEST, and title defaults to Virtual Chest.

  • itemid - Integer - An ID of item.

  • itemdata - Associative Array - An array describing an itemstack. At the time of this writing, contains keys type (numeric Minecraft item type), qty (amount of this item), data (any numeric data, such as direction, color, etc), enchantments (associative array), @meta (associative array)

  • itemarray - Associative Array - An array describing a collection of @itemdata. The keys are integers representing the slot.

  • meta - Associative Array - An array describing a item data. Please go to http://wiki.sk89q.com/wiki/CommandHelper/Staged/API/set_itemmeta for more details.

Clone this wiki locally