diff --git a/api/pom.xml b/api/pom.xml
index 9d076b2dc..333282a97 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -5,7 +5,7 @@
luckpermsme.lucko.luckperms
- 2.17-SNAPSHOT
+ 3.0-SNAPSHOT4.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 5fffa0a03..24cc6350d 100644
--- a/api/src/main/java/me/lucko/luckperms/api/Contexts.java
+++ b/api/src/main/java/me/lucko/luckperms/api/Contexts.java
@@ -24,8 +24,6 @@ package me.lucko.luckperms.api;
import me.lucko.luckperms.api.context.ContextSet;
-import java.util.Map;
-
/**
* Context and options for a permission lookup.
*
@@ -51,18 +49,6 @@ public class Contexts {
return new Contexts(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, op);
}
- @SuppressWarnings("deprecation")
- @Deprecated
- public static Contexts of(Map context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups) {
- return new Contexts(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups);
- }
-
- @SuppressWarnings("deprecation")
- @Deprecated
- public static Contexts of(Map context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
- return new Contexts(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, op);
- }
-
/**
* The contexts that apply for this lookup
* The keys for servers and worlds are defined as static values.
@@ -115,17 +101,6 @@ public class Contexts {
this.op = op;
}
- @Deprecated
- public Contexts(Map context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups, boolean op) {
- this(context == null ? null : ContextSet.fromMap(context), includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, op);
- }
-
- @SuppressWarnings("deprecation")
- @Deprecated
- public Contexts(Map context, boolean includeGlobal, boolean includeGlobalWorld, boolean applyGroups, boolean applyGlobalGroups, boolean applyGlobalWorldGroups) {
- this(context, includeGlobal, includeGlobalWorld, applyGroups, applyGlobalGroups, applyGlobalWorldGroups, false);
- }
-
/**
* Gets the contexts that apply for this lookup
*
@@ -136,17 +111,6 @@ public class Contexts {
return this.context;
}
- /**
- * Gets the contexts that apply for this lookup
- *
- * @return an immutable map of context key value pairs
- * @deprecated in favour of {@link #getContexts()}
- */
- @Deprecated
- public Map getContext() {
- return this.context.toMap();
- }
-
/**
* Gets if OP defaults should be included
*
diff --git a/api/src/main/java/me/lucko/luckperms/api/Datastore.java b/api/src/main/java/me/lucko/luckperms/api/Datastore.java
deleted file mode 100644
index 621dfd052..000000000
--- a/api/src/main/java/me/lucko/luckperms/api/Datastore.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2016 Lucko (Luck)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.lucko.luckperms.api;
-
-import me.lucko.luckperms.api.data.Callback;
-
-import java.util.Set;
-import java.util.UUID;
-
-/**
- * Deprecated Storage interface. Use {@link Storage} instead.
- *
- * @deprecated as of version 2.14 in favour of {@link Storage}.
- */
-@Deprecated
-public interface Datastore {
-
- String getName();
-
- boolean isAcceptingLogins();
-
- @Deprecated
- Sync sync();
-
- @Deprecated
- Async async();
-
- @Deprecated
- Future future();
-
- @Deprecated
- interface Sync {
- boolean logAction(LogEntry entry);
-
- Log getLog();
-
- @Deprecated
- boolean loadOrCreateUser(UUID uuid, String username);
-
- @Deprecated
- boolean loadUser(UUID uuid);
-
- boolean loadUser(UUID uuid, String username);
-
- boolean saveUser(User user);
-
- boolean cleanupUsers();
-
- Set getUniqueUsers();
-
- boolean createAndLoadGroup(String name);
-
- boolean loadGroup(String name);
-
- boolean loadAllGroups();
-
- boolean saveGroup(Group group);
-
- boolean deleteGroup(Group group);
-
- boolean createAndLoadTrack(String name);
-
- boolean loadTrack(String name);
-
- boolean loadAllTracks();
-
- boolean saveTrack(Track track);
-
- boolean deleteTrack(Track track);
-
- boolean saveUUIDData(String username, UUID uuid);
-
- UUID getUUID(String username);
- }
-
- @Deprecated
- interface Async {
- void logAction(LogEntry entry, Callback callback);
-
- void getLog(Callback callback);
-
- @Deprecated
- void loadOrCreateUser(UUID uuid, String username, Callback callback);
-
- @Deprecated
- void loadUser(UUID uuid, Callback callback);
-
- void loadUser(UUID uuid, String username, Callback callback);
-
- void saveUser(User user, Callback callback);
-
- void cleanupUsers(Callback callback);
-
- void getUniqueUsers(Callback> callback);
-
- void createAndLoadGroup(String name, Callback callback);
-
- void loadGroup(String name, Callback callback);
-
- void loadAllGroups(Callback callback);
-
- void saveGroup(Group group, Callback callback);
-
- void deleteGroup(Group group, Callback callback);
-
- void createAndLoadTrack(String name, Callback callback);
-
- void loadTrack(String name, Callback callback);
-
- void loadAllTracks(Callback callback);
-
- void saveTrack(Track track, Callback callback);
-
- void deleteTrack(Track track, Callback callback);
-
- void saveUUIDData(String username, UUID uuid, Callback callback);
-
- void getUUID(String username, Callback callback);
- }
-
- @Deprecated
- interface Future {
- java.util.concurrent.Future logAction(LogEntry entry);
-
- java.util.concurrent.Future getLog();
-
- @Deprecated
- java.util.concurrent.Future loadOrCreateUser(UUID uuid, String username);
-
- @Deprecated
- java.util.concurrent.Future loadUser(UUID uuid);
-
- java.util.concurrent.Future loadUser(UUID uuid, String username);
-
- java.util.concurrent.Future saveUser(User user);
-
- java.util.concurrent.Future cleanupUsers();
-
- java.util.concurrent.Future> getUniqueUsers();
-
- java.util.concurrent.Future createAndLoadGroup(String name);
-
- java.util.concurrent.Future loadGroup(String name);
-
- java.util.concurrent.Future loadAllGroups();
-
- java.util.concurrent.Future saveGroup(Group group);
-
- java.util.concurrent.Future deleteGroup(Group group);
-
- java.util.concurrent.Future createAndLoadTrack(String name);
-
- java.util.concurrent.Future loadTrack(String name);
-
- java.util.concurrent.Future loadAllTracks();
-
- java.util.concurrent.Future saveTrack(Track track);
-
- java.util.concurrent.Future deleteTrack(Track track);
-
- java.util.concurrent.Future saveUUIDData(String username, UUID uuid);
-
- java.util.concurrent.Future getUUID(String username);
- }
-}
diff --git a/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java b/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java
index 9bd4a4718..be123eb63 100644
--- a/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java
+++ b/api/src/main/java/me/lucko/luckperms/api/LPConfiguration.java
@@ -23,7 +23,6 @@
package me.lucko.luckperms.api;
import me.lucko.luckperms.api.data.DatastoreConfiguration;
-import me.lucko.luckperms.api.data.MySQLConfiguration;
import java.util.Map;
@@ -44,22 +43,6 @@ public interface LPConfiguration {
*/
int getSyncTime();
- /**
- * Returns the default group, in a node representation
- * @return the default group, in a node representation
- * @deprecated as of 2.6, the default group is always "default"
- */
- @Deprecated
- String getDefaultGroupNode();
-
- /**
- * Returns the name of the default group
- * @return the name of the default group
- * @deprecated as of 2.6, the default group is always "default"
- */
- @Deprecated
- String getDefaultGroupName();
-
/**
* Returns if the users on this server will have their global permissions applied
* @return if the users on this server will have their global permissions applied
@@ -118,15 +101,6 @@ public interface LPConfiguration {
*/
boolean getLogNotify();
- /**
- * Returns true if permission checks are being recorded / debugged
- * @return true if permission checks are being recorded / debugged
- * @since 2.9
- * @deprecated as this value is now always false. Functionality was replaced by the verbose command.
- */
- @Deprecated
- boolean getDebugPermissionChecks();
-
/**
* Returns true if the vanilla op system is enabled
* @return true if the vanilla op system is enabled
@@ -162,15 +136,6 @@ public interface LPConfiguration {
*/
boolean getVaultIncludeGlobal();
- /**
- * Returns the database values set in the configuration
- * @return the database values set in the configuration
- * @deprecated use {@link #getDatastoreConfig()}
- */
- @SuppressWarnings("deprecation")
- @Deprecated
- MySQLConfiguration getDatabaseValues();
-
/**
* Returns the values set for data storage in the configuration
* @return the values set for data storage in the configuration
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 8aa14ed02..112006362 100644
--- a/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java
+++ b/api/src/main/java/me/lucko/luckperms/api/LuckPermsApi.java
@@ -22,10 +22,9 @@
package me.lucko.luckperms.api;
-import me.lucko.luckperms.api.context.ContextListener;
+import me.lucko.luckperms.api.context.ContextCalculator;
import me.lucko.luckperms.api.context.ContextSet;
-import me.lucko.luckperms.api.context.IContextCalculator;
-import me.lucko.luckperms.api.event.LPListener;
+import me.lucko.luckperms.api.event.EventBus;
import java.util.Optional;
import java.util.Set;
@@ -42,37 +41,31 @@ public interface LuckPermsApi {
void runUpdateTask();
/**
+ * Gets the API version
* @return the version of the API running on the platform
* @since 2.6
*/
double getApiVersion();
/**
+ * Gets the plugin version
* @return the version of the plugin running on the platform
*/
String getVersion();
/**
+ * Gets the platform LuckPerms is running on
* @return the platform LuckPerms is running on
* @since 2.7
*/
PlatformType getPlatformType();
/**
- * Registers a listener to be sent LuckPerms events
- *
- * @param listener the listener instance
- * @throws NullPointerException if the listener is null
+ * Gets the event bus, used for subscribing to events
+ * @return the event bus
+ * @since 3.0
*/
- void registerListener(LPListener listener);
-
- /**
- * Unregisters a previously registered listener from the EventBus
- *
- * @param listener the listener instance to unregister
- * @throws NullPointerException if the listener is null
- */
- void unregisterListener(LPListener listener);
+ EventBus getEventBus();
/**
* Gets a wrapped {@link LPConfiguration} instance, with read only access
@@ -89,16 +82,6 @@ public interface LuckPermsApi {
*/
Storage getStorage();
- /**
- * Gets a wrapped Datastore instance.
- *
- * @return a datastore instance
- * @deprecated in favour of {@link #getStorage()}
- */
- @SuppressWarnings("deprecation")
- @Deprecated
- Datastore getDatastore();
-
/**
* Gets the messaging service in use on the platform, if present.
*
@@ -274,15 +257,7 @@ public interface LuckPermsApi {
* @param contextCalculator the context calculator to register. The type MUST be the player class of the platform.
* @throws ClassCastException if the type is not the player class of the platform.
*/
- void registerContextCalculator(IContextCalculator> contextCalculator);
-
- /**
- * Registers a custom context listener to the server,
- *
- * @param contextListener the context listener to register. The type MUST be the player class of the platform.
- * @throws ClassCastException if the type is not the player class of the platform.
- */
- void registerContextListener(ContextListener> contextListener);
+ void registerContextCalculator(ContextCalculator> contextCalculator);
/**
* Gets a calculated context instance for the user using the rules of the platform.
@@ -295,7 +270,7 @@ public interface LuckPermsApi {
Optional getContextForUser(User user);
/**
- * Gets set of contexts applicable to a player using the platforms {@link IContextCalculator}s.
+ * Gets set of contexts applicable to a player using the platforms {@link ContextCalculator}s.
*
* @param player the player to calculate for. Must be the player instance for the platform.
* @return a set of contexts.
diff --git a/api/src/main/java/me/lucko/luckperms/api/Node.java b/api/src/main/java/me/lucko/luckperms/api/Node.java
index 4e202e595..2b747e9c4 100644
--- a/api/src/main/java/me/lucko/luckperms/api/Node.java
+++ b/api/src/main/java/me/lucko/luckperms/api/Node.java
@@ -133,31 +133,6 @@ public interface Node extends Map.Entry {
*/
boolean shouldApplyWithContext(ContextSet context);
- /**
- * If this node should apply in the given context
- *
- * @param context the context key value pairs
- * @param worldAndServer if world and server contexts should be checked
- * @return true if the node should apply
- * @deprecated in favour of {@link #shouldApplyWithContext(ContextSet, boolean)}
- */
- @Deprecated
- default boolean shouldApplyWithContext(Map context, boolean worldAndServer) {
- return shouldApplyWithContext(ContextSet.fromMap(context), worldAndServer);
- }
-
- /**
- * If this node should apply in the given context
- *
- * @param context the context key value pairs
- * @return true if the node should apply
- * @deprecated in favour of {@link #shouldApplyWithContext(ContextSet)}
- */
- @Deprecated
- default boolean shouldApplyWithContext(Map context) {
- return shouldApplyWithContext(ContextSet.fromMap(context));
- }
-
/**
* Similar to {@link #shouldApplyOnServer(String, boolean, boolean)}, except this method accepts a List
*
@@ -227,15 +202,6 @@ public interface Node extends Map.Entry {
*/
boolean hasExpired();
- /**
- * @return the extra contexts required for this node to apply
- * @deprecated in favour of {@link #getContexts()}
- */
- @Deprecated
- default Map getExtraContexts() {
- return getContexts().toMap();
- }
-
/**
* @return the extra contexts required for this node to apply
* @since 2.13
diff --git a/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java b/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java
index ef907d78f..5d2a85d67 100644
--- a/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java
+++ b/api/src/main/java/me/lucko/luckperms/api/PermissionHolder.java
@@ -25,7 +25,6 @@ package me.lucko.luckperms.api;
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
@@ -73,17 +72,6 @@ public interface PermissionHolder {
*/
Set extends Node> getTransientPermissions();
-
- /**
- * Gets an immutable set of the nodes that this object has and inherits
- *
- * @return an immutable set of permissions
- * @since 2.6
- * @deprecated in favour of {@link #getAllNodes(Contexts)}
- */
- @Deprecated
- Set getAllNodes();
-
/**
* Gets a mutable sorted set of the nodes that this object has and inherits, filtered by context
* Unlike {@link #getAllNodesFiltered(Contexts)}, this method will not filter individual nodes. The context is only
@@ -117,15 +105,6 @@ public interface PermissionHolder {
*/
Map exportNodes(Contexts contexts, boolean lowerCase);
- /**
- * Gets an immutable Map of the objects permission nodes
- *
- * @return an immutable map of permissions
- * @deprecated in favour of {@link #getPermissions()}
- */
- @Deprecated
- Map getNodes();
-
/**
* Removes temporary permissions that have expired
*/
@@ -631,86 +610,4 @@ public interface PermissionHolder {
*/
Set getTemporaryPermissionNodes();
- /**
- * Gets the permissions and inherited permissions that apply to a specific server and world
- *
- * @param server The server to get nodes for
- * @param world The world to get nodes for
- * @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues)
- * @param possibleNodes A list of possible permission nodes for wildcard permission handling
- * @return a {@link Map} of the permissions
- * @deprecated in favour of {@link #getPermissions(String, String, Map, boolean, List, boolean)}
- */
- @Deprecated
- Map getLocalPermissions(String server, String world, List excludedGroups, List possibleNodes);
-
- /**
- * Gets the permissions and inherited permissions that apply to a specific server and world
- *
- * @param server The server to get nodes for
- * @param world The world to get nodes for
- * @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues)
- * @return a {@link Map} of the permissions
- * @deprecated in favour of {@link #getPermissions(String, String, Map, boolean, List, boolean)}
- */
- @Deprecated
- Map getLocalPermissions(String server, String world, List excludedGroups);
-
- /**
- * Gets the permissions and inherited permissions that apply to a specific server
- *
- * @param server The server to get nodes for
- * @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues)
- * @param possibleNodes A list of possible permission nodes for wildcard permission handling
- * @return a {@link Map} of the permissions
- * @deprecated in favour of {@link #getPermissions(String, String, Map, boolean, List, boolean)}
- */
- @Deprecated
- Map getLocalPermissions(String server, List excludedGroups, List possibleNodes);
-
- /**
- * Gets the permissions and inherited permissions that apply to a specific server
- *
- * @param server The server to get nodes for
- * @param excludedGroups Groups that shouldn't be inherited (to prevent circular inheritance issues)
- * @return a {@link Map} of the permissions
- * @deprecated in favour of {@link #getPermissions(String, String, Map, boolean, List, boolean)}
- */
- @Deprecated
- Map getLocalPermissions(String server, List excludedGroups);
-
- /**
- * Convert the holders nodes into a Map of permissions to be applied on the platform
- *
- * @param server the server
- * @param world the world
- * @param extraContext any extra context to filter by
- * @param includeGlobal whether to include global nodes
- * @param possibleNodes a list of possible permissions for resolving wildcards
- * @param applyGroups if inherited group permissions should be included
- * @return a map of permissions
- * @since 2.6
- * @deprecated in favour of {@link #getAllNodesFiltered(Contexts)}
- */
- @Deprecated
- Map getPermissions(String server, String world, Map extraContext, boolean includeGlobal, List possibleNodes, boolean applyGroups);
-
- /**
- * Processes the nodes and returns the temporary ones.
- *
- * @return a map of temporary nodes
- * @deprecated in favour of {@link #getTemporaryPermissionNodes()}
- */
- @Deprecated
- Map, Long> getTemporaryNodes();
-
- /**
- * Processes the nodes and returns the non-temporary ones.
- *
- * @return a map of permanent nodes
- * @deprecated in favour of {@link #getPermanentPermissionNodes()}
- */
- @Deprecated
- Map getPermanentNodes();
-
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/PlatformType.java b/api/src/main/java/me/lucko/luckperms/api/PlatformType.java
index e99644076..04e7fad81 100644
--- a/api/src/main/java/me/lucko/luckperms/api/PlatformType.java
+++ b/api/src/main/java/me/lucko/luckperms/api/PlatformType.java
@@ -31,12 +31,7 @@ public enum PlatformType {
BUKKIT("Bukkit"),
BUNGEE("Bungee"),
- SPONGE("Sponge"),
-
- /**
- * @since 2.9
- */
- STANDALONE("Standalone");
+ SPONGE("Sponge");
private final String friendlyName;
diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java b/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java
index f26303bea..aec773715 100644
--- a/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java
+++ b/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java
@@ -22,55 +22,34 @@
package me.lucko.luckperms.api.context;
-import java.util.List;
import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
/**
- * A simple implementation of the listener aspects of {@link IContextCalculator}
+ * Calculates whether contexts are applicable to {@link T}
*
- * @param the subject type
+ *
Somewhat inspired by the system used on Sponge.
+ *
+ * @param the subject type. Is ALWAYS the player class of the platform.
*/
-public abstract class ContextCalculator implements IContextCalculator {
- private final List> listeners = new CopyOnWriteArrayList<>();
+public interface ContextCalculator {
/**
- * Pushes an update to all registered {@link ContextListener}s.
- * Make sure any changes are applied internally before this method is called.
+ * Gives the subject all of the applicable contexts they meet
*
- * @param subject the subject that changed
- * @param before the context state before the change
- * @param current the context state after the change (now)
- * @throws NullPointerException if any parameters are null
+ * @param subject the subject to add contexts to
+ * @param accumulator a map of contexts to add to
+ * @return the map
+ * @since 2.13
*/
- protected void pushUpdate(T subject, Map.Entry before, Map.Entry current) {
- if (subject == null) {
- throw new NullPointerException("subject");
- }
- if (before == null) {
- throw new NullPointerException("before");
- }
- if (current == null) {
- throw new NullPointerException("current");
- }
+ MutableContextSet giveApplicableContext(T subject, MutableContextSet accumulator);
- for (ContextListener listener : listeners) {
- try {
- listener.onContextChange(subject, before, current);
- } catch (Exception e) {
- System.out.println("Exception whilst passing context change to listener: " + listener);
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public void addListener(ContextListener listener) {
- if (listener == null) {
- throw new NullPointerException("listener");
- }
-
- listeners.add(listener);
- }
+ /**
+ * Checks to see if a context is applicable to a subject
+ *
+ * @param subject the subject to check against
+ * @param context the context to check for
+ * @return true if met, or false if not. If this calculator does not calculate the given context, return false.
+ */
+ boolean isContextApplicable(T subject, Map.Entry context);
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/context/IContextCalculator.java b/api/src/main/java/me/lucko/luckperms/api/context/IContextCalculator.java
deleted file mode 100644
index 20e0b6876..000000000
--- a/api/src/main/java/me/lucko/luckperms/api/context/IContextCalculator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2016 Lucko (Luck)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.lucko.luckperms.api.context;
-
-import java.util.Map;
-
-/**
- * Calculates whether contexts are applicable to {@link T}
- *
- *
Somewhat inspired by the system used on Sponge.
- *
- * @param the subject type. Is ALWAYS the player class of the platform.
- */
-public interface IContextCalculator {
-
- /**
- * Gives the subject all of the applicable contexts they meet
- *
- * @param subject the subject to add contexts to
- * @param accumulator a map of contexts to add to
- * @return the map
- * @since 2.13
- */
- MutableContextSet giveApplicableContext(T subject, MutableContextSet accumulator);
-
- /**
- * Checks to see if a context is applicable to a subject
- *
- * @param subject the subject to check against
- * @param context the context to check for
- * @return true if met, or false if not. If this calculator does not calculate the given context, return false.
- */
- boolean isContextApplicable(T subject, Map.Entry context);
-
- /**
- * Adds a listener to be called whenever a context handled by this calculator changes
- *
- * @param listener the listener instance
- * @throws NullPointerException if listener is null
- */
- void addListener(ContextListener listener);
-
-}
diff --git a/api/src/main/java/me/lucko/luckperms/api/data/Callback.java b/api/src/main/java/me/lucko/luckperms/api/data/Callback.java
deleted file mode 100644
index 177262e8c..000000000
--- a/api/src/main/java/me/lucko/luckperms/api/data/Callback.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2016 Lucko (Luck)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.lucko.luckperms.api.data;
-
-import java.util.function.Consumer;
-
-/**
- * A callback used to wait for the completion of asynchronous operations.
- * All callbacks are ran on the main server thread.
- *
- * @param the return type
- * @deprecated in favour of {@link Consumer}
- */
-@Deprecated
-public interface Callback {
-
- static Callback empty() {
- return t -> {
- };
- }
-
- static Callback of(Runnable runnable) {
- if (runnable == null) {
- throw new NullPointerException("runnable");
- }
- return t -> runnable.run();
- }
-
- static Callback of(Consumer consumer) {
- if (consumer == null) {
- throw new NullPointerException("consumer");
- }
- return consumer::accept;
- }
-
- /**
- * Helper method for converting old {@link Callback}s to use the new {@link me.lucko.luckperms.api.Storage}
- * interface.
- *
- * @param callback the callback to convert
- * @param the return type
- * @return a consumer instance
- * @since 2.14
- * @deprecated in favour of just using {@link Consumer}s.
- */
- @Deprecated
- static Consumer convertToConsumer(Callback callback) {
- return callback::onComplete;
- }
-
- /**
- * Called when the operation completes.
- *
- * @param t the return value, may be null
- */
- void onComplete(T t);
-
-}
diff --git a/api/src/main/java/me/lucko/luckperms/api/data/DatastoreConfiguration.java b/api/src/main/java/me/lucko/luckperms/api/data/DatastoreConfiguration.java
index c8f7dfa94..fae694df0 100644
--- a/api/src/main/java/me/lucko/luckperms/api/data/DatastoreConfiguration.java
+++ b/api/src/main/java/me/lucko/luckperms/api/data/DatastoreConfiguration.java
@@ -26,8 +26,7 @@ package me.lucko.luckperms.api.data;
* Represents the data section of the main LuckPerms configuration.
* All methods could return null.
*/
-@SuppressWarnings("deprecation")
-public interface DatastoreConfiguration extends MySQLConfiguration {
+public interface DatastoreConfiguration {
String getAddress();
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/AbstractPermissionAddEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/AbstractPermissionAddEvent.java
deleted file mode 100644
index 3984df491..000000000
--- a/api/src/main/java/me/lucko/luckperms/api/event/AbstractPermissionAddEvent.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2016 Lucko (Luck)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.lucko.luckperms.api.event;
-
-import me.lucko.luckperms.api.PermissionHolder;
-
-import java.util.Optional;
-
-public class AbstractPermissionAddEvent extends TargetedEvent {
-
- private final String server;
- private final String world;
- private final long expiry;
-
- protected AbstractPermissionAddEvent(String eventName, PermissionHolder target, String server, String world, long expiry) {
- super(eventName, target);
- this.server = server;
- this.world = world;
- this.expiry = expiry;
- }
-
- public Optional getServer() {
- return Optional.ofNullable(server);
- }
-
- public Optional getWorld() {
- return Optional.ofNullable(world);
- }
-
- public boolean isTemporary() {
- return expiry != 0L;
- }
-
- public long getExpiry() {
- return expiry;
- }
-}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/UserEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/Cancellable.java
similarity index 79%
rename from api/src/main/java/me/lucko/luckperms/api/event/UserEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/Cancellable.java
index 80225181c..e19c959d5 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/UserEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/Cancellable.java
@@ -22,21 +22,18 @@
package me.lucko.luckperms.api.event;
-import me.lucko.luckperms.api.User;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
- * Represents an event acting upon a user.
+ * Represents an event that can be cancelled
*/
-public class UserEvent extends LPEvent {
+public interface Cancellable {
- private final User user;
+ /**
+ * Gets an {@link AtomicBoolean} holding the cancellation state of the event
+ *
+ * @return the cancellation
+ */
+ AtomicBoolean getCancellationState();
- protected UserEvent(String eventName, User user) {
- super(eventName);
- this.user = user;
- }
-
- public User getUser() {
- return user;
- }
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/LPEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/EventBus.java
similarity index 59%
rename from api/src/main/java/me/lucko/luckperms/api/event/LPEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/EventBus.java
index a9cadd4f0..27eec611d 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/LPEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/EventBus.java
@@ -22,39 +22,33 @@
package me.lucko.luckperms.api.event;
-import me.lucko.luckperms.api.LuckPermsApi;
+import java.util.Set;
+import java.util.function.Consumer;
/**
- * Abstract LuckPerms Event class.
+ * The LuckPerms event bus. Used for subscribing (or registering listeners) to events.
+ *
+ * @since 3.0
*/
-public abstract class LPEvent {
+public interface EventBus {
/**
- * A friendly name of the event
+ * Subscribe to an event
+ *
+ * @param eventClass the event class
+ * @param handler the event handler
+ * @param the event class
+ * @return an event handler instance representing this subscription
*/
- private final String eventName;
+ EventHandler subscribe(Class eventClass, Consumer handler);
+
/**
- * A link to the API instance provided for convenience.
+ * Gets a set of all registered handlers for a given event
+ *
+ * @param eventClass the event to find handlers for
+ * @param the event class
+ * @return an immutable set of event handlers
*/
- private LuckPermsApi api = null;
-
- protected LPEvent(String eventName) {
- this.eventName = eventName;
- }
-
- public String getEventName() {
- return eventName;
- }
-
- public LuckPermsApi getApi() {
- return api;
- }
-
- public void setApi(LuckPermsApi api) {
- if (this.api != null) {
- throw new IllegalStateException("API can only be set once.");
- }
- this.api = api;
- }
+ Set> getHandlers(Class eventClass);
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/AbstractPermissionRemoveEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/EventHandler.java
similarity index 56%
rename from api/src/main/java/me/lucko/luckperms/api/event/AbstractPermissionRemoveEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/EventHandler.java
index daa26636f..3af0c7139 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/AbstractPermissionRemoveEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/EventHandler.java
@@ -22,41 +22,48 @@
package me.lucko.luckperms.api.event;
-import me.lucko.luckperms.api.PermissionHolder;
+import java.util.function.Consumer;
-import java.util.Optional;
-
-public class AbstractPermissionRemoveEvent extends TargetedEvent {
-
- private final String server;
- private final String world;
- private final boolean temporary;
-
- protected AbstractPermissionRemoveEvent(String eventName, PermissionHolder target, String server, String world, boolean temporary) {
- super(eventName, target);
- this.server = server;
- this.world = world;
- this.temporary = temporary;
- }
-
- public Optional getServer() {
- return Optional.ofNullable(server);
- }
-
- public Optional getWorld() {
- return Optional.ofNullable(world);
- }
+/**
+ * Represents a handler for a LuckPerms event
+ *
+ * @param the event class
+ */
+public interface EventHandler {
/**
- * @deprecated use {@link #isTemporary()}
+ * Gets the class this handler is listening to
+ *
+ * @return the event class
*/
- @Deprecated
- public boolean getTemporary() {
- return temporary;
- }
+ Class getEventClass();
- public boolean isTemporary() {
- return temporary;
- }
+ /**
+ * Returns true if this handler is active
+ *
+ * @return true if this handler is still active
+ */
+ boolean isActive();
+
+ /**
+ * Unregisters this handler from the event bus
+ *
+ * @return true if the handler wasn't already unregistered
+ */
+ boolean unregister();
+
+ /**
+ * Gets the event consumer responsible for handling the event
+ *
+ * @return the event consumer
+ */
+ Consumer getConsumer();
+
+ /**
+ * Gets the number of times this handler has been called
+ *
+ * @return the number of times this handler has been called
+ */
+ int getCallCount();
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/TargetedEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/LuckPermsEvent.java
similarity index 78%
rename from api/src/main/java/me/lucko/luckperms/api/event/TargetedEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/LuckPermsEvent.java
index 523bbc001..42286805e 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/TargetedEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/LuckPermsEvent.java
@@ -22,21 +22,20 @@
package me.lucko.luckperms.api.event;
+import me.lucko.luckperms.api.LuckPermsApi;
+
/**
- * Represents an event acting upon a target
+ * The base event interface
*
- * @param the target type
+ * @since 3.0
*/
-public class TargetedEvent extends LPEvent {
+public interface LuckPermsEvent {
- private final T target;
+ /**
+ * Get the API instance this event was dispatched from
+ *
+ * @return the api instance
+ */
+ LuckPermsApi getApi();
- protected TargetedEvent(String eventName, T target) {
- super(eventName);
- this.target = target;
- }
-
- public T getTarget() {
- return target;
- }
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/cause/CreationCause.java b/api/src/main/java/me/lucko/luckperms/api/event/cause/CreationCause.java
new file mode 100644
index 000000000..34d5e0619
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/cause/CreationCause.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.cause;
+
+/**
+ * The cause of a group/track creation
+ */
+public enum CreationCause {
+
+ /**
+ * The creation was caused by a command
+ */
+ COMMAND,
+
+ /**
+ * The creation was caused by an API call
+ */
+ API,
+
+ /**
+ * The creation was caused by a LuckPerms internal
+ */
+ INTERNAL;
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/cause/DeletionCause.java b/api/src/main/java/me/lucko/luckperms/api/event/cause/DeletionCause.java
new file mode 100644
index 000000000..e9c4b9c9a
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/cause/DeletionCause.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.cause;
+
+/**
+ * The cause of a group/track deletion
+ */
+public enum DeletionCause {
+
+ /**
+ * The deletion was caused by a command
+ */
+ COMMAND,
+
+ /**
+ * The deletion was caused by an API call
+ */
+ API,
+
+ /**
+ * The deletion was caused by a LuckPerms internal
+ */
+ INTERNAL;
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/events/GroupRemoveEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/events/GroupRemoveEvent.java
deleted file mode 100644
index f44a74a7f..000000000
--- a/api/src/main/java/me/lucko/luckperms/api/event/events/GroupRemoveEvent.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2016 Lucko (Luck)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.lucko.luckperms.api.event.events;
-
-import me.lucko.luckperms.api.PermissionHolder;
-import me.lucko.luckperms.api.event.AbstractPermissionRemoveEvent;
-
-/**
- * Called whenever a user or group is removed from / stops inheriting another group
- */
-public class GroupRemoveEvent extends AbstractPermissionRemoveEvent {
-
- /**
- * The name of group being removed from the target.
- * Be aware that this group may have already been deleted, and and instance may therefore not exist internally.
- */
- private final String group;
-
- public GroupRemoveEvent(PermissionHolder target, String group, String server, String world, boolean temporary) {
- super("Group Remove Event", target, server, world, temporary);
- this.group = group;
- }
-
- public String getGroup() {
- return group;
- }
-}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/events/PermissionExpireEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/events/PermissionExpireEvent.java
deleted file mode 100644
index 8d090ea49..000000000
--- a/api/src/main/java/me/lucko/luckperms/api/event/events/PermissionExpireEvent.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2016 Lucko (Luck)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.lucko.luckperms.api.event.events;
-
-import me.lucko.luckperms.api.PermissionHolder;
-import me.lucko.luckperms.api.event.TargetedEvent;
-
-/**
- * Called when a permission expires for an object.
- *
- * @deprecated in favour of {@link PermissionNodeExpireEvent}
- */
-@Deprecated
-public class PermissionExpireEvent extends TargetedEvent {
-
- private final String node;
-
- public PermissionExpireEvent(PermissionHolder target, String node) {
- super("Permission Expire Event", target);
- this.node = node;
- }
-
- public String getNode() {
- return node;
- }
-}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/events/PermissionSetEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/events/PermissionSetEvent.java
deleted file mode 100644
index c4f522cc1..000000000
--- a/api/src/main/java/me/lucko/luckperms/api/event/events/PermissionSetEvent.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2016 Lucko (Luck)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.lucko.luckperms.api.event.events;
-
-import me.lucko.luckperms.api.PermissionHolder;
-import me.lucko.luckperms.api.event.AbstractPermissionAddEvent;
-
-import java.util.AbstractMap;
-import java.util.Map;
-
-/**
- * Called whenever a user or group has a permission set.
- *
- * @deprecated in favour of {@link PermissionNodeSetEvent}
- */
-@Deprecated
-public class PermissionSetEvent extends AbstractPermissionAddEvent {
-
- private final String node;
- private final boolean value;
-
- public PermissionSetEvent(PermissionHolder target, String node, boolean value, String server, String world, long expiry) {
- super("Permission Set Event", target, server, world, expiry);
- this.node = node;
- this.value = value;
- }
-
- public String getNode() {
- return node;
- }
-
- public boolean getValue() {
- return value;
- }
-
- public Map.Entry getEntry() {
- return new AbstractMap.SimpleEntry<>(node, value);
- }
-}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/events/PermissionUnsetEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/events/PermissionUnsetEvent.java
deleted file mode 100644
index d009c6c64..000000000
--- a/api/src/main/java/me/lucko/luckperms/api/event/events/PermissionUnsetEvent.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2016 Lucko (Luck)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.lucko.luckperms.api.event.events;
-
-import me.lucko.luckperms.api.PermissionHolder;
-import me.lucko.luckperms.api.event.AbstractPermissionRemoveEvent;
-
-/**
- * Called whenever a user or group has a permission unset.
- *
- * @deprecated in favour of {@link PermissionNodeUnsetEvent}
- */
-@Deprecated
-public class PermissionUnsetEvent extends AbstractPermissionRemoveEvent {
-
- private final String node;
-
- public PermissionUnsetEvent(PermissionHolder target, String node, String server, String world, boolean temporary) {
- super("Permission Unset Event", target, server, world, temporary);
- this.node = node;
- }
-
- public String getNode() {
- return node;
- }
-}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCreateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCreateEvent.java
new file mode 100644
index 000000000..587b3f4b0
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCreateEvent.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.group;
+
+import me.lucko.luckperms.api.Group;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+import me.lucko.luckperms.api.event.cause.CreationCause;
+
+/**
+ * Called when a group is created
+ */
+public interface GroupCreateEvent extends LuckPermsEvent {
+
+ /**
+ * Gets the new group
+ *
+ * @return the new group
+ */
+ Group getGroup();
+
+ /**
+ * Gets the cause of the creation
+ *
+ * @return the cause of the creation
+ */
+ CreationCause getCause();
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/events/PermissionNodeUnsetEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDeleteEvent.java
similarity index 62%
rename from api/src/main/java/me/lucko/luckperms/api/event/events/PermissionNodeUnsetEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/group/GroupDeleteEvent.java
index 7cbcfd716..1dd9ff104 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/events/PermissionNodeUnsetEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDeleteEvent.java
@@ -20,19 +20,38 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.api.event.events;
+package me.lucko.luckperms.api.event.group;
import me.lucko.luckperms.api.Node;
-import me.lucko.luckperms.api.PermissionHolder;
-import me.lucko.luckperms.api.event.AbstractPermissionEvent;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+import me.lucko.luckperms.api.event.cause.DeletionCause;
+
+import java.util.Set;
/**
- * Called when a permission node is unset from a holder
- *
- * @since 2.6
+ * Called when a group is deleted
*/
-public class PermissionNodeUnsetEvent extends AbstractPermissionEvent {
- public PermissionNodeUnsetEvent(PermissionHolder target, Node node) {
- super("Permission Node Unset Event", target, node);
- }
+public interface GroupDeleteEvent extends LuckPermsEvent {
+
+ /**
+ * Gets the name of the deleted group
+ *
+ * @return the name of the deleted group
+ */
+ String getGroupName();
+
+ /**
+ * Gets an immutable copy of the groups existing data
+ *
+ * @return a copy of the groups existing data
+ */
+ Set getExistingData();
+
+ /**
+ * Gets the cause of the deletion
+ *
+ * @return the cause of the deletion
+ */
+ DeletionCause getCause();
+
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadAllEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadAllEvent.java
new file mode 100644
index 000000000..509648be5
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadAllEvent.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.group;
+
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+
+/**
+ * Called when all groups have been loaded in from storage.
+ *
+ *
Usually only called on startup and in sync tasks.
+ */
+public interface GroupLoadAllEvent extends LuckPermsEvent {
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/CancellableEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadEvent.java
similarity index 72%
rename from api/src/main/java/me/lucko/luckperms/api/event/CancellableEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadEvent.java
index 52c31cef9..ea518f1c2 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/CancellableEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadEvent.java
@@ -20,24 +20,23 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.api.event;
+package me.lucko.luckperms.api.event.group;
+
+import me.lucko.luckperms.api.Group;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
/**
- * Event that allows listeners to set the cancelled state of an event.
+ * Called when a group is loaded into memory from the storage.
+ *
+ * Note that this event is not the same as {@link GroupCreateEvent}
*/
-public abstract class CancellableEvent extends LPEvent {
+public interface GroupLoadEvent extends LuckPermsEvent {
- private boolean cancelled = false;
+ /**
+ * Gets the group that was loaded
+ *
+ * @return the group that was loaded
+ */
+ Group getGroup();
- protected CancellableEvent(String eventName) {
- super(eventName);
- }
-
- public boolean isCancelled() {
- return cancelled;
- }
-
- public void setCancelled(boolean cancelled) {
- this.cancelled = cancelled;
- }
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/log/LogBroadcastEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/log/LogBroadcastEvent.java
new file mode 100644
index 000000000..f2cd0680a
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/log/LogBroadcastEvent.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.log;
+
+import me.lucko.luckperms.api.LogEntry;
+import me.lucko.luckperms.api.event.Cancellable;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+
+/**
+ * Called when a log entry is about to be sent to notifiable players on the platform
+ */
+public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable {
+
+ /**
+ * Gets the log entry to be broadcasted
+ *
+ * @return the log entry to be broadcasted
+ */
+ LogEntry getEntry();
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/AbstractPermissionEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/log/LogPublishEvent.java
similarity index 71%
rename from api/src/main/java/me/lucko/luckperms/api/event/AbstractPermissionEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/log/LogPublishEvent.java
index 09ae4976a..6b2b88a3b 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/AbstractPermissionEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/log/LogPublishEvent.java
@@ -20,24 +20,22 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.api.event;
+package me.lucko.luckperms.api.event.log;
-import me.lucko.luckperms.api.Node;
-import me.lucko.luckperms.api.PermissionHolder;
+import me.lucko.luckperms.api.LogEntry;
+import me.lucko.luckperms.api.event.Cancellable;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
/**
- * @since 2.6
+ * Called when a log is about to be published to the storage file/table
*/
-public class AbstractPermissionEvent extends TargetedEvent {
+public interface LogPublishEvent extends LuckPermsEvent, Cancellable {
- private final Node node;
+ /**
+ * Gets the log entry to be published
+ *
+ * @return the log entry to be published
+ */
+ LogEntry getEntry();
- protected AbstractPermissionEvent(String eventName, PermissionHolder target, Node node) {
- super(eventName, target);
- this.node = node;
- }
-
- public Node getNode() {
- return node;
- }
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/data/MySQLConfiguration.java b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeAddEvent.java
similarity index 79%
rename from api/src/main/java/me/lucko/luckperms/api/data/MySQLConfiguration.java
rename to api/src/main/java/me/lucko/luckperms/api/event/node/NodeAddEvent.java
index aedaf44fe..fb7583aeb 100644
--- a/api/src/main/java/me/lucko/luckperms/api/data/MySQLConfiguration.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeAddEvent.java
@@ -20,19 +20,20 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.api.data;
+package me.lucko.luckperms.api.event.node;
+
+import me.lucko.luckperms.api.Node;
/**
- * @deprecated Use {@link DatastoreConfiguration}. This is now used by multiple datastores, not just MySQL.
+ * Called when a node is added to a holder
*/
-@Deprecated
-public interface MySQLConfiguration {
+public interface NodeAddEvent extends NodeMutateEvent {
- String getAddress();
+ /**
+ * Gets the node that was added
+ *
+ * @return the node that was added
+ */
+ Node getNode();
- String getDatabase();
-
- String getUsername();
-
- String getPassword();
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/node/NodeClearEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeClearEvent.java
new file mode 100644
index 000000000..74ad904ec
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeClearEvent.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.node;
+
+/**
+ * Called when a holder has their nodes cleared
+ */
+public interface NodeClearEvent extends NodeMutateEvent {
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/node/NodeMutateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeMutateEvent.java
new file mode 100644
index 000000000..dac0dc176
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeMutateEvent.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.node;
+
+import me.lucko.luckperms.api.Node;
+import me.lucko.luckperms.api.PermissionHolder;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+
+import java.util.Set;
+
+/**
+ * Called when a node is added to/removed from a user/group
+ */
+public interface NodeMutateEvent extends LuckPermsEvent {
+
+ /**
+ * Gets the target of the event
+ *
+ * @return the event target
+ */
+ PermissionHolder getTarget();
+
+ /**
+ * Gets an immutable copy of the holders data before the change
+ *
+ * @return the data before the change
+ */
+ Set getDataBefore();
+
+ /**
+ * Gets an immutable copy of the holders data after the change
+ *
+ * @return the data after the change
+ */
+ Set getDataAfter();
+
+ /**
+ * Gets whether the target of this event is a {@link me.lucko.luckperms.api.User}
+ *
+ *
This is equivalent to checking if getTarget() instanceof User
+ *
+ * @return if the event is targeting a user
+ */
+ boolean isUser();
+
+ /**
+ * Gets whether the target of this event is a {@link me.lucko.luckperms.api.Group}
+ *
+ *
This is equivalent to checking if getTarget() instanceof Group
+ *
+ * @return if the event is targeting a group
+ */
+ boolean isGroup();
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/node/NodeRemoveEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeRemoveEvent.java
new file mode 100644
index 000000000..2308cf234
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeRemoveEvent.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.node;
+
+import me.lucko.luckperms.api.Node;
+
+/**
+ * Called when a node is removed from a holder
+ */
+public interface NodeRemoveEvent extends NodeMutateEvent {
+
+ /**
+ * Gets the node that was removed
+ *
+ * @return the node that was removed
+ */
+ Node getNode();
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/sync/ConfigReloadEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/sync/ConfigReloadEvent.java
new file mode 100644
index 000000000..dfce7f27d
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/sync/ConfigReloadEvent.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.sync;
+
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+
+/**
+ * Called when the configuration is reloaded
+ */
+public interface ConfigReloadEvent extends LuckPermsEvent {
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/events/PostSyncEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/sync/PostSyncEvent.java
similarity index 82%
rename from api/src/main/java/me/lucko/luckperms/api/event/events/PostSyncEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/sync/PostSyncEvent.java
index 1dcec295b..37d1cee93 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/events/PostSyncEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/sync/PostSyncEvent.java
@@ -20,17 +20,13 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.api.event.events;
+package me.lucko.luckperms.api.event.sync;
-import me.lucko.luckperms.api.event.LPEvent;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
/**
- * Called after the sync task has ran.
+ * Called when an sync task has been completed
*/
-public class PostSyncEvent extends LPEvent {
-
- public PostSyncEvent() {
- super("Post Sync Event");
- }
+public interface PostSyncEvent extends LuckPermsEvent {
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/sync/PreNetworkSyncEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/sync/PreNetworkSyncEvent.java
new file mode 100644
index 000000000..5d3cee124
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/sync/PreNetworkSyncEvent.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.sync;
+
+import me.lucko.luckperms.api.event.Cancellable;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+
+import java.util.UUID;
+
+/**
+ * Called before a network sync task runs
+ */
+public interface PreNetworkSyncEvent extends LuckPermsEvent, Cancellable {
+
+ /**
+ * Gets the ID of the sync request
+ *
+ * @return the id of the sync request
+ */
+ UUID getSyncId();
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/events/PreSyncEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/sync/PreSyncEvent.java
similarity index 77%
rename from api/src/main/java/me/lucko/luckperms/api/event/events/PreSyncEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/sync/PreSyncEvent.java
index 126ca3e09..d1252b82a 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/events/PreSyncEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/sync/PreSyncEvent.java
@@ -20,18 +20,14 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.api.event.events;
+package me.lucko.luckperms.api.event.sync;
-import me.lucko.luckperms.api.event.CancellableEvent;
+import me.lucko.luckperms.api.event.Cancellable;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
/**
- * Called before the sync task is about to run.
- * Set this event to cancelled to prevent the sync task from running.
+ * Called before a sync task runs
*/
-public class PreSyncEvent extends CancellableEvent {
-
- public PreSyncEvent() {
- super("Pre Sync Event");
- }
+public interface PreSyncEvent extends LuckPermsEvent, Cancellable {
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/TrackCreateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackCreateEvent.java
new file mode 100644
index 000000000..b279c172d
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackCreateEvent.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.track;
+
+import me.lucko.luckperms.api.Track;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+import me.lucko.luckperms.api.event.cause.CreationCause;
+
+/**
+ * Called when a track is created
+ */
+public interface TrackCreateEvent extends LuckPermsEvent {
+
+ /**
+ * Gets the new track
+ *
+ * @return the new track
+ */
+ Track getTrack();
+
+ /**
+ * Gets the cause of the creation
+ *
+ * @return the cause of the creation
+ */
+ CreationCause getCause();
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ContextListener.java b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackDeleteEvent.java
similarity index 63%
rename from api/src/main/java/me/lucko/luckperms/api/context/ContextListener.java
rename to api/src/main/java/me/lucko/luckperms/api/event/track/TrackDeleteEvent.java
index 3b19c9bfc..ddf13c0b2 100644
--- a/api/src/main/java/me/lucko/luckperms/api/context/ContextListener.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackDeleteEvent.java
@@ -20,24 +20,37 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.api.context;
+package me.lucko.luckperms.api.event.track;
-import java.util.Map;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+import me.lucko.luckperms.api.event.cause.DeletionCause;
+
+import java.util.List;
/**
- * Listens to context changes
- *
- * @param the subject type, Is ALWAYS the player class of the platform.
+ * Called when a track is deleted
*/
-public interface ContextListener {
+public interface TrackDeleteEvent extends LuckPermsEvent {
/**
- * Called whenever a context changes on the
+ * Gets the name of the deleted track
*
- * @param subject the subject that had context changed
- * @param before the context state before the change
- * @param current the context state after the change (now)
+ * @return the name of the deleted track
*/
- void onContextChange(T subject, Map.Entry before, Map.Entry current) throws Exception;
+ String getTrackName();
+
+ /**
+ * Gets an immutable copy of the tracks existing data
+ *
+ * @return a copy of the tracks existing data
+ */
+ List getExistingData();
+
+ /**
+ * Gets the cause of the deletion
+ *
+ * @return the cause of the deletion
+ */
+ DeletionCause getCause();
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/TrackLoadAllEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackLoadAllEvent.java
new file mode 100644
index 000000000..8fbdb9703
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackLoadAllEvent.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.track;
+
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+
+/**
+ * Called when all tracks have been loaded in from storage.
+ *
+ *
Usually only called on startup and in sync tasks.
+ */
+public interface TrackLoadAllEvent extends LuckPermsEvent {
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/TrackLoadEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackLoadEvent.java
new file mode 100644
index 000000000..7e8eb8ef5
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackLoadEvent.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.track;
+
+import me.lucko.luckperms.api.Track;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+
+/**
+ * Called when a track is loaded into memory from the storage.
+ *
+ * Note that this event is not the same as {@link TrackCreateEvent}
+ */
+public interface TrackLoadEvent extends LuckPermsEvent {
+
+ /**
+ * Gets the track that was loaded
+ *
+ * @return the track that was loaded
+ */
+ Track getTrack();
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackAddGroupEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackAddGroupEvent.java
new file mode 100644
index 000000000..5f878d286
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackAddGroupEvent.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.track.mutate;
+
+/**
+ * Called when a group is added to a track
+ */
+public interface TrackAddGroupEvent extends TrackMutateEvent {
+
+ /**
+ * Gets the group that was added
+ *
+ * @return the group that was added
+ */
+ String getGroup();
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/LPListener.java b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackClearEvent.java
similarity index 88%
rename from api/src/main/java/me/lucko/luckperms/api/event/LPListener.java
rename to api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackClearEvent.java
index dc0bc7896..987c33517 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/LPListener.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackClearEvent.java
@@ -20,10 +20,11 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.api.event;
+package me.lucko.luckperms.api.event.track.mutate;
/**
- * Used to mark a class that listens for LuckPerms events
+ * Called when a track is cleared
*/
-public interface LPListener {
+public interface TrackClearEvent extends TrackMutateEvent {
+
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/events/LogNotifyEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackMutateEvent.java
similarity index 62%
rename from api/src/main/java/me/lucko/luckperms/api/event/events/LogNotifyEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackMutateEvent.java
index da5cc1d59..fb5630459 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/events/LogNotifyEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackMutateEvent.java
@@ -20,30 +20,37 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.api.event.events;
+package me.lucko.luckperms.api.event.track.mutate;
-import me.lucko.luckperms.api.LogEntry;
-import me.lucko.luckperms.api.event.CancellableEvent;
+import me.lucko.luckperms.api.Track;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+
+import java.util.List;
/**
- * Called before a LogEntry is broadcasted to players only with the notify permission.
- * The log entry will still be recorded in the datastore, regardless of the cancellation state of this event.
- * Cancelling this event only stops the broadcast.
+ * Called when a track is changed
*/
-public class LogNotifyEvent extends CancellableEvent {
+public interface TrackMutateEvent extends LuckPermsEvent {
/**
- * The log entry to be broadcasted
+ * Gets the track that was mutated
+ *
+ * @return the track that was mutated
*/
- private final LogEntry entry;
+ Track getTrack();
- public LogNotifyEvent(LogEntry entry) {
- super("Log Notify Event");
- this.entry = entry;
- }
+ /**
+ * Gets an immutable copy of the tracks data before the change
+ *
+ * @return the data before the change
+ */
+ List getDataBefore();
- public LogEntry getEntry() {
- return entry;
- }
+ /**
+ * Gets an immutable copy of the tracks data after the change
+ *
+ * @return the data after the change
+ */
+ List getDataAfter();
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackRemoveGroupEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackRemoveGroupEvent.java
new file mode 100644
index 000000000..3b753e575
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackRemoveGroupEvent.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.track.mutate;
+
+/**
+ * Called when a group is removed from a track
+ */
+public interface TrackRemoveGroupEvent extends TrackMutateEvent {
+
+ /**
+ * Gets the group that was removed
+ *
+ * @return the group that was removed
+ */
+ String getGroup();
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/UserCacheLoadEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserCacheLoadEvent.java
new file mode 100644
index 000000000..b479b2905
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserCacheLoadEvent.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.user;
+
+import me.lucko.luckperms.api.User;
+import me.lucko.luckperms.api.caching.UserData;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+
+/**
+ * Called when a users {@link me.lucko.luckperms.api.caching.UserData} is loaded.
+ */
+public interface UserCacheLoadEvent extends LuckPermsEvent {
+
+ /**
+ * Gets the user whose data was loaded
+ *
+ * @return the user
+ */
+ User getUser();
+
+ /**
+ * Gets the data that was loaded
+ *
+ * @return the loaded data
+ */
+ UserData getLoadedData();
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/UserDataRecalculateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserDataRecalculateEvent.java
new file mode 100644
index 000000000..3f63483e3
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserDataRecalculateEvent.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.user;
+
+import me.lucko.luckperms.api.User;
+import me.lucko.luckperms.api.caching.UserData;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+
+/**
+ * Called when a users cached data is refreshed
+ */
+public interface UserDataRecalculateEvent extends LuckPermsEvent {
+
+ /**
+ * Gets the user whose data was recalculated
+ *
+ * @return the user
+ */
+ User getUser();
+
+ /**
+ * Gets the data that was recalculated
+ *
+ * @return the data
+ */
+ UserData getData();
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/events/UserFirstLoginEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserFirstLoginEvent.java
similarity index 71%
rename from api/src/main/java/me/lucko/luckperms/api/event/events/UserFirstLoginEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/user/UserFirstLoginEvent.java
index 00905779a..431746c57 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/events/UserFirstLoginEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserFirstLoginEvent.java
@@ -20,35 +20,37 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.api.event.events;
+package me.lucko.luckperms.api.event.user;
-import me.lucko.luckperms.api.event.LPEvent;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
import java.util.UUID;
/**
- * Called when the user logs into the network for the first time. Particularly useful for networks with multiple
- * lobbies, who want to welcome a user when they join for the first time.
+ * Called when the user logs into the network for the first time.
+ *
+ *
Particularly useful for networks with multiple
+ * lobbies, who want to welcome a user when they join for the first time.
*
*
This event is fired before the player has actually joined the game on the async login / auth event. If you want to
- * do something with the user, store the UUID in a set, and then check the set in the PlayerJoinEvent o.e.
+ * do something with the user, store the UUID in a set, and then check the set in the PlayerJoinEvent o.e.
+ *
+ *
The users data will not be loaded when this event is called.
*/
-public class UserFirstLoginEvent extends LPEvent {
+public interface UserFirstLoginEvent extends LuckPermsEvent {
- private final UUID uuid;
- private final String username;
+ /**
+ * Gets the UUID of the user
+ *
+ * @return the uuid of the user
+ */
+ UUID getUuid();
- public UserFirstLoginEvent(UUID uuid, String username) {
- super("User First Join Event");
- this.uuid = uuid;
- this.username = username;
- }
+ /**
+ * Gets the username of the user
+ *
+ * @return the username of the user
+ */
+ String getUsername();
- public UUID getUuid() {
- return uuid;
- }
-
- public String getUsername() {
- return username;
- }
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/events/UserDemoteEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoadEvent.java
similarity index 76%
rename from api/src/main/java/me/lucko/luckperms/api/event/events/UserDemoteEvent.java
rename to api/src/main/java/me/lucko/luckperms/api/event/user/UserLoadEvent.java
index acaed456e..3295b2276 100644
--- a/api/src/main/java/me/lucko/luckperms/api/event/events/UserDemoteEvent.java
+++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoadEvent.java
@@ -20,19 +20,21 @@
* SOFTWARE.
*/
-package me.lucko.luckperms.api.event.events;
+package me.lucko.luckperms.api.event.user;
-import me.lucko.luckperms.api.Track;
import me.lucko.luckperms.api.User;
-import me.lucko.luckperms.api.event.TrackEvent;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
/**
- * Called whenever a user is demoted down a track
+ * Called when a user is loaded into memory from the storage.
*/
-public class UserDemoteEvent extends TrackEvent {
+public interface UserLoadEvent extends LuckPermsEvent {
- public UserDemoteEvent(Track track, User user, String from, String to) {
- super("User Demote Event", track, user, from, to);
- }
+ /**
+ * Gets the user that was loaded
+ *
+ * @return the user that was loaded
+ */
+ User getUser();
}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/track/TrackAction.java b/api/src/main/java/me/lucko/luckperms/api/event/user/track/TrackAction.java
new file mode 100644
index 000000000..5af37a76e
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/user/track/TrackAction.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.user.track;
+
+/**
+ * Represents the type of action performed in a {@link UserTrackEvent}
+ */
+public enum TrackAction {
+
+ /**
+ * The user was promoted up a track
+ */
+ PROMOTION,
+
+ /**
+ * The user was demoted down a track
+ */
+ DEMOTION;
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserDemoteEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserDemoteEvent.java
new file mode 100644
index 000000000..52f873c59
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserDemoteEvent.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.user.track;
+
+/**
+ * Called when a user is demoted down a track.
+ *
+ *
{@link #getAction()} is always {@link TrackAction#DEMOTION}
+ */
+public interface UserDemoteEvent extends UserTrackEvent {
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserPromoteEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserPromoteEvent.java
new file mode 100644
index 000000000..b48adaafe
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserPromoteEvent.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.user.track;
+
+/**
+ * Called when a user is promoted up a track.
+ *
+ *
{@link #getAction()} is always {@link TrackAction#PROMOTION}
+ */
+public interface UserPromoteEvent extends UserTrackEvent {
+
+}
diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserTrackEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserTrackEvent.java
new file mode 100644
index 000000000..43dfd7344
--- /dev/null
+++ b/api/src/main/java/me/lucko/luckperms/api/event/user/track/UserTrackEvent.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2016 Lucko (Luck)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.lucko.luckperms.api.event.user.track;
+
+import me.lucko.luckperms.api.Track;
+import me.lucko.luckperms.api.User;
+import me.lucko.luckperms.api.event.LuckPermsEvent;
+
+import java.util.Optional;
+
+/**
+ * Called when a user interacts with a track through a promotion or demotion
+ */
+public interface UserTrackEvent extends LuckPermsEvent {
+
+ /**
+ * Gets the track involved in the event
+ *
+ * @return the track involved in the event
+ */
+ Track getTrack();
+
+ /**
+ * Gets the user who was promoted or demoted
+ *
+ * @return the user involved in the event
+ */
+ User getUser();
+
+ /**
+ * Gets the action performed
+ *
+ * @return the action performed
+ */
+ TrackAction getAction();
+
+ /**
+ * Gets the group the user was promoted/demoted from.
+ *
+ *
May be {@link Optional#empty()} if the user wasn't already placed on the track.
+ *
+ * @return the group the user was promoted/demoted from
+ */
+ Optional getGroupFrom();
+
+ /**
+ * Gets the group the user was promoted/demoted to
+ *
+ * @return the group the user was promoted/demoted to
+ */
+ Optional getGroupTo();
+
+}
diff --git a/bukkit-legacy/pom.xml b/bukkit-legacy/pom.xml
index 8c5f009a9..d94404560 100644
--- a/bukkit-legacy/pom.xml
+++ b/bukkit-legacy/pom.xml
@@ -5,7 +5,7 @@
luckpermsme.lucko.luckperms
- 2.17-SNAPSHOT
+ 3.0-SNAPSHOT4.0.0
diff --git a/bukkit-placeholders/pom.xml b/bukkit-placeholders/pom.xml
index 9db9eb8fd..e0adab80b 100644
--- a/bukkit-placeholders/pom.xml
+++ b/bukkit-placeholders/pom.xml
@@ -5,7 +5,7 @@
luckpermsme.lucko.luckperms
- 2.17-SNAPSHOT
+ 3.0-SNAPSHOT4.0.0
diff --git a/bukkit/pom.xml b/bukkit/pom.xml
index 2743189b7..ffbb4823a 100644
--- a/bukkit/pom.xml
+++ b/bukkit/pom.xml
@@ -5,7 +5,7 @@
luckpermsme.lucko.luckperms
- 2.17-SNAPSHOT
+ 3.0-SNAPSHOT4.0.0
diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java
index 79c2e5855..6d1681152 100644
--- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java
+++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java
@@ -246,14 +246,13 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
uuidCache = new UuidCache(this);
userManager = new GenericUserManager(this);
groupManager = new GenericGroupManager(this);
- trackManager = new GenericTrackManager();
+ trackManager = new GenericTrackManager(this);
importer = new Importer(commandManager);
calculatorFactory = new BukkitCalculatorFactory(this);
cachedStateManager = new CachedStateManager(this);
contextManager = new ContextManager<>();
worldCalculator = new WorldCalculator(this);
- pm.registerEvents(worldCalculator, this);
contextManager.registerCalculator(worldCalculator);
contextManager.registerCalculator(new ServerCalculator<>(getConfiguration()));
diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/WorldCalculator.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/WorldCalculator.java
index 8ea99858c..5c022fd89 100644
--- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/WorldCalculator.java
+++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/WorldCalculator.java
@@ -32,12 +32,11 @@ import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import org.bukkit.entity.Player;
-import org.bukkit.event.Listener;
import java.util.Map;
@RequiredArgsConstructor
-public class WorldCalculator extends ContextCalculator implements Listener {
+public class WorldCalculator implements ContextCalculator {
private static final String WORLD_KEY = "world";
private final LuckPermsPlugin plugin;
diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java
index 6a7e47e68..50616c4ef 100644
--- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java
+++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java
@@ -30,6 +30,7 @@ import de.bananaco.bpermissions.api.World;
import de.bananaco.bpermissions.api.WorldManager;
import me.lucko.luckperms.api.MetaUtils;
+import me.lucko.luckperms.api.event.cause.CreationCause;
import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.SubCommand;
@@ -114,7 +115,7 @@ public class MigrationBPermissions extends SubCommand