manage_inventory
Quite a multifunctional action that allows you to manage (save, open, set, add, clear and delete) different inventories to the players, blocks, entities etc.
Meaning
Allows you to manage (save, open, set, add, clear and delete) different inventories to the players, blocks, entities etc. You can, for example, save inventory of some entity, open inventory of some player, set inventory of some block from the saved entity's inventory or current player's inventory and many more.
Format
- 'manage_inventory: action:<action>;<option>:<value>;<optionN>:<valueN>'action:<action> โ may be save, open, set, add, clear or delete, "save" will save the inventory from some owner or newly created with possible further opening or deletion, "open" will open the inventory to the target from some owner, from some saved inventory or newly created, "set" and "add" will set/add the inventory to the target from some owner or from some saved inventory, "clear" will clear the inventory to the target and "delete" will delete the specified saved inventory, also "set" and "clear" can set and reset title for the opened player's inventory if only title and target are specified, you can add "?" symbol before the action to use the temporary inventories storage, that is, until server restart (see more info about "?" in the hints); (MANDATORY)
Options (any order (you do not need to specify "inventory", "owner" and "typeOrSize" together, despite the fact that they are "semi-mandatory", you only need one of them, otherwise the action will not be executed)):
inventory:<inventory_id> โ indicates by which id/name the inventory will be saved, opened or deleted, any text is supported (use only in case of "save", "open" and "delete" actions) (see more info in the hints); (SEMI-MANDATORY)
fake:<true | (default)false> โ in case of functional inventories of blocks like anvils, workbenches etc indicates whether the real functionality of the inventory will persist (fake:false) or not (fake:true) and whether the holder by default will exist (fake:false) or not (fake:true), in case of any other inventories indicates whether the content of this inventory will be used (fake:false) or not (fake:true) and whether the holder by default will exist (fake:false) or not (fake:true) (use only in case of "save" or "open" actions, can be skipped) (see more info in the hints); (SEMI-OPTIONAL)
owner:<entity_uuid | player_name | world,x,y,z> โ indicates whose inventory will be used (for example of some player), you also can use "^" before the nickname to use the open player's inventory and "|<slot (index or named slot)>" after to get inventory of the some item (for example, shulker box in inventory) (use only in case of "save", "open", "set" and "add" actions) (see more info in the hints); (SEMI-MANDATORY)
holder:<entity_uuid | player_name | world,x,y,z> โ the holder which will hold the inventory, you can not specify custom holder if "fake:false" is specified, only in case of "fake:true" or opening some saved inventory (does not matter "fake:false" or "fake:true" - it is still a copy) you can specify custom holder, in any case the holder should be an InventoryHolder (use only in case of "save" or "open" actions, can be skipped) (see more info in the hints); (SEMI-OPTIONAL)
target:<player> โ for which player the inventory will be opened or changed, in case of "set", "add" and "clear" actions you can use here the same "^" and "|<slot (index or named slot)>" as well (use only in case of "open", "set", "add" and "clear" actions) (see more info in the hints); (SEMI-MANDATORY)
typeOrSize:<inventory_type | integer_size> โ you can save or open newly created inventory, for that specify the type or the size of the inventory here, see the available types here, in case of size it should be a multiple of 9 between 9 and 54 slots, for example, 18 (use only in case of "save" and "open" actions) (see more info in the hints); (SEMI-MANDATORY)
title:<inventory_title> โ the title of the inventory, you can not specify custom title for opening if "fake:false" is specified, only in case of "fake:true" for opening, saving (does not matter "fake:false" or "fake:true" - it is a copy) or opening some saved inventory (again does not matter "fake:false" or "fake:true" - it is still a copy) you can specify custom title, you can also just use "set" or "clear" action and specify only "target" with custom title, this will set or reset title in inventory if the target is player with some opened inventory, if no title is specified, the inventory will try to be used with its basic minecraft title (use only in case of "save", "open", "set" or "clear" actions, can be skipped) (see more info in the hints). (SEMI-OPTIONAL)
The action is supposed to support any possible inventories in game, that is not just "Player1 inventory" or "this placed workbench inventory", but also any entities, for example zombies, skeletons, horses, mules, villagers etc, blocks like anvils, enchanting tables, hoppers, chests, furnaces, shulker boxes, barrels etc, inventories inside inventories like shulker boxes inside chests or players or mules and many many more! You can save these inventories, open them and change them how you want.
If you want to save inventory, you need to specify the "inventory" and either the "typeOrSize" or the "owner" (fake, title and holder options will be optional, target option will be ignored).
If you want to open inventory, you need to specify the "target" and either the "inventory" or the "typeOrSize" or the "owner" (fake, title and holder options will be optional).
If you want to change (set or add) inventory, you need to specify the "target" and either the "inventory" or the "owner" (typeOrSize, fake, title and holder options will be ignored).
If you want to clear inventory, you just need to specify the "target" (inventory, owner, typeOrSize, fake, title and holder options will be ignored).
If you want to delete inventory, you just need to specify the "inventory" (target, owner, typeOrSize, fake, title and holder options will be ignored).
If you want to change title of the opened inventory of some player, you can just specify "set" or "clear" and the "target" with "title", as result if target will be a player with some opened inventory, the title will be changed/reset (other specified options like "owner" or "inventory" will take priority and "set" will not work as title changing, but as inventory changing).
IMPORTANT ADVANCED THINGS!
You can not create the "CREATIVE" and "CRAFTING" inventory types!
Villagers (merchant) inventories can be changed only from the same source - merchant, like you can not set chest inventory to the villager inventory, only from villager to villager!
When opening a player's saved inventory, it does not matter whether fake:false or fake:true, there will be no link to the real player! Simply fake:true will add another line for armor, etc., while fake:false will not.
When opening the saved inventory of an entity, it does not matter whether fake:false or fake:true, there will be no link to the real entity! The fake:true will simply delete the contents in most cases, if there were any (in fact, there can only be one link case (for example, when opening) - only with the merchant, but the opened saved inventory will still not be linked).
When opening a saved block inventory, it does not matter if it is fake:false or fake:true, there will be no link to the real block! The fake:true will simply delete the contents in most cases, if there were any.
When fake:false, there is always a holder. For example, if a real workbench is open, the holder is the player; if it is a mule's inventory, the holder is the mule; if it is a shulker's inventory in some inventory, the holder is that shalker (if possible, and if not, then the holder is the entity/block where the shalker is located, and if that is not possible either, then the player who is looking), if it is a zombie's inventory (and it is not an InventoryHolder) - then the holder is the player who is looking, and so on (and the holder cannot be redefined here, unless it is not an open saved inventory, but simply an open inventory), when fake:true, there is never a holder, you have to set it yourself if necessary.
For open real blocks such as anvil or enchanting table (and possibly others as well), the holder is always Unknown in all respects (for example, if you check via the openInvOwner option in entity placeholders), even when you manually open the inventory in Minecraft โ it will be the same.
It is impossible to assign a custom holder for fake merchant inventory, regardless of whether it is done through owner or typeOrSize.
The fake:true will always open the same inventory but without items where they could theoretically be (except for the merchant, who will have the same offers as before, but in this case, the real villager will not be able to level up, etc., and except for the player, the player's fake inventory will be assembled from the player's current inventory and simply add armor to it, and it will not be synchronized with the real player).
In typeOrSize, some inventories such as chests or furnaces (and possibly other different types) cannot be opened as real inventories with functionality, so they always open as fake inventories with the ability to change the title, but not the holder.
If something has already been saved without content due to fake:true, then the content cannot be restored when opening by specifying fake:false. Only reverse logic is allowed: if something was saved as it actually is with fake:false, then when opening, you can remove the content, etc., by specifying fake:true. (except for the merchant โ nothing will change, and except for the player โ its logic is described above).
If the inventory has been saved, regardless of the parameters, when opening it, you can still redefine the title and holder where possible, even without specifying fake:true (the title is possible everywhere, and the holder is possible everywhere except for the merchant), because all inventories from the saved ones are still opened as copies and not as real ones.
When saving, it doesn't matter whether fake:false or fake:true is used, the custom title will still be saved, but the custom holder will only be saved with fake:true.
Changing inventories with "set" will set the target inventory slots exactly as source inventory has, in the same order etc, but only if these inventories are the same types (like player - player, chest - chest, etc), otherwise just from first slot to the last slot.
The perpetual inventories and temporary inventories are different! The same inventories names will point to different inventories.
If "?" prefix will not be specified in the action, the inventory will be stored in a file at the path plugins/TriggerReactor/inventories.json (you can change this file as well), otherwise the inventory will be stored in the server memory until it is restarted.
Targets
Entities (InventoryHolders, LivingEntities (with some equipment));
Players;
Storages (InventoryHolders).
Where is useful
For example, if you need to create the custom system of "virtual personal storages", it also can be combined in a useful way with change_item action for "expandable storages" etc. Or, for example, if you need to create some kind of inventories managing system (to see them, change and more) like /invsee command in Essentials etc. Or after all if you want to implement your own inventories backupping system to backup players inventories on different occasions and then be able to restore them. And many more.
Examples
- 'manage_inventory: action:open;target:%player%;typeOrSize:CHEST;title:ยงfMy little inventory' # Open the new inventory to the current player with type "CHEST", title "ยงfMy little inventory" and holder as the current player (because by default it is fake:false and holder always exist)- 'manage_inventory: action:save;inventory:Open inventory of %player%;owner:^%player%;title:ยงa%player% saved opened inventory' # Save the opened inventory (for example, some merchant or chest) of the current player with custom title- 'manage_inventory: action:open;owner:world,3097,65,8607|0;target:%player%' # Open the inventory of the item (for example, of the shulker box) in the block (for example, in the chest) at the specified location to the current player- 'manage_inventory: action:set;inventory:specialSavedInv;target:2b3d2f25-5747-495b-82c0-a6138e4b0a44' # Set the saved inventory to some entity- 'manage_inventory: action:set;title:Custom Title;target:%player%' # Set custom title to the opened inventory of some playerLast updated