Class RegionStorage
java.lang.Object
me.tayebyassine.homestead.storage.RegionStorage
High-level, region-aware facade for the storage system.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanCheck whether the given player can access the region's storage.static SharedStoragecreateStorage(Region region, int size) Create a new storage for the given region.static voiddeleteStorage(Region region) Delete the storage for the given region.static SharedStoragegetStorage(Region region) Get the storage for the given region, loading it from disk if necessary.static intgetStorageSize(Region region) Get the current storage size (slot count) for the given region.static booleanhasStorage(Region region) Check whether the given region has a storage.static voidopenStorage(Region region, org.bukkit.entity.Player player) Open the region's storage for the given player.static booleanupgradeStorage(Region region, int newSize) Upgrade the storage for the given region to a larger size.
-
Method Details
-
hasStorage
Check whether the given region has a storage.- Parameters:
region- the region to check- Returns:
trueif a storage exists for the region
-
getStorage
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
Get the current storage size (slot count) for the given region.- Parameters:
region- the region to query- Returns:
- the storage size, or
0if no storage exists
-
createStorage
Create a new storage for the given region.- Parameters:
region- the region to create storage forsize- the inventory size (must be a valid Bukkit size)- Returns:
- the newly created storage
-
deleteStorage
Delete the storage for the given region.- Parameters:
region- the region whose storage to delete
-
upgradeStorage
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 upgradenewSize- the new inventory size- Returns:
trueif the upgrade was performed,falseif no upgrade was needed or no storage exists
-
canAccess
Check whether the given player can access the region's storage.- Parameters:
region- the regionplayer- the player to check- Returns:
trueif the player is the owner, a member, or the region is public
-
openStorage
Open the region's storage for the given player. The player must have access viacanAccess(Region, Player).- Parameters:
region- the region whose storage to openplayer- the player to open the storage for
-