1
0
mirror of https://github.com/BentoBoxWorld/Warps.git synced 2024-11-21 18:15:17 +01:00
6 Addon Request
xCodiq edited this page 2019-10-21 14:48:00 +02:00

Introduction

Addon Requests allow plugins and addons to access to internal addon data without necessarily injecting or overwriting the said addon.

This is especially useful for plugins, whose access to addon's classes is restricted by Java's ClassLoader visibility principle (which can be summed up as the following: child ClassLoader can see all the classes loaded by the parent ClassLoader, but the parent ClassLoader cannot see the classes loaded by the child ClassLoader).

Available Addon Requests

Get Sorted Warps: getSortedWarps

/**
 * 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.
 * @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 warps.
 */
public List<UUID> getSortedWarps(String worldName) {
    return (List<UUID>) new AddonRequestBuilder()
        .addon("Warps")
        .label("getSortedWarps")
        .addMetaData("world", worldName)
        .request();
}

Possible values returned:

  • an empty List if the specified world doesn't exist or doesn't contain warps;
  • a List containing the UUIDs of the island owners whose island has a warp sign ordered by most recent added.

Get Player Warp Location: getWarp

/**
 * Since v1.6.2
 * Returns the location of the warp for player or null if one is not found
 * @param playerUUID UUID of the player, not null.
 * @param worldName Name of the world (Overworld) the island is in, not null.
 * @return a Location that represents warp sign location,
 *         or null if one is not found.
 */
public Location getWarp(String playerUUID, String worldName) {
    return (Location) new AddonRequestBuilder()
        .addon("Warps")
        .label("getWarp")
        .addMetaData("world", worldName)
        .addMetaData("uuid", playerUUID)
        .request();
}

Possible values returned:

  • null if player does not has warp in given world;
  • a Location of the warp sign.

Get all warp in World: getWarpMap

/**
 * Returns the players whose island has a warp sign in given world mapped to the warp sign location.
 * @param worldName Name of the world (Overworld) the island is in, not null.
 * @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 map if the specified world doesn't exist or doesn't contain warp sign.
 */
public Map<UUID, Location> getWarpMap(String worldName) {
    return (Map<UUID, Location>) new AddonRequestBuilder()
        .addon("Warps")
        .label("getWarpMap")
        .addMetaData("world", worldName)
        .request();
}

Possible values returned:

  • an empty Map if the specified world doesn't exist or doesn't contain warp signs;
  • 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

/**
 * 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(String playerUUID, String worldName) {
    return (boolean) new AddonRequestBuilder()
        .addon("Warps")
        .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

/**
 * 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("Warps")
        .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.