Adds an API to request data from the WarpSignsManager class
https://github.com/BentoBoxWorld/Warps/issues/39
This commit is contained in:
parent
57bed61167
commit
633f2a63e2
2
pom.xml
2
pom.xml
|
@ -66,7 +66,7 @@
|
|||
<!-- Do not change unless you want different name for local builds. -->
|
||||
<build.number>-LOCAL</build.number>
|
||||
<!-- This allows to change between versions. -->
|
||||
<build.version>1.6.1</build.version>
|
||||
<build.version>1.6.2</build.version>
|
||||
</properties>
|
||||
|
||||
<!-- Profiles will allow to automatically change build version. -->
|
||||
|
|
|
@ -2,9 +2,11 @@ package world.bentobox.warps;
|
|||
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
|
@ -192,4 +194,47 @@ public class Warp extends Addon {
|
|||
return this.getPlugin().getAddonsManager().getAddonByName(LEVEL_ADDON_NAME).map(l -> ((Level) l).getIslandLevel(world, uniqueId)).orElse(null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see world.bentobox.bentobox.api.addons.Addon#request(java.lang.String, java.util.Map)
|
||||
*
|
||||
* This API enables plugins to request data from the WarpSignsManager
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Object request(String requestLabel, Map<String, Object> metaData) {
|
||||
if (metaData.isEmpty()) return null;
|
||||
World world = null;
|
||||
UUID uuid = null;
|
||||
// Parse keys
|
||||
if (metaData.containsKey("world")) {
|
||||
world = Bukkit.getWorld((String)metaData.get("world"));
|
||||
if (world == null) return null;
|
||||
}
|
||||
if (metaData.containsKey("uuid")) {
|
||||
try {
|
||||
uuid = UUID.fromString((String)metaData.get("uuid"));
|
||||
} catch (Exception e) {
|
||||
logError("Requested UUID is invalid");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
switch(requestLabel) {
|
||||
case "getSignInfo":
|
||||
return getWarpSignsManager().getSignInfo(world, uuid);
|
||||
case "getSortedWarps":
|
||||
return getWarpSignsManager().getSortedWarps(world);
|
||||
case "getWarp":
|
||||
return getWarpSignsManager().getWarp(world, uuid);
|
||||
case "getWarpMap":
|
||||
return getWarpSignsManager().getWarpMap(world);
|
||||
case "hasWarp":
|
||||
return getWarpSignsManager().hasWarp(world, uuid);
|
||||
case "listWarps":
|
||||
return getWarpSignsManager().listWarps(world);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue