Skip to content

Custom Inventory System

The Core/API plugin will assign a list of ItemStacks to each player, binded to Redis + saved to SQL on shutdown & every time updateInventory(); is called (Should be ran every time a trade is done etc) + every 5 minutes automatically. This list of itemstacks is the players "inventory". The vanilla inventory is ignored, and should never be saved anywhere.

Every server will have a class automatically setting the players vanilla inventory. This allows the server to for example:

  • Set certain items in their inventory to random GUI items like Cosmetic buttons, Minigame buttons, etc
  • Add GUI pages, where if for example theres 30 items in the item stack, but only 9 are shown in the vanilla inventory, there can be a "next page" button to load the next 9, etc
  • Be able to effectively "clear" the inventory (eg for Minigames where items should not be kept by the player), by just clearing the vanilla inventory, then loading the actual inventory back as soon as they switch servers, whereas if the vanilla inventory system was used, this would require saving their inventory somewhere, clearing their inventory, then returning back to the saved one later, which risks that other saved inventory being lost, data inconsistencies, etc
  • Be able to sync inventories between servers easily

Overall, this is a fairly simple way to just make sure inventories are saved in a way thats better for a Network Socialverse server, rather than the vanilla system which is made for non-network survival/creative servers.

Vanilla Inventory

The vanilla inventory is not the same on every server. Each server manages the inventory in its own way, but an example can be:

  • 9th Hotbar Slot: "Home" button
  • Sides of non-hotbar inventory: Buttons for various tasks
  • Next & Previous page buttons at top of inventory
  • Fills all remaining free slots with custom inventory items. If there are any left that arent shown, next/previous page buttons scrolls.

Some servers might not even show the custom inventory items, such as minigames. Since they are never "deleted" and are always still there, they will still come back when switching back to another server.

Armor & Vanity Slots

The custom inventory system contains two ItemStack lists for armor slots. One for "armor" and one for "vanity", for 8 armor slots total. There will be a button in most servers vanilla inventories to switch between which of the two to show in the armor slots.

If you are wearing an armor piece in the same slot of both inventories, eg wearing a Back Cosmetic in your vanity chestplate, and a chestplate in your armor chestplate, the stats of the Armor one will always be used, but the item in the Vanity one will always be displayed. This allows you to wear armor for stats, but wear cosmetics "on top of the armor".