1
0
mirror of https://github.com/BentoBoxWorld/Warps.git synced 2024-11-28 21:55:14 +01:00

Restore Correct Requests

BONNe 2019-08-25 16:13:13 +03:00
parent 703c1682b7
commit 6b8edec0da

@ -6,135 +6,119 @@ This is especially useful for plugins, whose access to addon's classes is restri
## Available Addon Requests ## Available Addon Requests
### Get Challenge List: `challenge-list` ### Get Sorted Warps: `getSortedWarps`
```java ```java
/** /**
* Returns a list of challenges that are active in the given world. * Since v1.6.2
* Returns a sorted list of warps with most recent players listed first.
* @param worldName Name of the world (Overworld) the island is in, not null. * @param worldName Name of the world (Overworld) the island is in, not null.
* @return a List containing the strings that represents unique challenge id's in the given world, * @return a List containing the UUIDs of the island owners whose island has a warp sign,
* or an empty list if the specified world doesn't exist or doesn't contain any challenge. * or an empty list if the specified world doesn't exist or doesn't contain warps.
*/ */
public List<String> getChallenges(String worldName) { public List<UUID> getSortedWarps(String worldName) {
return (List<String>) new AddonRequestBuilder() return (List<UUID>) new AddonRequestBuilder()
.addon("Challenges") .addon("WelcomeWarps")
.label("challenge-list") .label("getSortedWarps")
.addMetaData("world-name", worldName) .addMetaData("world", worldName)
.request(); .request();
} }
``` ```
Possible values returned: Possible values returned:
* an empty List if the specified world doesn't exist or doesn't contain any challenge; * an empty List if the specified world doesn't exist or doesn't contain warps;
* a List containing the strings that represents unique challenge id's. * a List containing the UUIDs of the island owners whose island has a warp sign ordered by most recent added.
### Get Challenge Data: `challenge-data` ### Get Player Warp Location: `getWarp`
```java ```java
/** /**
* Returns the challenge data for given challenge id. * Since v1.6.2
* @param challengeId String ID of the challenge, not null. * Returns the location of the warp for player or null if one is not found
* @return a Map that contains some internal challenge object data, * @param playerUUID UUID of the player, not null.
* or empty map if challenge is not defined.
*/
public Map<String, Object> getChallengeDataMap(String challengeId) {
return (Map<String, Object>) new AddonRequestBuilder()
.addon("Challenges")
.label("challenge-data")
.addMetaData("challenge-name", challengeId)
.request();
}
```
Possible values returned:
* a empty Map if challenge with the given id is not found;
* a map that contains some internal challenges object data:
* `uniqueId`: the same id that was passed to this handler. (`Entry<String, String>`)
* `name`: String object of display name for a challenge. (`Entry<String, String>`)
* `icon`: ItemStack object that represents a challenge. (`Entry<String, ItemStack>`)
* `levelId`: String object of levelId that this challenge is linked. (`Entry<String, String>`)
* `order`: Integer object of order number for a given challenge. (`Entry<String, Integer>`)
* `deployed`: a boolean object of deployment status. (`Entry<String, Boolean>`)
* `description`: List of strings that represents challenges description. (`Entry<String, List<String>>`)
* `type`: String object that represents challenges type. (`Entry<String, String>`)
* `repeatable`: a boolean object of a repeatable option. (`Entry<String, Boolean>`)
* `maxTimes`: Integer object that represents how many times challenge can be completed. (`Entry<String, Integer>`)
### Get Challenge Level List: `level-list`
```java
/**
* Returns a list of challenge levels that are active in the given world.
* @param worldName Name of the world (Overworld) the island is in, not null. * @param worldName Name of the world (Overworld) the island is in, not null.
* @return a List containing the strings that represents unique challenge level id's in the given world, * @return a Location that represents warp sign location,
* or an empty list if the specified world doesn't exist or doesn't contain any challenge level. * or null if one is not found.
*/ */
public List<String> getChallengeLevels(String worldName) { public Location getWarp(UUID playerUUID, String worldName) {
return (List<String>) new AddonRequestBuilder() return (Location) new AddonRequestBuilder()
.addon("Challenges") .addon("WelcomeWarps")
.label("level-list") .label("getWarp")
.addMetaData("world-name", worldName) .addMetaData("world", worldName)
.addMetaData("uuid", playerUUID)
.request(); .request();
} }
``` ```
Possible values returned: Possible values returned:
* an empty List if the specified world doesn't exist or doesn't contain any challenge level; * null if player does not has warp in given world;
* a List containing the strings that represents unique challenge level id's. * a Location of the warp sign.
### Get Challenge Level Data: `level-data` ### Get all warp in World: `getWarpMap`
```java ```java
/** /**
* Returns the challenge level data for given challenge level id. * Returns the players whose island has a warp sign in given world mapped to the warp sign location.
* @param levelId String ID of the challenge level, not null.
* @return a Map that contains some internal challenge level object data,
* or empty map if challenge level is not defined.
*/
public Map<String, Object> getChallengeLevelData(String levelId) {
return (Map<String, Object>) new AddonRequestBuilder()
.addon("Challenges")
.label("level-data")
.addMetaData("level-name", levelId)
.request();
}
```
Possible values returned:
* a empty Map if a challenge level with the given id is not found;
* a map that contains some internal challenge level object data:
* `uniqueId`: the same id that was passed to this handler. (`Entry<String, String>`)
* `name`: String object of display name for a challenge level. (`Entry<String, String>`)
* `icon`: ItemStack object that represents a challenge level. (`Entry<String, ItemStack>`)
* `world`: String object that represents world name where level operates. (`Entry<String, String>`)
* `order`: Integer object of order number for a given challenge level. (`Entry<String, Integer>`)
* `message`: String object that represents level unlock message. (`Entry<String, String>`)
* `waiveramount`: Integer object of waiver amount for a given challenge level. (`Entry<String, Integer>`)
* `challenges`: List of strings that represents challenges that are owned by the given level. (`Entry<String, List<String>>`)
### Get Completed Challenges: `completed-challenges`
```java
/**
* Returns a list of challenge's id which given player is completed in the given world.
* @param playerUUID Player UUID who's data must be returned, not null.
* @param worldName Name of the world (Overworld) the island is in, not null. * @param worldName Name of the world (Overworld) the island is in, not null.
* @return a Set containing the strings that represents unique challenge id's in the given world that are completed, * @return a Map containing the UUIDs of the island owners whose island has a warp sign, mapped to the warp sign location,
* or an empty set if the specified world doesn't exist or player hasn't completed any challenge. * or an empty map if the specified world doesn't exist or doesn't contain warp sign.
*/ */
public Set<String> getCompletedChallenges(UUID playerUUID, String worldName) { public Map<UUID, Location> getWarpMap(String worldName) {
return (Set<String>) new AddonRequestBuilder() return (Map<UUID, Location>) new AddonRequestBuilder()
.addon("Challenges") .addon("WelcomeWarps")
.label("completed-challenges") .label("getWarpMap")
.addMetaData("player", playerUUID) .addMetaData("world", worldName)
.addMetaData("world-name", worldName)
.request(); .request();
} }
``` ```
Possible values returned: Possible values returned:
* an empty Set if the specified world doesn't exist or player hasn't completed any challenge.; * an empty Map if the specified world doesn't exist or doesn't contain warp signs;
* a Set containing the strings that represents unique challenge id's that are completed by given player in the given world. * a Map containing the UUIDs of the island owners whose island has a warp sign, mapped to the warp sign location.
### Check if player has a warp sign: `hasWarp`
```java
/**
* Since v1.6.2
* Returns if given player in given world has a warp sign.
* @param playerUUID UUID of the player, not null.
* @param worldName Name of the world (Overworld) the island is in, not null.
* @return {@code true} if player has a warp sign in given world,
* otherwise {@code false}.
*/
public boolean hasWarp(UUID playerUUID, String worldName) {
return (boolean) new AddonRequestBuilder()
.addon("WelcomeWarps")
.label("hasWarp")
.addMetaData("world", worldName)
.addMetaData("uuid", playerUUID)
.request();
}
```
Possible values returned:
* false if player does not has warp in given world;
* true if player has a warp sign in given world.
### Get Set of all Warps: `listWarps`
```java
/**
* Since v1.6.2
* Returns a Set that contains all known warps in given world
* @param worldName Name of the world (Overworld) the island is in, not null.
* @return a Set containing the UUIDs of the island owners whose island has a warp sign,
* or an empty Set if the specified world doesn't exist or doesn't contain warps.
*/
public Set<UUID> listWarps(String worldName) {
return (Set<UUID>) new AddonRequestBuilder()
.addon("WelcomeWarps")
.label("listWarps")
.addMetaData("world", worldName)
.request();
}
```
Possible values returned:
* an empty Set if the specified world doesn't exist or doesn't contain warps;
* a Set containing the UUIDs of the island owners whose island has a warp sign.