Skip to content
nicegamer7 edited this page Aug 14, 2019 · 3 revisions

This document outlines the basics of how plugin developers can use multiverse-inventories to both add custom shares to be used by their plugins, as well as how to use multiverse-inventories to check for a default or a share setup by another plugin.

I want to add my own custom shareable config entry.

  1. Create a class for the static sharable definitions to go

     public class MySharables {
         
     }
    
  2. Decide what data the sharable will store.

    If my plugin was an economy plugin i would use the Double type so that I could store the amount for each player

    If I have a plugin that gives backpacks, I would use an array of ItemStack as the type because thats what is stored.

    If I had something like a custom set of data per player, I could also write a custom class and use that.

  3. Create a Sharable definition in your class. In this case I will use an ItemStack array, as its it will be for a custom inventory.

     public class MySharables {
         
         public static final Sharable<ItemStack[]> MySharable = new Sharable.Builder<ItemStack[]>("mySharable", ItemStack[].class, new SharableHandler<ItemStack[]>() {
                 @Override
                 public void updateProfile(PlayerProfile profile, Player player) {
                     profile.set(MySharable, player.getInventory().getContents());
                 }
                 
                 @Override
                 public boolean updatePlayer(Player player, PlayerProfile profile) {
                     ItemStack[] value = profile.get(MySharable);
                     if ( value == null ) {
                         return false;
                     }
                     player.getInventory().setContents(value);
                     player.updateInventory();
                     return true;
                           
                 }
         }).stringSerializer(new ProfileEntry(false, "mySharable")).altName("ms").build();
     }
    

The final ProfileEntry string defines the name in the config file itself, not just internally. The altName(String) function allows you to specify other values in the config file that would equate to the same internal name for the share.

I want to get all the groups for a world

Unfinished Wiki, Saving for tomorrow

I want to check a default or my own shareables presence

Unfinished Wiki, Saving for tomorrow