Question How to store data globally?

Hanprogramer

New member
Jun 23, 2023
1
0
1
I need to store some specific custom items. Items created using commands by admins, they contain some items inside. Imagine custom lootbags.

How would I go about storing it in commands?
Like
/lootbag give <Name>
/lootbag register <Name>

How I created the lootbag is /lootbag create. Store the items inside of it by reading the first 9 slots in the player's inventory. Then give the lootbag item. It's usable already. But it's terrible to recreate everytime needed
 

Machine Maker

Paper Developer
Staff member
Dec 17, 2021
132
6
19
18
California
Is this a Plugin Development question? If so, I'll move it to the right forum.

If you want to have "names" for a collection of items that is persisted across a server restart, you will need some sort of extra storage, whether that is a database you want to create and query/update or just plain text file that stores itemstacks serialized as bytes. Then store a "name" for the collection of items that can be set when you run /lootbag create <Name>. Then you can use the name elsewhere to get an exact copy of it.