Adds method to obtain island via island unique id.

This commit is contained in:
tastybento 2019-02-08 21:56:14 -08:00
parent af96055753
commit f64968c7c7

View File

@ -702,10 +702,10 @@ public class IslandsManager {
// Only load non-quarantined island
// TODO: write a purge admin command to delete these records
handler.loadObjects().stream().filter(i -> !i.isDoNotLoad()).forEach(island -> {
if (!islandCache.addIsland(island)) {
// Quarantine the offending island
toQuarantine.add(island);
}
if (!islandCache.addIsland(island)) {
// Quarantine the offending island
toQuarantine.add(island);
}
});
if (!toQuarantine.isEmpty()) {
plugin.logError(toQuarantine.size() + " islands could not be loaded successfully; quarantining.");
@ -931,4 +931,14 @@ public class IslandsManager {
handler.saveObject(island);
}
/**
* Get island by unique id
* @param uniqueId - unique id
* @return optional island
* @since 1.3.0
*/
public Optional<Island> getIsland(String uniqueId) {
return handler.objectExists(uniqueId) ? Optional.ofNullable(handler.loadObject(uniqueId)) : Optional.empty();
}
}