From e07b67763236905ced629ddd3c760e8c5f24703a Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 6 Aug 2016 19:47:39 +0200 Subject: [PATCH] Update readme --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e5f04a7b..5ad5ee6da 100644 --- a/README.md +++ b/README.md @@ -61,11 +61,20 @@ The only way around this is to decrease the sync interval. LuckPerms has an extensive API, allowing for easy integration with other projects. To use the Api, you need to obtain an instance of the `LuckPermsApi` interface. This can be done in a number of ways. ```java -// On all platforms +// On all platforms (throws IllegalStateException if the API is not loaded) final LuckPermsApi api = LuckPerms.getApi(); +// Or with Optional +Optional provider = LuckPerms.getApiSafe(); +if (provider.isPresent()) { + final LuckPermsApi api = provider.get(); +} + // On Bukkit/Spigot -final LuckPermsApi api = Bukkit.getServicesManager().getRegistration(LuckPermsApi.class).getProvider(); +ServicesManager manager = Bukkit.getServicesManager(); +if (manager.isProvidedFor(LuckPermsApi.class)) { + final LuckPermsApi api = manager.getRegistration(LuckPermsApi.class).getProvider(); +} // On Sponge Optional provider = Sponge.getServiceManager().provide(LuckPermsApi.class);