Class RegionStorage

java.lang.Object
me.tayebyassine.homestead.storage.RegionStorage

public final class RegionStorage extends Object
High-level, region-aware facade for the storage system.
  • Method Details

    • hasStorage

      public static boolean hasStorage(Region region)
      Check whether the given region has a storage.
      Parameters:
      region - the region to check
      Returns:
      true if a storage exists for the region
    • getStorage

      public static SharedStorage getStorage(Region region)
      Get the storage for the given region, loading it from disk if necessary.
      Parameters:
      region - the region whose storage to retrieve
      Returns:
      the shared storage instance
    • getStorageSize

      public static int getStorageSize(Region region)
      Get the current storage size (slot count) for the given region.
      Parameters:
      region - the region to query
      Returns:
      the storage size, or 0 if no storage exists
    • createStorage

      public static SharedStorage createStorage(Region region, int size)
      Create a new storage for the given region.
      Parameters:
      region - the region to create storage for
      size - the inventory size (must be a valid Bukkit size)
      Returns:
      the newly created storage
    • deleteStorage

      public static void deleteStorage(Region region)
      Delete the storage for the given region.
      Parameters:
      region - the region whose storage to delete
    • upgradeStorage

      public static boolean upgradeStorage(Region region, int newSize)
      Upgrade the storage for the given region to a larger size. Existing items are copied to the new storage.
      Parameters:
      region - the region whose storage to upgrade
      newSize - the new inventory size
      Returns:
      true if the upgrade was performed, false if no upgrade was needed or no storage exists
    • canAccess

      public static boolean canAccess(Region region, org.bukkit.entity.Player player)
      Check whether the given player can access the region's storage.
      Parameters:
      region - the region
      player - the player to check
      Returns:
      true if the player is the owner, a member, or the region is public
    • openStorage

      public static void openStorage(Region region, org.bukkit.entity.Player player)
      Open the region's storage for the given player. The player must have access via canAccess(Region, Player).
      Parameters:
      region - the region whose storage to open
      player - the player to open the storage for