diff --git a/api/pom.xml b/api/pom.xml index 046db07b..061c5252 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -5,7 +5,7 @@ luckperms me.lucko.luckperms - 2.14-SNAPSHOT + 2.15-SNAPSHOT 4.0.0 diff --git a/api/src/main/java/me/lucko/luckperms/api/Contexts.java b/api/src/main/java/me/lucko/luckperms/api/Contexts.java index 8272b33a..a38723c0 100644 --- a/api/src/main/java/me/lucko/luckperms/api/Contexts.java +++ b/api/src/main/java/me/lucko/luckperms/api/Contexts.java @@ -32,6 +32,7 @@ import java.util.Map; * @since 2.11 */ public class Contexts { + private static final Contexts ALLOW_ALL = new Contexts(ContextSet.empty(), true, true, true, true, true, true); public static final String SERVER_KEY = "server"; public static final String WORLD_KEY = "world"; @@ -40,7 +41,7 @@ public class Contexts { * @return a context that will not apply any filters */ public static Contexts allowAll() { - return new Contexts(ContextSet.empty(), true, true, true, true, true, true); + return ALLOW_ALL; } public static Contexts of(ContextSet context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) { diff --git a/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java b/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java index 521dc12a..068a60c7 100644 --- a/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java +++ b/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java @@ -250,4 +250,12 @@ public interface LuckPermsApi { */ void registerContextListener(ContextListener contextListener); + /** + * Gets a calculated context instance for the user using the rules of the platform. + * These values are calculated using the options in the configuration, and the provided calculators. + * @param user the user to get contexts for + * @return an optional containing contexts. Will return empty if the user is not online. + */ + Optional getContextForUser(User user); + } diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java b/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java index 8e84bf80..17864c65 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java @@ -37,6 +37,7 @@ import java.util.stream.Collectors; * @since 2.13 */ public class ContextSet { + private static final ContextSet EMPTY = new ContextSet(); /** * Make a singleton ContextSet from a context pair @@ -112,7 +113,7 @@ public class ContextSet { * @return a new ContextSet */ public static ContextSet empty() { - return new ContextSet(); + return EMPTY; } final Set> contexts; diff --git a/bukkit-legacy/pom.xml b/bukkit-legacy/pom.xml index a34b02d2..de8702c3 100644 --- a/bukkit-legacy/pom.xml +++ b/bukkit-legacy/pom.xml @@ -5,7 +5,7 @@ luckperms me.lucko.luckperms - 2.14-SNAPSHOT + 2.15-SNAPSHOT 4.0.0 diff --git a/bukkit-placeholders/pom.xml b/bukkit-placeholders/pom.xml index ebc5d5a0..53728b09 100644 --- a/bukkit-placeholders/pom.xml +++ b/bukkit-placeholders/pom.xml @@ -5,7 +5,7 @@ luckperms me.lucko.luckperms - 2.14-SNAPSHOT + 2.15-SNAPSHOT 4.0.0 @@ -30,7 +30,7 @@ me.lucko.luckperms luckperms-api - 2.14-SNAPSHOT + ${project.version} provided diff --git a/bukkit/pom.xml b/bukkit/pom.xml index e18b8ace..1e616e18 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ luckperms me.lucko.luckperms - 2.14-SNAPSHOT + 2.15-SNAPSHOT 4.0.0 diff --git a/bungee/pom.xml b/bungee/pom.xml index e042f5c7..476a54a6 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ luckperms me.lucko.luckperms - 2.14-SNAPSHOT + 2.15-SNAPSHOT 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index e3cfdcd5..ca9baa2b 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ luckperms me.lucko.luckperms - 2.14-SNAPSHOT + 2.15-SNAPSHOT 4.0.0 diff --git a/common/src/main/java/me/lucko/luckperms/common/api/ApiProvider.java b/common/src/main/java/me/lucko/luckperms/common/api/ApiProvider.java index f5499adc..75ef11b5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/ApiProvider.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/ApiProvider.java @@ -71,7 +71,7 @@ public class ApiProvider implements LuckPermsApi { @Override public double getApiVersion() { - return 2.14; + return 2.15; } @Override @@ -159,7 +159,7 @@ public class ApiProvider implements LuckPermsApi { @Override public void cleanupUser(@NonNull User user) { - me.lucko.luckperms.common.api.internal.Utils.checkUser(user); + Utils.checkUser(user); plugin.getUserManager().cleanup(((UserLink) user).getMaster()); } @@ -221,4 +221,10 @@ public class ApiProvider implements LuckPermsApi { public void registerContextListener(ContextListener contextListener) { plugin.getContextManager().registerListener(contextListener); } + + @Override + public Optional getContextForUser(User user) { + Utils.checkUser(user); + return Optional.ofNullable(plugin.getContextForUser(((UserLink) user).getMaster())); + } } diff --git a/pom.xml b/pom.xml index 3eecac1e..dfc971cc 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.lucko.luckperms luckperms - 2.14-SNAPSHOT + 2.15-SNAPSHOT common api @@ -38,7 +38,7 @@ UTF-8 - 2.14 + 2.15 diff --git a/sponge/pom.xml b/sponge/pom.xml index da0ac680..d0de596c 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -5,7 +5,7 @@ luckperms me.lucko.luckperms - 2.14-SNAPSHOT + 2.15-SNAPSHOT 4.0.0