Move stuff into commons, rename PermissionObject, add more javadocs to api

This commit is contained in:
Luck
2016-08-06 00:11:00 +02:00
Unverified
parent 03450c3339
commit caf03379f2
38 changed files with 516 additions and 388 deletions
@@ -4,14 +4,22 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import me.lucko.luckperms.api.LuckPermsApi;
import java.util.Optional;
/**
* Static access to LuckPerms
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class LuckPerms {
public final class LuckPerms {
private static LuckPermsApi api = null;
/**
* Gets an instance of {@link LuckPermsApi}
* @return an api instance
* @throws IllegalStateException if the api is not loaded
*/
public static LuckPermsApi getApi() {
if (api == null) {
throw new IllegalStateException("API is not loaded.");
@@ -19,6 +27,15 @@ public class LuckPerms {
return api;
}
/**
* Gets an instance of {@link LuckPermsApi} safely. Unlike {@link LuckPerms#getApi}, this method will not throw an
* {@link IllegalStateException} if the api is not loaded, rather return an empty {@link Optional}.
* @return an optional api instance
*/
public static Optional<LuckPermsApi> getApiSafe() {
return Optional.ofNullable(api);
}
static void registerProvider(LuckPermsApi luckPermsApi) {
api = luckPermsApi;
}