Package com.yottabyte.crates.api.crate
Interface CrateManager
-
public interface CrateManager
The manager for all crate related operations.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addKeys(org.bukkit.command.CommandSender sender, org.bukkit.OfflinePlayer target, String crateId, long amount, String keyType)
void
disableCrates(String initiator)
Prevent all crates from being opened.void
enableCrates(String initiator)
Allow all crates to be opened.Optional<Crate>
getCrateById(String id)
Get aCrate
by its identifier.Optional<Crate>
getCrateByKey(org.bukkit.inventory.ItemStack itemStack)
Get aCrate
from anyItemStack
List<String>
getCrateIds()
Get all registered crate IDs.CrateLocation
getCrateLocation(org.bukkit.block.Block block)
Get theCrateLocation
from aBlock
.Set<Crate>
getCrates()
Get all registeredCrate
s.boolean
isKey(org.bukkit.inventory.ItemStack itemStack)
Check if anItemStack
is a crate keyboolean
isOpeningCrate(org.bukkit.entity.Player player)
Check if a player is currently opening a crate.void
keyAll(org.bukkit.command.CommandSender sender, String crateId, long amount, String keyType)
void
openCratePhysically(org.bukkit.entity.Player player, Crate crate, org.bukkit.block.Block block, org.bukkit.inventory.EquipmentSlot hand)
Open aCrate
with a physical key.void
openCrateVirtually(org.bukkit.entity.Player player, Crate crate, int amount, org.bukkit.block.Block block)
Open aCrate
with a virtual key.void
reload()
Reload everything related to crates.void
removeCrateBlock(org.bukkit.entity.Player sender, org.bukkit.block.Block block)
void
removeKeys(org.bukkit.command.CommandSender sender, org.bukkit.OfflinePlayer target, String crateId, long amount)
void
setCrateBlock(org.bukkit.entity.Player sender, org.bukkit.block.Block block, String crateId)
void
setKeys(org.bukkit.command.CommandSender sender, org.bukkit.OfflinePlayer target, String crateId, long amount)
void
showKeys(org.bukkit.command.CommandSender sender, org.bukkit.OfflinePlayer target)
void
showKeys(org.bukkit.command.CommandSender sender, org.bukkit.OfflinePlayer target, String crateId)
void
viewCratePreviewMenu(org.bukkit.entity.Player player, Crate crate)
Open the rewards preview menu for aCrate
.void
viewVirtualCratesMenu(org.bukkit.entity.Player player)
Open the virtual crates menu.
-
-
-
Method Detail
-
reload
void reload()
Reload everything related to crates.
-
getCrateIds
List<String> getCrateIds()
Get all registered crate IDs.- Returns:
- an immutable
List
of crate identifiers
-
disableCrates
void disableCrates(String initiator)
Prevent all crates from being opened.- Parameters:
initiator
- the name of initiator of the action
-
enableCrates
void enableCrates(String initiator)
Allow all crates to be opened.- Parameters:
initiator
- the name of initiator of the action
-
showKeys
void showKeys(org.bukkit.command.CommandSender sender, org.bukkit.OfflinePlayer target, String crateId)
-
showKeys
void showKeys(org.bukkit.command.CommandSender sender, org.bukkit.OfflinePlayer target)
-
keyAll
void keyAll(org.bukkit.command.CommandSender sender, String crateId, long amount, String keyType)
-
addKeys
void addKeys(org.bukkit.command.CommandSender sender, org.bukkit.OfflinePlayer target, String crateId, long amount, String keyType)
-
removeKeys
void removeKeys(org.bukkit.command.CommandSender sender, org.bukkit.OfflinePlayer target, String crateId, long amount)
-
setKeys
void setKeys(org.bukkit.command.CommandSender sender, org.bukkit.OfflinePlayer target, String crateId, long amount)
-
isKey
boolean isKey(org.bukkit.inventory.ItemStack itemStack)
Check if anItemStack
is a crate key- Parameters:
itemStack
- theItemStack
to test- Returns:
- true if a crate, otherwise false
-
getCrateByKey
Optional<Crate> getCrateByKey(org.bukkit.inventory.ItemStack itemStack)
Get aCrate
from anyItemStack
-
setCrateBlock
void setCrateBlock(org.bukkit.entity.Player sender, org.bukkit.block.Block block, String crateId)
-
removeCrateBlock
void removeCrateBlock(org.bukkit.entity.Player sender, org.bukkit.block.Block block)
-
getCrateLocation
CrateLocation getCrateLocation(org.bukkit.block.Block block)
Get theCrateLocation
from aBlock
.- Parameters:
block
- theBlock
used to find theCrateLocation
- Returns:
- the
CrateLocation
found or null if the block is not aCrateLocation
-
viewCratePreviewMenu
void viewCratePreviewMenu(org.bukkit.entity.Player player, Crate crate)
Open the rewards preview menu for aCrate
.- Parameters:
player
- thePlayer
to open the menu forcrate
- theCrate
to preview rewards for
-
viewVirtualCratesMenu
void viewVirtualCratesMenu(org.bukkit.entity.Player player)
Open the virtual crates menu.- Parameters:
player
- thePlayer
to open the menu for
-
openCratePhysically
void openCratePhysically(org.bukkit.entity.Player player, Crate crate, org.bukkit.block.Block block, org.bukkit.inventory.EquipmentSlot hand)
Open aCrate
with a physical key.Disclaimer: This method consumes the item in
EquipmentSlot
as a key with no checks.- Parameters:
player
- thePlayer
opening the cratecrate
- theCrate
to openblock
- theBlock
of the cratehand
- theEquipmentSlot
the key is in
-
openCrateVirtually
void openCrateVirtually(org.bukkit.entity.Player player, Crate crate, int amount, org.bukkit.block.Block block)
Open aCrate
with a virtual key.- Parameters:
player
- thePlayer
opening the cratecrate
- theCrate
to openamount
- the amount of keys to consumeblock
- theBlock
of the crate, is null when opened via command or GUI
-
isOpeningCrate
boolean isOpeningCrate(org.bukkit.entity.Player player)
Check if a player is currently opening a crate.- Parameters:
player
- thePlayer
to check- Returns:
- true if the player is currently opening a crate, otherwise false
-
-