Package com.Moshu.TreasureHunt.Core.API
Class HuntAPI
java.lang.Object
com.Moshu.TreasureHunt.Core.API.HuntAPI
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionHunts here are guaranteed to be activeHunt IDs from here are guaranteed to be activeTreasures here are guaranteed to be activestatic Hunt
getNearestHunt
(org.bukkit.Location loc) Gets the nearest hunt at a locationstatic Treasure
getTreasure
(org.bukkit.Location loc) Gets the treasure at a locationstatic @NotNull ArrayList
<TreasureData> About TreasureData TreasureData holds all the info from the treasure file It represents only the info of the treasure, not the actual treasure itself You can get info about TreasureKey, ItemRewards, CommandRewards, TreasureDebuff and TreasureKeepers from there If you need info about the treasure itself, you can get it from the Treasure class which is instantiated by starting a Hunt.static boolean
isHuntActive
(String id) Checks if a hunt is active with a specific identifierstatic boolean
isHuntActive
(org.bukkit.Location loc) Checks if a treasure is active at a locationstatic boolean
isNearTreasure
(org.bukkit.entity.Player p) Checks if a player is near a treasurestatic boolean
isTreasure
(org.bukkit.Location loc) Checks if a location is a treasurestatic boolean
isTreasureKey
(org.bukkit.inventory.ItemStack itemStack) Checks if an item is a treasure keystatic Hunt
startTreasureHunt
(@NotNull org.bukkit.Location location, @NotNull String treasureIdentifier) Starts a treasure hunt at a specific location.static CompletableFuture
<Hunt> startTreasureHuntAtRandomLocation
(@NotNull String treasureIdentifier) Async method that starts a treasure hunt at a random location.
-
Constructor Details
-
HuntAPI
public HuntAPI()
-
-
Method Details
-
getTreasureData
About TreasureData TreasureData holds all the info from the treasure file It represents only the info of the treasure, not the actual treasure itself You can get info about TreasureKey, ItemRewards, CommandRewards, TreasureDebuff and TreasureKeepers from there If you need info about the treasure itself, you can get it from the Treasure class which is instantiated by starting a Hunt.- Returns:
- ArrayList of all the TreasureData (the data of all the treasure.yml files)
-
startTreasureHuntAtRandomLocation
@Nullable public static CompletableFuture<Hunt> startTreasureHuntAtRandomLocation(@NotNull @NotNull String treasureIdentifier) Async method that starts a treasure hunt at a random location. Needs a valid treasure identifier or it will return null.- Parameters:
treasureIdentifier
-- Returns:
- a future that completes when the hunt has started (a location has been found for the treasure).
- Throws:
TreasureAlreadyRunningException
- if a treasure with the same identifier is already running. The location where the treasure will spawn depends on your treasure.yml and config.yml settings. The location is restricted within world boundaries, and cannot spawn in regions or unsafe places.
-
startTreasureHunt
public static Hunt startTreasureHunt(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull String treasureIdentifier) Starts a treasure hunt at a specific location.- Parameters:
location
- the location where the treasure will spawn -- attention: this location still needs to be safe enough (inside world boundaries, not in regions, not on unsafe places) or the hunt will fail and won't start.treasureIdentifier
- the treasure identifier (needs a valid identifier)- Returns:
- a Hunt instance that already started
-
getActiveHunts
Hunts here are guaranteed to be active- Returns:
- a list of all the hunts active
-
getActiveHuntsIdentifiers
Hunt IDs from here are guaranteed to be active- Returns:
- a list of all the hunts' identifiers active
-
getActiveTreasures
Treasures here are guaranteed to be active- Returns:
- a list of all the treasures active
-
isHuntActive
public static boolean isHuntActive(org.bukkit.Location loc) Checks if a treasure is active at a location- Parameters:
loc
- the location to check- Returns:
- true if a treasure is active at the location, false otherwise
-
getNearestHunt
Gets the nearest hunt at a location- Parameters:
loc
- the location to check- Returns:
- the nearest hunt at the location, null if no hunt is active at the location
-
isTreasure
public static boolean isTreasure(org.bukkit.Location loc) Checks if a location is a treasure- Parameters:
loc
- the location to check- Returns:
- true if the location is a treasure, false otherwise
-
getTreasure
Gets the treasure at a location- Parameters:
loc
- the location to check- Returns:
- the treasure at the location, null if no treasure is at the location
-
isNearTreasure
public static boolean isNearTreasure(org.bukkit.entity.Player p) Checks if a player is near a treasure- Parameters:
p
- the player to check- Returns:
- true if the player is near a treasure, false otherwise
-
isTreasureKey
public static boolean isTreasureKey(org.bukkit.inventory.ItemStack itemStack) Checks if an item is a treasure key- Parameters:
itemStack
- the item to check- Returns:
- true if the item is a treasure key, false otherwise
-
isHuntActive
Checks if a hunt is active with a specific identifier- Parameters:
id
- the identifier to check- Returns:
- true if the hunt is active with the identifier, false otherwise
-