From b8466beee55074fbf793f872bbd2b7deadf5cf23 Mon Sep 17 00:00:00 2001 From: Luck Date: Thu, 9 Aug 2018 22:39:33 +0100 Subject: [PATCH] Completely rework event system * Event instances are now generated dynamically at runtime. The performance hit of creating proxies at runtime is negligible in this case. * A better EventBus implementation is now being used internally, API contracts are unaffected. --- .../luckperms/api/event/Cancellable.java | 1 + .../me/lucko/luckperms/api/event/Param.java | 35 ++-- .../me/lucko/luckperms/api/event/Sourced.java | 1 + .../api/event/group/GroupCacheLoadEvent.java | 3 + .../api/event/group/GroupCreateEvent.java | 3 + .../group/GroupDataRecalculateEvent.java | 3 + .../api/event/group/GroupDeleteEvent.java | 4 + .../api/event/group/GroupLoadEvent.java | 2 + .../api/event/log/LogBroadcastEvent.java | 3 + .../api/event/log/LogNetworkPublishEvent.java | 3 + .../api/event/log/LogNotifyEvent.java | 4 + .../api/event/log/LogPublishEvent.java | 2 + .../api/event/log/LogReceiveEvent.java | 3 + .../api/event/node/NodeAddEvent.java | 2 + .../api/event/node/NodeMutateEvent.java | 14 +- .../api/event/node/NodeRemoveEvent.java | 2 + .../api/event/player/PlayerDataSaveEvent.java | 4 + .../api/event/sync/PreNetworkSyncEvent.java | 2 + .../api/event/track/TrackCreateEvent.java | 3 + .../api/event/track/TrackDeleteEvent.java | 4 + .../api/event/track/TrackLoadEvent.java | 2 + .../track/mutate/TrackAddGroupEvent.java | 3 + .../event/track/mutate/TrackMutateEvent.java | 4 + .../track/mutate/TrackRemoveGroupEvent.java | 3 + .../api/event/user/UserCacheLoadEvent.java | 3 + .../event/user/UserDataRecalculateEvent.java | 3 + .../api/event/user/UserFirstLoginEvent.java | 3 + .../api/event/user/UserLoadEvent.java | 2 + .../api/event/user/UserLoginProcessEvent.java | 5 + .../api/event/user/track/UserDemoteEvent.java | 7 + .../event/user/track/UserPromoteEvent.java | 7 + .../api/event/user/track/UserTrackEvent.java | 5 + bukkit/pom.xml | 4 + .../luckperms/bukkit/LPBukkitPlugin.java | 2 +- bungee/pom.xml | 4 + .../luckperms/bungee/LPBungeePlugin.java | 2 +- common/pom.xml | 18 ++ .../common/dependencies/Dependency.java | 7 + .../common/event/AbstractEventBus.java | 158 +++++--------- .../luckperms/common/event/EventFactory.java | 197 ++++++++---------- .../common/event/LuckPermsEventHandler.java | 11 +- .../common/event/gen/GeneratedEventSpec.java | 163 +++++++++++++++ .../common/event/impl/EventConfigReload.java | 37 ---- .../event/impl/EventGroupCacheLoad.java | 61 ------ .../common/event/impl/EventGroupCreate.java | 61 ------ .../event/impl/EventGroupDataRecalculate.java | 61 ------ .../common/event/impl/EventGroupDelete.java | 74 ------- .../common/event/impl/EventGroupLoad.java | 52 ----- .../common/event/impl/EventGroupLoadAll.java | 37 ---- .../common/event/impl/EventLogBroadcast.java | 73 ------- .../event/impl/EventLogNetworkPublish.java | 74 ------- .../common/event/impl/EventLogNotify.java | 91 -------- .../common/event/impl/EventLogPublish.java | 62 ------ .../common/event/impl/EventLogReceive.java | 62 ------ .../common/event/impl/EventNodeAdd.java | 95 --------- .../common/event/impl/EventNodeClear.java | 86 -------- .../common/event/impl/EventNodeRemove.java | 95 --------- .../event/impl/EventPlayerDataSave.java | 72 ------- .../common/event/impl/EventPostSync.java | 37 ---- .../event/impl/EventPreNetworkSync.java | 64 ------ .../common/event/impl/EventPreSync.java | 53 ----- .../common/event/impl/EventTrackAddGroup.java | 82 -------- .../common/event/impl/EventTrackClear.java | 73 ------- .../common/event/impl/EventTrackCreate.java | 61 ------ .../common/event/impl/EventTrackDelete.java | 73 ------- .../common/event/impl/EventTrackLoad.java | 52 ----- .../common/event/impl/EventTrackLoadAll.java | 37 ---- .../event/impl/EventTrackRemoveGroup.java | 82 -------- .../common/event/impl/EventUserCacheLoad.java | 61 ------ .../event/impl/EventUserDataRecalculate.java | 61 ------ .../common/event/impl/EventUserDemote.java | 103 --------- .../event/impl/EventUserFirstLogin.java | 61 ------ .../common/event/impl/EventUserLoad.java | 52 ----- .../event/impl/EventUserLoginProcess.java | 69 ------ .../common/event/impl/EventUserPromote.java | 103 --------- nukkit/pom.xml | 4 + .../luckperms/nukkit/LPNukkitPlugin.java | 2 +- sponge/pom.xml | 4 + .../luckperms/sponge/LPSpongePlugin.java | 2 +- 79 files changed, 486 insertions(+), 2454 deletions(-) rename common/src/main/java/me/lucko/luckperms/common/event/AbstractEvent.java => api/src/main/java/me/lucko/luckperms/api/event/Param.java (69%) create mode 100644 common/src/main/java/me/lucko/luckperms/common/event/gen/GeneratedEventSpec.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventConfigReload.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupCacheLoad.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupCreate.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupDataRecalculate.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupDelete.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupLoad.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupLoadAll.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogBroadcast.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNetworkPublish.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNotify.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogPublish.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogReceive.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeAdd.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeClear.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeRemove.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventPlayerDataSave.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventPostSync.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventPreNetworkSync.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventPreSync.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackAddGroup.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackClear.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackCreate.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackDelete.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackLoad.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackLoadAll.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackRemoveGroup.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserCacheLoad.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserDataRecalculate.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserDemote.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserFirstLogin.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserLoad.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserLoginProcess.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserPromote.java diff --git a/api/src/main/java/me/lucko/luckperms/api/event/Cancellable.java b/api/src/main/java/me/lucko/luckperms/api/event/Cancellable.java index 1d656bc05..fce020ba6 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/Cancellable.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/Cancellable.java @@ -40,6 +40,7 @@ public interface Cancellable { * @return the cancellation */ @Nonnull + @Param(-1) AtomicBoolean getCancellationState(); /** diff --git a/common/src/main/java/me/lucko/luckperms/common/event/AbstractEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/Param.java similarity index 69% rename from common/src/main/java/me/lucko/luckperms/common/event/AbstractEvent.java rename to api/src/main/java/me/lucko/luckperms/api/event/Param.java index 1d91b3977..7d28d41c4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/AbstractEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/Param.java @@ -23,24 +23,27 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.event; +package me.lucko.luckperms.api.event; -import me.lucko.luckperms.api.LuckPermsApi; -import me.lucko.luckperms.api.event.LuckPermsEvent; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; -import javax.annotation.Nonnull; +/** + * Represents the position of a parameter within an event. + * + *

This is an implementation detail and should not be relied upon.

+ */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Param { -public abstract class AbstractEvent implements LuckPermsEvent { + /** + * Gets the index of the parameter. + * + * @return the index + */ + int value(); - private LuckPermsApi api = null; - - @Nonnull - @Override - public LuckPermsApi getApi() { - return this.api; - } - - void setApi(LuckPermsApi api) { - this.api = api; - } } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/Sourced.java b/api/src/main/java/me/lucko/luckperms/api/event/Sourced.java index c1ec7a30c..16a75678a 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/Sourced.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/Sourced.java @@ -45,6 +45,7 @@ public interface Sourced { * @return the source */ @Nonnull + @Param(-1) Source getSource(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCacheLoadEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCacheLoadEvent.java index 8a7c86199..94db18488 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCacheLoadEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupCacheLoadEvent.java @@ -28,6 +28,7 @@ package me.lucko.luckperms.api.event.group; import me.lucko.luckperms.api.Group; import me.lucko.luckperms.api.caching.GroupData; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import javax.annotation.Nonnull; @@ -44,6 +45,7 @@ public interface GroupCacheLoadEvent extends LuckPermsEvent { * @return the group */ @Nonnull + @Param(0) Group getGroup(); /** @@ -52,6 +54,7 @@ public interface GroupCacheLoadEvent extends LuckPermsEvent { * @return the loaded data */ @Nonnull + @Param(1) GroupData getLoadedData(); } 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 index 01a8c86fe..885264e3e 100644 --- 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 @@ -27,6 +27,7 @@ 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.Param; import me.lucko.luckperms.api.event.cause.CreationCause; import javax.annotation.Nonnull; @@ -42,6 +43,7 @@ public interface GroupCreateEvent extends LuckPermsEvent { * @return the new group */ @Nonnull + @Param(0) Group getGroup(); /** @@ -50,6 +52,7 @@ public interface GroupCreateEvent extends LuckPermsEvent { * @return the cause of the creation */ @Nonnull + @Param(1) CreationCause getCause(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDataRecalculateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDataRecalculateEvent.java index cf270b451..9afde7c47 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDataRecalculateEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDataRecalculateEvent.java @@ -28,6 +28,7 @@ package me.lucko.luckperms.api.event.group; import me.lucko.luckperms.api.Group; import me.lucko.luckperms.api.caching.GroupData; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import javax.annotation.Nonnull; @@ -44,6 +45,7 @@ public interface GroupDataRecalculateEvent extends LuckPermsEvent { * @return the group */ @Nonnull + @Param(0) Group getGroup(); /** @@ -52,6 +54,7 @@ public interface GroupDataRecalculateEvent extends LuckPermsEvent { * @return the data */ @Nonnull + @Param(1) GroupData getData(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDeleteEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDeleteEvent.java index 48fe48576..a9fa994d4 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDeleteEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupDeleteEvent.java @@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.group; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import me.lucko.luckperms.api.event.cause.DeletionCause; import java.util.Set; @@ -44,6 +45,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent { * @return the name of the deleted group */ @Nonnull + @Param(0) String getGroupName(); /** @@ -52,6 +54,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent { * @return a copy of the groups existing data */ @Nonnull + @Param(1) Set getExistingData(); /** @@ -60,6 +63,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent { * @return the cause of the deletion */ @Nonnull + @Param(2) DeletionCause getCause(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadEvent.java index eb414f6e4..b6dbc0c21 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/group/GroupLoadEvent.java @@ -27,6 +27,7 @@ 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.Param; import javax.annotation.Nonnull; @@ -43,6 +44,7 @@ public interface GroupLoadEvent extends LuckPermsEvent { * @return the group that was loaded */ @Nonnull + @Param(0) Group getGroup(); } 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 index 8a4f0e6d7..81188d333 100644 --- 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 @@ -28,6 +28,7 @@ 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; +import me.lucko.luckperms.api.event.Param; import javax.annotation.Nonnull; @@ -42,6 +43,7 @@ public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable { * @return the log entry to be broadcasted */ @Nonnull + @Param(0) LogEntry getEntry(); /** @@ -51,6 +53,7 @@ public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable { * @since 3.3 */ @Nonnull + @Param(1) Origin getOrigin(); /** diff --git a/api/src/main/java/me/lucko/luckperms/api/event/log/LogNetworkPublishEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/log/LogNetworkPublishEvent.java index 54e4895c9..e0b2af094 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/log/LogNetworkPublishEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/log/LogNetworkPublishEvent.java @@ -28,6 +28,7 @@ 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; +import me.lucko.luckperms.api.event.Param; import java.util.UUID; @@ -46,6 +47,7 @@ public interface LogNetworkPublishEvent extends LuckPermsEvent, Cancellable { * @return the id of the log entry being published */ @Nonnull + @Param(0) UUID getLogId(); /** @@ -54,6 +56,7 @@ public interface LogNetworkPublishEvent extends LuckPermsEvent, Cancellable { * @return the log entry to be published */ @Nonnull + @Param(1) LogEntry getEntry(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/log/LogNotifyEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/log/LogNotifyEvent.java index 299bcf2b2..e7e5fc39a 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/log/LogNotifyEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/log/LogNotifyEvent.java @@ -29,6 +29,7 @@ import me.lucko.luckperms.api.Entity; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.event.Cancellable; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import javax.annotation.Nonnull; @@ -50,6 +51,7 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable { * @return the log entry to be sent */ @Nonnull + @Param(0) LogEntry getEntry(); /** @@ -58,6 +60,7 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable { * @return the origin of the log */ @Nonnull + @Param(1) Origin getOrigin(); /** @@ -66,6 +69,7 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable { * @return the object to notify */ @Nonnull + @Param(2) Entity getNotifiable(); /** diff --git a/api/src/main/java/me/lucko/luckperms/api/event/log/LogPublishEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/log/LogPublishEvent.java index 15c2a990e..9298a395e 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/log/LogPublishEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/log/LogPublishEvent.java @@ -28,6 +28,7 @@ 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; +import me.lucko.luckperms.api.event.Param; import javax.annotation.Nonnull; @@ -42,6 +43,7 @@ public interface LogPublishEvent extends LuckPermsEvent, Cancellable { * @return the log entry to be published */ @Nonnull + @Param(0) LogEntry getEntry(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/log/LogReceiveEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/log/LogReceiveEvent.java index 0752aa67e..d107649fc 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/log/LogReceiveEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/log/LogReceiveEvent.java @@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.log; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import java.util.UUID; @@ -45,6 +46,7 @@ public interface LogReceiveEvent extends LuckPermsEvent { * @return the id of the log entry being received */ @Nonnull + @Param(0) UUID getLogId(); /** @@ -53,6 +55,7 @@ public interface LogReceiveEvent extends LuckPermsEvent { * @return the log entry being received */ @Nonnull + @Param(1) LogEntry getEntry(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/node/NodeAddEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeAddEvent.java index 5944c5f93..544101d9b 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/node/NodeAddEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/node/NodeAddEvent.java @@ -26,6 +26,7 @@ package me.lucko.luckperms.api.event.node; import me.lucko.luckperms.api.Node; +import me.lucko.luckperms.api.event.Param; import javax.annotation.Nonnull; @@ -40,6 +41,7 @@ public interface NodeAddEvent extends NodeMutateEvent { * @return the node that was added */ @Nonnull + @Param(3) Node getNode(); } 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 index 293147456..405005b07 100644 --- 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 @@ -25,9 +25,12 @@ package me.lucko.luckperms.api.event.node; +import me.lucko.luckperms.api.Group; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.PermissionHolder; +import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import java.util.Set; @@ -44,6 +47,7 @@ public interface NodeMutateEvent extends LuckPermsEvent { * @return the event target */ @Nonnull + @Param(0) PermissionHolder getTarget(); /** @@ -52,6 +56,7 @@ public interface NodeMutateEvent extends LuckPermsEvent { * @return the data before the change */ @Nonnull + @Param(1) Set getDataBefore(); /** @@ -60,6 +65,7 @@ public interface NodeMutateEvent extends LuckPermsEvent { * @return the data after the change */ @Nonnull + @Param(2) Set getDataAfter(); /** @@ -69,7 +75,9 @@ public interface NodeMutateEvent extends LuckPermsEvent { * * @return if the event is targeting a user */ - boolean isUser(); + default boolean isUser() { + return getTarget() instanceof User; + } /** * Gets whether the target of this event is a {@link me.lucko.luckperms.api.Group} @@ -78,6 +86,8 @@ public interface NodeMutateEvent extends LuckPermsEvent { * * @return if the event is targeting a group */ - boolean isGroup(); + default boolean isGroup() { + return getTarget() instanceof Group; + } } 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 index 8e2becbfa..2d04c7cc4 100644 --- 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 @@ -26,6 +26,7 @@ package me.lucko.luckperms.api.event.node; import me.lucko.luckperms.api.Node; +import me.lucko.luckperms.api.event.Param; import javax.annotation.Nonnull; @@ -40,6 +41,7 @@ public interface NodeRemoveEvent extends NodeMutateEvent { * @return the node that was removed */ @Nonnull + @Param(3) Node getNode(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/player/PlayerDataSaveEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/player/PlayerDataSaveEvent.java index 5d6b5ee40..cb2801381 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/player/PlayerDataSaveEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/player/PlayerDataSaveEvent.java @@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.player; import me.lucko.luckperms.api.PlayerSaveResult; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import me.lucko.luckperms.api.manager.UserManager; import java.util.UUID; @@ -48,6 +49,7 @@ public interface PlayerDataSaveEvent extends LuckPermsEvent { * @return the uuid */ @Nonnull + @Param(0) UUID getUuid(); /** @@ -56,6 +58,7 @@ public interface PlayerDataSaveEvent extends LuckPermsEvent { * @return the username */ @Nonnull + @Param(1) String getUsername(); /** @@ -64,6 +67,7 @@ public interface PlayerDataSaveEvent extends LuckPermsEvent { * @return the result */ @Nonnull + @Param(2) PlayerSaveResult getResult(); } 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 index a5241964b..9f67c7696 100644 --- 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 @@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.sync; import me.lucko.luckperms.api.event.Cancellable; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import java.util.UUID; @@ -43,6 +44,7 @@ public interface PreNetworkSyncEvent extends LuckPermsEvent, Cancellable { * @return the id of the sync request */ @Nonnull + @Param(0) UUID getSyncId(); } 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 index 816b7ac20..24fdc73cf 100644 --- 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 @@ -27,6 +27,7 @@ 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.Param; import me.lucko.luckperms.api.event.cause.CreationCause; import javax.annotation.Nonnull; @@ -42,6 +43,7 @@ public interface TrackCreateEvent extends LuckPermsEvent { * @return the new track */ @Nonnull + @Param(0) Track getTrack(); /** @@ -50,6 +52,7 @@ public interface TrackCreateEvent extends LuckPermsEvent { * @return the cause of the creation */ @Nonnull + @Param(1) CreationCause getCause(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/TrackDeleteEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackDeleteEvent.java index 3d753d59f..e9b41bfcd 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/track/TrackDeleteEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/track/TrackDeleteEvent.java @@ -26,6 +26,7 @@ package me.lucko.luckperms.api.event.track; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import me.lucko.luckperms.api.event.cause.DeletionCause; import java.util.List; @@ -43,6 +44,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent { * @return the name of the deleted track */ @Nonnull + @Param(0) String getTrackName(); /** @@ -51,6 +53,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent { * @return a copy of the tracks existing data */ @Nonnull + @Param(1) List getExistingData(); /** @@ -59,6 +62,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent { * @return the cause of the deletion */ @Nonnull + @Param(2) DeletionCause getCause(); } 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 index b53271bd7..368e27aab 100644 --- 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 @@ -27,6 +27,7 @@ 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.Param; import javax.annotation.Nonnull; @@ -43,6 +44,7 @@ public interface TrackLoadEvent extends LuckPermsEvent { * @return the track that was loaded */ @Nonnull + @Param(0) 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 index 76a3294f5..1ace501e5 100644 --- 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 @@ -25,6 +25,8 @@ package me.lucko.luckperms.api.event.track.mutate; +import me.lucko.luckperms.api.event.Param; + import javax.annotation.Nonnull; /** @@ -38,6 +40,7 @@ public interface TrackAddGroupEvent extends TrackMutateEvent { * @return the group that was added */ @Nonnull + @Param(3) String getGroup(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackMutateEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackMutateEvent.java index d9fad7491..145534aff 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackMutateEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/track/mutate/TrackMutateEvent.java @@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.track.mutate; import me.lucko.luckperms.api.Track; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import java.util.List; @@ -43,6 +44,7 @@ public interface TrackMutateEvent extends LuckPermsEvent { * @return the track that was mutated */ @Nonnull + @Param(0) Track getTrack(); /** @@ -51,6 +53,7 @@ public interface TrackMutateEvent extends LuckPermsEvent { * @return the data before the change */ @Nonnull + @Param(1) List getDataBefore(); /** @@ -59,6 +62,7 @@ public interface TrackMutateEvent extends LuckPermsEvent { * @return the data after the change */ @Nonnull + @Param(2) 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 index f582cbd8f..3c6aaec36 100644 --- 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 @@ -25,6 +25,8 @@ package me.lucko.luckperms.api.event.track.mutate; +import me.lucko.luckperms.api.event.Param; + import javax.annotation.Nonnull; /** @@ -38,6 +40,7 @@ public interface TrackRemoveGroupEvent extends TrackMutateEvent { * @return the group that was removed */ @Nonnull + @Param(3) 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 index a3f3b8ad5..be2dcb2f6 100644 --- 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 @@ -28,6 +28,7 @@ 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; +import me.lucko.luckperms.api.event.Param; import javax.annotation.Nonnull; @@ -42,6 +43,7 @@ public interface UserCacheLoadEvent extends LuckPermsEvent { * @return the user */ @Nonnull + @Param(0) User getUser(); /** @@ -50,6 +52,7 @@ public interface UserCacheLoadEvent extends LuckPermsEvent { * @return the loaded data */ @Nonnull + @Param(1) 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 index 354fd6d89..bf57916eb 100644 --- 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 @@ -28,6 +28,7 @@ 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; +import me.lucko.luckperms.api.event.Param; import javax.annotation.Nonnull; @@ -42,6 +43,7 @@ public interface UserDataRecalculateEvent extends LuckPermsEvent { * @return the user */ @Nonnull + @Param(0) User getUser(); /** @@ -50,6 +52,7 @@ public interface UserDataRecalculateEvent extends LuckPermsEvent { * @return the data */ @Nonnull + @Param(1) UserData getData(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/UserFirstLoginEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserFirstLoginEvent.java index 0807e9d25..2f2068b28 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/user/UserFirstLoginEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserFirstLoginEvent.java @@ -26,6 +26,7 @@ package me.lucko.luckperms.api.event.user; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import java.util.UUID; @@ -50,6 +51,7 @@ public interface UserFirstLoginEvent extends LuckPermsEvent { * @return the uuid of the user */ @Nonnull + @Param(0) UUID getUuid(); /** @@ -58,6 +60,7 @@ public interface UserFirstLoginEvent extends LuckPermsEvent { * @return the username of the user */ @Nonnull + @Param(1) String getUsername(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoadEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoadEvent.java index 847fc7138..f67e94e45 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoadEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoadEvent.java @@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.user; import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import javax.annotation.Nonnull; @@ -41,6 +42,7 @@ public interface UserLoadEvent extends LuckPermsEvent { * @return the user that was loaded */ @Nonnull + @Param(0) User getUser(); } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoginProcessEvent.java b/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoginProcessEvent.java index 739e809ee..c95f5b3d4 100644 --- a/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoginProcessEvent.java +++ b/api/src/main/java/me/lucko/luckperms/api/event/user/UserLoginProcessEvent.java @@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.user; import me.lucko.luckperms.api.User; import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; import java.util.UUID; @@ -52,6 +53,7 @@ public interface UserLoginProcessEvent extends LuckPermsEvent { * @return the uuid of the connection which was processed */ @Nonnull + @Param(0) UUID getUuid(); /** @@ -60,6 +62,7 @@ public interface UserLoginProcessEvent extends LuckPermsEvent { * @return the username of the connection which was processed */ @Nonnull + @Param(1) String getUsername(); /** @@ -67,6 +70,8 @@ public interface UserLoginProcessEvent extends LuckPermsEvent { * * @return the user instance */ + @Nonnull + @Param(2) User getUser(); } 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 index 1402ecf0f..02fd581c3 100644 --- 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 @@ -25,6 +25,8 @@ package me.lucko.luckperms.api.event.user.track; +import javax.annotation.Nonnull; + /** * Called when a user is demoted down a track. * @@ -32,4 +34,9 @@ package me.lucko.luckperms.api.event.user.track; */ public interface UserDemoteEvent extends UserTrackEvent { + @Nonnull + @Override + default TrackAction getAction() { + return TrackAction.DEMOTION; + } } 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 index dce2bfc00..edbcc2421 100644 --- 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 @@ -25,6 +25,8 @@ package me.lucko.luckperms.api.event.user.track; +import javax.annotation.Nonnull; + /** * Called when a user is promoted up a track. * @@ -32,4 +34,9 @@ package me.lucko.luckperms.api.event.user.track; */ public interface UserPromoteEvent extends UserTrackEvent { + @Nonnull + @Override + default TrackAction getAction() { + return TrackAction.PROMOTION; + } } 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 index 4c8ead719..cf3385c50 100644 --- 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 @@ -28,6 +28,7 @@ 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 me.lucko.luckperms.api.event.Param; import me.lucko.luckperms.api.event.Sourced; import java.util.Optional; @@ -45,6 +46,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced { * @return the track involved in the event */ @Nonnull + @Param(0) Track getTrack(); /** @@ -53,6 +55,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced { * @return the user involved in the event */ @Nonnull + @Param(1) User getUser(); /** @@ -71,6 +74,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced { * @return the group the user was promoted/demoted from */ @Nonnull + @Param(2) Optional getGroupFrom(); /** @@ -79,6 +83,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced { * @return the group the user was promoted/demoted to */ @Nonnull + @Param(3) Optional getGroupTo(); } diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 18989f434..d53f998ea 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -66,6 +66,10 @@ net.kyori.text me.lucko.luckperms.lib.text + + net.kyori.event + me.lucko.luckperms.lib.eventbus + com.github.benmanes.caffeine me.lucko.luckperms.lib.caffeine 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 b22c28b37..895cc2542 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java @@ -123,7 +123,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin { @Override protected Set getGlobalDependencies() { - EnumSet dependencies = EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP); + EnumSet dependencies = EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, Dependency.EVENT); if (isBrigadierSupported()) { dependencies.add(Dependency.COMMODORE); } diff --git a/bungee/pom.xml b/bungee/pom.xml index 7c370c3fa..074ebb0e2 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -56,6 +56,10 @@ net.kyori.text me.lucko.luckperms.lib.text + + net.kyori.event + me.lucko.luckperms.lib.eventbus + com.github.benmanes.caffeine me.lucko.luckperms.lib.caffeine diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java index 11183d110..0f21454e4 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java @@ -94,7 +94,7 @@ public class LPBungeePlugin extends AbstractLuckPermsPlugin { @Override protected Set getGlobalDependencies() { - return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP); + return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, Dependency.EVENT); } @Override diff --git a/common/pom.xml b/common/pom.xml index 851014944..c84380089 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -70,6 +70,24 @@ + + + net.kyori + event-api + 2.0.1 + compile + + + org.checkerframework + checker-qual + + + com.google.guava + guava + + + + diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java index c4971e19d..055c7e940 100644 --- a/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java +++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/Dependency.java @@ -67,6 +67,13 @@ public enum Dependency { "drQpwf+oI1+DPrn0iCvEtoID+xXR3dpZK5ySaBrUiok=", Relocation.of("text", "net{}kyori{}text") ), + EVENT( + "net{}kyori", + "event-api", + "2.0.1", + "4XVmowvKHCmO38ZO2jeZKh/mD00xBg73zau79s4kTe4=", + Relocation.of("eventbus", "net{}kyori{}event") + ), CAFFEINE( "com{}github{}ben-manes{}caffeine", "caffeine", diff --git a/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java b/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java index bc0b33875..304abb4b8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java @@ -25,33 +25,26 @@ package me.lucko.luckperms.common.event; -import com.github.benmanes.caffeine.cache.Caffeine; -import com.github.benmanes.caffeine.cache.LoadingCache; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; -import me.lucko.luckperms.api.event.Cancellable; import me.lucko.luckperms.api.event.EventBus; import me.lucko.luckperms.api.event.EventHandler; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.common.api.LuckPermsApiProvider; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.utils.Predicates; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import net.kyori.event.EventSubscriber; +import net.kyori.event.SimpleEventBus; + +import java.util.HashSet; import java.util.Objects; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; +import java.util.function.Predicate; import javax.annotation.Nonnull; -/** - * Simple implementation of EventBus. - */ public abstract class AbstractEventBus

implements EventBus, AutoCloseable { /** @@ -65,26 +58,9 @@ public abstract class AbstractEventBus

implements EventBus, AutoCloseable { private final LuckPermsApiProvider apiProvider; /** - * The registered handlers in this event bus + * The delegate event bus */ - private final Multimap, LuckPermsEventHandler> handlerMap = Multimaps.newSetMultimap(new ConcurrentHashMap<>(), ConcurrentHashMap::newKeySet); - - /** - * A cache of event class --> applicable handlers. - * - * A registered "handler" will be passed all possible events it can handle, according to - * {@link Class#isAssignableFrom(Class)}. - */ - private final LoadingCache, List>> handlerCache = Caffeine.newBuilder() - .build(eventClass -> { - ImmutableList.Builder> matched = ImmutableList.builder(); - AbstractEventBus.this.handlerMap.asMap().forEach((clazz, handlers) -> { - if (clazz.isAssignableFrom(eventClass)) { - matched.addAll(handlers); - } - }); - return matched.build(); - }); + private final Bus bus = new Bus(); protected AbstractEventBus(LuckPermsPlugin plugin, LuckPermsApiProvider apiProvider) { this.plugin = plugin; @@ -95,6 +71,23 @@ public abstract class AbstractEventBus

implements EventBus, AutoCloseable { return this.plugin; } + public LuckPermsApiProvider getApiProvider() { + return this.apiProvider; + } + + /** + * Checks that the given plugin object is a valid plugin instance for the platform + * + * @param plugin the object + * @return a plugin + * @throws IllegalArgumentException if the plugin is invalid + */ + protected abstract P checkPlugin(Object plugin) throws IllegalArgumentException; + + public void post(LuckPermsEvent event) { + this.bus.post(event); + } + @Nonnull @Override public EventHandler subscribe(@Nonnull Class eventClass, @Nonnull Consumer handler) { @@ -112,36 +105,6 @@ public abstract class AbstractEventBus

implements EventBus, AutoCloseable { return registerSubscription(eventClass, handler, checkPlugin(plugin)); } - @Nonnull - @Override - public Set> getHandlers(@Nonnull Class eventClass) { - Collection> handlers = this.handlerMap.asMap().get(eventClass); - ImmutableSet.Builder> ret = ImmutableSet.builder(); - for (LuckPermsEventHandler handler : handlers) { - //noinspection unchecked - ret.add((EventHandler) handler); - } - return ret.build(); - } - - /** - * Checks that the given plugin object is a valid plugin instance for the platform - * - * @param plugin the object - * @return a plugin - * @throws IllegalArgumentException if the plugin is invalid - */ - protected abstract P checkPlugin(Object plugin) throws IllegalArgumentException; - - /** - * Registers a subscription for the given class, handler and plugin - * - * @param eventClass the event class - * @param handler the handler - * @param plugin the plugin, nullable - * @param the event type - * @return the resultant handler - */ private EventHandler registerSubscription(Class eventClass, Consumer handler, Object plugin) { if (!eventClass.isInterface()) { throw new IllegalArgumentException("class " + eventClass + " is not an interface"); @@ -151,20 +114,28 @@ public abstract class AbstractEventBus

implements EventBus, AutoCloseable { } LuckPermsEventHandler eventHandler = new LuckPermsEventHandler<>(this, eventClass, handler, plugin); - this.handlerMap.put(eventClass, eventHandler); - this.handlerCache.invalidateAll(); + this.bus.register(eventClass, eventHandler); return eventHandler; } + @Nonnull + @Override + public Set> getHandlers(@Nonnull Class eventClass) { + Set> handlers = this.bus.getHandlers(); + handlers.removeIf(h -> !h.getEventClass().isAssignableFrom(eventClass)); + + //noinspection unchecked + return (Set) ImmutableSet.copyOf(handlers); + } + /** * Removes a specific handler from the bus * * @param handler the handler to remove */ public void unregisterHandler(LuckPermsEventHandler handler) { - this.handlerMap.remove(handler.getEventClass(), handler); - this.handlerCache.invalidateAll(); + this.bus.unregister(handler); } /** @@ -173,54 +144,35 @@ public abstract class AbstractEventBus

implements EventBus, AutoCloseable { * @param plugin the plugin */ protected void unregisterHandlers(P plugin) { - List> handlers = new ArrayList<>(this.handlerMap.values()); - for (LuckPermsEventHandler handler : handlers) { - if (handler.getPlugin() == plugin) { - handler.unregister(); - } - } + this.bus.unregisterMatching(sub -> ((LuckPermsEventHandler) sub).getPlugin() == plugin); } - /** - * Unregisters all handlers in this event bus - */ @Override public void close() { - List> handlers = new ArrayList<>(this.handlerMap.values()); - for (LuckPermsEventHandler handler : handlers) { - handler.unregister(); - } + this.bus.unregisterAll(); } - /** - * Fires the given event to all registered handlers in this event bus - * - * @param event the event to fire - */ - public void fireEvent(LuckPermsEvent event) { - if (event instanceof AbstractEvent) { - ((AbstractEvent) event).setApi(this.apiProvider); + private static final class Bus extends SimpleEventBus { + + @Override + public void unregisterMatching(@Nonnull Predicate> predicate) { + super.unregisterMatching(predicate); } - List> handlers = this.handlerCache.get(event.getClass()); - if (handlers == null) { - return; + public void unregisterAll() { + unregisterMatching(Predicates.alwaysTrue()); } - for (LuckPermsEventHandler handler : handlers) { - handler.handle(event); - } - } + public Set> getHandlers() { + Set> handlers = new HashSet<>(); - /** - * Fires the given event asynchronously to all registered handlers in this event bus - * - * @param event the event to fire - */ - public void fireEventAsync(LuckPermsEvent event) { - if (event instanceof Cancellable) { - throw new IllegalArgumentException("cannot call Cancellable event async"); + // bit of a hack + unregisterMatching(sub -> { + handlers.add((LuckPermsEventHandler) sub); + return false; + }); + + return handlers; } - this.plugin.getBootstrap().getScheduler().executeAsync(() -> fireEvent(event)); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java b/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java index 4d224d1f0..a8319c3d8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java @@ -33,47 +33,47 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.PlayerSaveResult; import me.lucko.luckperms.api.caching.GroupData; import me.lucko.luckperms.api.caching.UserData; +import me.lucko.luckperms.api.event.Cancellable; import me.lucko.luckperms.api.event.LuckPermsEvent; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.api.event.cause.DeletionCause; +import me.lucko.luckperms.api.event.group.GroupCacheLoadEvent; +import me.lucko.luckperms.api.event.group.GroupCreateEvent; +import me.lucko.luckperms.api.event.group.GroupDataRecalculateEvent; +import me.lucko.luckperms.api.event.group.GroupDeleteEvent; +import me.lucko.luckperms.api.event.group.GroupLoadAllEvent; +import me.lucko.luckperms.api.event.group.GroupLoadEvent; import me.lucko.luckperms.api.event.log.LogBroadcastEvent; +import me.lucko.luckperms.api.event.log.LogNetworkPublishEvent; import me.lucko.luckperms.api.event.log.LogNotifyEvent; +import me.lucko.luckperms.api.event.log.LogPublishEvent; +import me.lucko.luckperms.api.event.log.LogReceiveEvent; +import me.lucko.luckperms.api.event.node.NodeAddEvent; +import me.lucko.luckperms.api.event.node.NodeClearEvent; +import me.lucko.luckperms.api.event.node.NodeRemoveEvent; +import me.lucko.luckperms.api.event.player.PlayerDataSaveEvent; import me.lucko.luckperms.api.event.source.Source; +import me.lucko.luckperms.api.event.sync.ConfigReloadEvent; +import me.lucko.luckperms.api.event.sync.PostSyncEvent; +import me.lucko.luckperms.api.event.sync.PreNetworkSyncEvent; +import me.lucko.luckperms.api.event.sync.PreSyncEvent; +import me.lucko.luckperms.api.event.track.TrackCreateEvent; +import me.lucko.luckperms.api.event.track.TrackDeleteEvent; +import me.lucko.luckperms.api.event.track.TrackLoadAllEvent; +import me.lucko.luckperms.api.event.track.TrackLoadEvent; +import me.lucko.luckperms.api.event.track.mutate.TrackAddGroupEvent; +import me.lucko.luckperms.api.event.track.mutate.TrackClearEvent; +import me.lucko.luckperms.api.event.track.mutate.TrackRemoveGroupEvent; +import me.lucko.luckperms.api.event.user.UserCacheLoadEvent; +import me.lucko.luckperms.api.event.user.UserDataRecalculateEvent; +import me.lucko.luckperms.api.event.user.UserFirstLoginEvent; +import me.lucko.luckperms.api.event.user.UserLoadEvent; +import me.lucko.luckperms.api.event.user.UserLoginProcessEvent; +import me.lucko.luckperms.api.event.user.track.UserDemoteEvent; +import me.lucko.luckperms.api.event.user.track.UserPromoteEvent; import me.lucko.luckperms.common.api.delegates.model.ApiPermissionHolder; import me.lucko.luckperms.common.api.delegates.model.ApiUser; -import me.lucko.luckperms.common.event.impl.EventConfigReload; -import me.lucko.luckperms.common.event.impl.EventGroupCacheLoad; -import me.lucko.luckperms.common.event.impl.EventGroupCreate; -import me.lucko.luckperms.common.event.impl.EventGroupDataRecalculate; -import me.lucko.luckperms.common.event.impl.EventGroupDelete; -import me.lucko.luckperms.common.event.impl.EventGroupLoad; -import me.lucko.luckperms.common.event.impl.EventGroupLoadAll; -import me.lucko.luckperms.common.event.impl.EventLogBroadcast; -import me.lucko.luckperms.common.event.impl.EventLogNetworkPublish; -import me.lucko.luckperms.common.event.impl.EventLogNotify; -import me.lucko.luckperms.common.event.impl.EventLogPublish; -import me.lucko.luckperms.common.event.impl.EventLogReceive; -import me.lucko.luckperms.common.event.impl.EventNodeAdd; -import me.lucko.luckperms.common.event.impl.EventNodeClear; -import me.lucko.luckperms.common.event.impl.EventNodeRemove; -import me.lucko.luckperms.common.event.impl.EventPlayerDataSave; -import me.lucko.luckperms.common.event.impl.EventPostSync; -import me.lucko.luckperms.common.event.impl.EventPreNetworkSync; -import me.lucko.luckperms.common.event.impl.EventPreSync; -import me.lucko.luckperms.common.event.impl.EventTrackAddGroup; -import me.lucko.luckperms.common.event.impl.EventTrackClear; -import me.lucko.luckperms.common.event.impl.EventTrackCreate; -import me.lucko.luckperms.common.event.impl.EventTrackDelete; -import me.lucko.luckperms.common.event.impl.EventTrackLoad; -import me.lucko.luckperms.common.event.impl.EventTrackLoadAll; -import me.lucko.luckperms.common.event.impl.EventTrackRemoveGroup; -import me.lucko.luckperms.common.event.impl.EventUserCacheLoad; -import me.lucko.luckperms.common.event.impl.EventUserDataRecalculate; -import me.lucko.luckperms.common.event.impl.EventUserDemote; -import me.lucko.luckperms.common.event.impl.EventUserFirstLogin; -import me.lucko.luckperms.common.event.impl.EventUserLoad; -import me.lucko.luckperms.common.event.impl.EventUserLoginProcess; -import me.lucko.luckperms.common.event.impl.EventUserPromote; +import me.lucko.luckperms.common.event.gen.GeneratedEventSpec; import me.lucko.luckperms.common.event.model.EntitySourceImpl; import me.lucko.luckperms.common.event.model.SenderEntity; import me.lucko.luckperms.common.event.model.UnknownSource; @@ -85,15 +85,17 @@ import me.lucko.luckperms.common.sender.Sender; import java.util.Collection; import java.util.List; +import java.util.Optional; import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Supplier; import javax.annotation.Nullable; public final class EventFactory { - private final AbstractEventBus eventBus; + private final AbstractEventBus eventBus; - public EventFactory(AbstractEventBus eventBus) { + public EventFactory(AbstractEventBus eventBus) { this.eventBus = eventBus; } @@ -101,193 +103,174 @@ public final class EventFactory { return this.eventBus; } - private void fireEventAsync(LuckPermsEvent event) { - this.eventBus.fireEventAsync(event); + private void post(LuckPermsEvent event) { + this.eventBus.post(event); } - private void fireEvent(LuckPermsEvent event) { - this.eventBus.fireEvent(event); + private void post(Supplier supplier) { + this.eventBus.getPlugin().getBootstrap().getScheduler().executeAsync(() -> { + LuckPermsEvent event = supplier.get(); + if (event instanceof Cancellable) { + throw new RuntimeException("Cancellable event posted async: " + event); + } + this.eventBus.post(event); + }); + } + + private LuckPermsEvent generate(Class eventClass, Object... params) { + return GeneratedEventSpec.lookup(eventClass).newInstance(this.eventBus.getApiProvider(), params); } public void handleGroupCacheLoad(Group group, GroupData data) { - EventGroupCacheLoad event = new EventGroupCacheLoad(group.getApiDelegate(), data); - fireEventAsync(event); + post(() -> generate(GroupCacheLoadEvent.class, group.getApiDelegate(), data)); } public void handleGroupCreate(Group group, CreationCause cause) { - EventGroupCreate event = new EventGroupCreate(group.getApiDelegate(), cause); - fireEventAsync(event); + post(() -> generate(GroupCreateEvent.class, group.getApiDelegate(), cause)); } public void handleGroupDelete(Group group, DeletionCause cause) { - EventGroupDelete event = new EventGroupDelete(group.getName(), ImmutableSet.copyOf(group.enduringData().immutable().values()), cause); - fireEventAsync(event); + post(() -> generate(GroupDeleteEvent.class, group.getName(), ImmutableSet.copyOf(group.enduringData().immutable().values()), cause)); } public void handleGroupLoadAll() { - EventGroupLoadAll event = new EventGroupLoadAll(); - fireEventAsync(event); + post(() -> generate(GroupLoadAllEvent.class)); } public void handleGroupLoad(Group group) { - EventGroupLoad event = new EventGroupLoad(group.getApiDelegate()); - fireEventAsync(event); + post(() -> generate(GroupLoadEvent.class, group.getApiDelegate())); } public boolean handleLogBroadcast(boolean initialState, LogEntry entry, LogBroadcastEvent.Origin origin) { AtomicBoolean cancel = new AtomicBoolean(initialState); - EventLogBroadcast event = new EventLogBroadcast(cancel, entry, origin); - fireEvent(event); + post(generate(LogBroadcastEvent.class, cancel, entry, origin)); return cancel.get(); } public boolean handleLogPublish(boolean initialState, LogEntry entry) { AtomicBoolean cancel = new AtomicBoolean(initialState); - EventLogPublish event = new EventLogPublish(cancel, entry); - fireEvent(event); + post(generate(LogPublishEvent.class, cancel, entry)); return cancel.get(); } public boolean handleLogNetworkPublish(boolean initialState, UUID id, LogEntry entry) { AtomicBoolean cancel = new AtomicBoolean(initialState); - EventLogNetworkPublish event = new EventLogNetworkPublish(cancel, id, entry); - fireEvent(event); + post(generate(LogNetworkPublishEvent.class, cancel, id, entry)); return cancel.get(); } public boolean handleLogNotify(boolean initialState, LogEntry entry, LogNotifyEvent.Origin origin, Sender sender) { AtomicBoolean cancel = new AtomicBoolean(initialState); - EventLogNotify event = new EventLogNotify(cancel, entry, origin, sender); - fireEvent(event); + post(generate(LogNotifyEvent.class, cancel, entry, origin, new SenderEntity(sender))); return cancel.get(); } public void handleLogReceive(UUID id, LogEntry entry) { - EventLogReceive event = new EventLogReceive(id, entry); - fireEventAsync(event); + post(() -> generate(LogReceiveEvent.class, id, entry)); } public void handleNodeAdd(Node node, PermissionHolder target, Collection before, Collection after) { - EventNodeAdd event = new EventNodeAdd(node, getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after)); - fireEventAsync(event); + post(() -> generate(NodeAddEvent.class, getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after), node)); } public void handleNodeClear(PermissionHolder target, Collection before, Collection after) { - EventNodeClear event = new EventNodeClear(getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after)); - fireEventAsync(event); + post(() -> generate(NodeClearEvent.class, getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after))); } public void handleNodeRemove(Node node, PermissionHolder target, Collection before, Collection after) { - EventNodeRemove event = new EventNodeRemove(node, getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after)); - fireEventAsync(event); + post(() -> generate(NodeRemoveEvent.class, getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after), node)); } public void handleConfigReload() { - EventConfigReload event = new EventConfigReload(); - fireEventAsync(event); + post(() -> generate(ConfigReloadEvent.class)); } public void handlePostSync() { - EventPostSync event = new EventPostSync(); - fireEventAsync(event); + post(() -> generate(PostSyncEvent.class)); } public boolean handleNetworkPreSync(boolean initialState, UUID id) { AtomicBoolean cancel = new AtomicBoolean(initialState); - EventPreNetworkSync event = new EventPreNetworkSync(cancel, id); - fireEvent(event); + post(generate(PreNetworkSyncEvent.class, cancel, id)); return cancel.get(); } public boolean handlePreSync(boolean initialState) { AtomicBoolean cancel = new AtomicBoolean(initialState); - EventPreSync event = new EventPreSync(cancel); - fireEvent(event); + post(generate(PreSyncEvent.class, cancel)); return cancel.get(); } public void handleTrackCreate(Track track, CreationCause cause) { - EventTrackCreate event = new EventTrackCreate(track.getApiDelegate(), cause); - fireEventAsync(event); + post(() -> generate(TrackCreateEvent.class, track.getApiDelegate(), cause)); } public void handleTrackDelete(Track track, DeletionCause cause) { - EventTrackDelete event = new EventTrackDelete(track.getName(), ImmutableList.copyOf(track.getGroups()), cause); - fireEventAsync(event); + post(() -> generate(TrackDeleteEvent.class, track.getName(), ImmutableList.copyOf(track.getGroups()), cause)); } public void handleTrackLoadAll() { - EventTrackLoadAll event = new EventTrackLoadAll(); - fireEventAsync(event); + post(() -> generate(TrackLoadAllEvent.class)); } public void handleTrackLoad(Track track) { - EventTrackLoad event = new EventTrackLoad(track.getApiDelegate()); - fireEventAsync(event); + post(() -> generate(TrackLoadEvent.class, track.getApiDelegate())); } public void handleTrackAddGroup(Track track, String group, List before, List after) { - EventTrackAddGroup event = new EventTrackAddGroup(group, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.copyOf(after)); - fireEventAsync(event); + post(() -> generate(TrackAddGroupEvent.class, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.copyOf(after), group)); } public void handleTrackClear(Track track, List before) { - EventTrackClear event = new EventTrackClear(track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.of()); - fireEventAsync(event); + post(() -> generate(TrackClearEvent.class, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.of())); } public void handleTrackRemoveGroup(Track track, String group, List before, List after) { - EventTrackRemoveGroup event = new EventTrackRemoveGroup(group, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.copyOf(after)); - fireEventAsync(event); + post(() -> generate(TrackRemoveGroupEvent.class, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.copyOf(after), group)); } public void handleUserCacheLoad(User user, UserData data) { - EventUserCacheLoad event = new EventUserCacheLoad(new ApiUser(user), data); - fireEventAsync(event); + post(() -> generate(UserCacheLoadEvent.class, new ApiUser(user), data)); } public void handleDataRecalculate(PermissionHolder holder) { if (holder.getType().isUser()) { User user = (User) holder; - EventUserDataRecalculate event = new EventUserDataRecalculate(user.getApiDelegate(), user.getCachedData()); - fireEventAsync(event); + post(() -> generate(UserDataRecalculateEvent.class, user.getApiDelegate(), user.getCachedData())); } else { Group group = (Group) holder; - EventGroupDataRecalculate event = new EventGroupDataRecalculate(group.getApiDelegate(), group.getCachedData()); - fireEventAsync(event); + post(() -> generate(GroupDataRecalculateEvent.class, group.getApiDelegate(), group.getCachedData())); } } public void handleUserFirstLogin(UUID uuid, String username) { - EventUserFirstLogin event = new EventUserFirstLogin(uuid, username); - fireEventAsync(event); + post(() -> generate(UserFirstLoginEvent.class, uuid, username)); } public void handlePlayerDataSave(UUID uuid, String username, PlayerSaveResult result) { - EventPlayerDataSave event = new EventPlayerDataSave(uuid, username, result); - fireEventAsync(event); + post(() -> generate(PlayerDataSaveEvent.class, uuid, username, result)); } public void handleUserLoad(User user) { - EventUserLoad event = new EventUserLoad(new ApiUser(user)); - fireEventAsync(event); + post(() -> generate(UserLoadEvent.class, new ApiUser(user))); } public void handleUserLoginProcess(UUID uuid, String username, User user) { - EventUserLoginProcess event = new EventUserLoginProcess(uuid, username, new ApiUser(user)); - fireEvent(event); + post(() -> generate(UserLoginProcessEvent.class, uuid, username, new ApiUser(user))); } public void handleUserDemote(User user, Track track, String from, String to, @Nullable Sender source) { - Source s = source == null ? UnknownSource.INSTANCE : new EntitySourceImpl(new SenderEntity(source)); - EventUserDemote event = new EventUserDemote(track.getApiDelegate(), new ApiUser(user), from, to, s); - fireEventAsync(event); + post(() -> { + Source s = source == null ? UnknownSource.INSTANCE : new EntitySourceImpl(new SenderEntity(source)); + return generate(UserDemoteEvent.class, s, track.getApiDelegate(), new ApiUser(user), Optional.ofNullable(from), Optional.ofNullable(to)); + }); } public void handleUserPromote(User user, Track track, String from, String to, @Nullable Sender source) { - Source s = source == null ? UnknownSource.INSTANCE : new EntitySourceImpl(new SenderEntity(source)); - EventUserPromote event = new EventUserPromote(track.getApiDelegate(), new ApiUser(user), from, to, s); - fireEventAsync(event); + post(() -> { + Source s = source == null ? UnknownSource.INSTANCE : new EntitySourceImpl(new SenderEntity(source)); + return generate(UserPromoteEvent.class, s, track.getApiDelegate(), new ApiUser(user), Optional.ofNullable(from), Optional.ofNullable(to)); + }); } private static ApiPermissionHolder getDelegate(PermissionHolder holder) { diff --git a/common/src/main/java/me/lucko/luckperms/common/event/LuckPermsEventHandler.java b/common/src/main/java/me/lucko/luckperms/common/event/LuckPermsEventHandler.java index aa7b94259..656be80c6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/LuckPermsEventHandler.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/LuckPermsEventHandler.java @@ -28,6 +28,8 @@ package me.lucko.luckperms.common.event; import me.lucko.luckperms.api.event.EventHandler; import me.lucko.luckperms.api.event.LuckPermsEvent; +import net.kyori.event.EventSubscriber; + import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; @@ -40,7 +42,7 @@ import javax.annotation.Nullable; * * @param the event type */ -public class LuckPermsEventHandler implements EventHandler { +public class LuckPermsEventHandler implements EventHandler, EventSubscriber { /** * The event bus which created this handler @@ -101,11 +103,10 @@ public class LuckPermsEventHandler implements EventHan return this.callCount.get(); } - @SuppressWarnings("unchecked") // we know that this method will never be called if the class doesn't match eventClass - void handle(LuckPermsEvent event) { + @Override + public void invoke(T event) throws Throwable { try { - T t = (T) event; - this.consumer.accept(t); + this.consumer.accept(event); this.callCount.incrementAndGet(); } catch (Throwable t) { this.eventBus.getPlugin().getLogger().warn("Unable to pass event " + event.getClass().getSimpleName() + " to handler " + this.consumer.getClass().getName()); diff --git a/common/src/main/java/me/lucko/luckperms/common/event/gen/GeneratedEventSpec.java b/common/src/main/java/me/lucko/luckperms/common/event/gen/GeneratedEventSpec.java new file mode 100644 index 000000000..e3f0ff064 --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/event/gen/GeneratedEventSpec.java @@ -0,0 +1,163 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * 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.common.event.gen; + +import com.github.benmanes.caffeine.cache.Caffeine; +import com.github.benmanes.caffeine.cache.LoadingCache; +import com.google.common.collect.ImmutableList; + +import me.lucko.luckperms.api.LuckPermsApi; +import me.lucko.luckperms.api.event.LuckPermsEvent; +import me.lucko.luckperms.api.event.Param; +import me.lucko.luckperms.common.utils.ImmutableCollectors; + +import java.lang.invoke.MethodHandles; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +/** + * Represents the generated specification for an instance of a given {@link LuckPermsEvent}. + */ +public class GeneratedEventSpec { + + private static final Method TO_STRING_METHOD; + private static final Method EQUALS_METHOD; + private static final Method HASHCODE_METHOD; + private static final Method GET_API_METHOD; + static { + try { + TO_STRING_METHOD = Object.class.getMethod("toString"); + EQUALS_METHOD = Object.class.getMethod("equals", Object.class); + HASHCODE_METHOD = Object.class.getMethod("hashCode"); + GET_API_METHOD = LuckPermsEvent.class.getMethod("getApi"); + } catch (NoSuchMethodException e) { + throw new ExceptionInInitializerError(e); + } + } + + private static final LoadingCache, GeneratedEventSpec> CACHE = Caffeine.newBuilder() + .build(GeneratedEventSpec::new); + + public static GeneratedEventSpec lookup(Class event) { + return CACHE.get(event); + } + + private final Class eventClass; + private final List methods; + private final List> returnTypes; + + private GeneratedEventSpec(Class eventClass) { + this.eventClass = eventClass; + + List methods = new ArrayList<>(); + for (Method method : eventClass.getMethods()) { + if (method.isDefault()) { + continue; + } + if (GET_API_METHOD.equals(method)) { + continue; + } + + methods.add(method); + } + methods.sort(Comparator.comparingInt(o -> o.isAnnotationPresent(Param.class) ? o.getAnnotation(Param.class).value() : 0)); + this.methods = ImmutableList.copyOf(methods); + + this.returnTypes = this.methods.stream() + .map(Method::getReturnType) + .collect(ImmutableCollectors.toList()); + } + + public LuckPermsEvent newInstance(LuckPermsApi api, Object... params) { + if (params.length != this.methods.size()) { + throw new IllegalStateException("param length differs from number of methods. expected " + this.methods.size() + " - " + this.methods); + } + + for (int i = 0; i < params.length; i++) { + Object param = params[i]; + Class expectedType = this.returnTypes.get(i); + if (!expectedType.isInstance(param)) { + throw new IllegalArgumentException("Parameter at index " + i + " cannot be assigned to " + expectedType); + } + } + + EventInvocationHandler eventInvocationHandler = new EventInvocationHandler(api, params); + return (LuckPermsEvent) Proxy.newProxyInstance(GeneratedEventSpec.class.getClassLoader(), new Class[]{this.eventClass}, eventInvocationHandler); + } + + /** + * An invocation handler bound to a set of parameters, used to implement the event as a proxy. + */ + private final class EventInvocationHandler implements InvocationHandler { + private final LuckPermsApi api; + private final Object[] fields; + + EventInvocationHandler(LuckPermsApi api, Object[] fields) { + this.api = api; + this.fields = fields; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if (TO_STRING_METHOD.equals(method)) { + return "GeneratedEvent(" + + "proxy=" + proxy + ", " + + "class=" + GeneratedEventSpec.this.eventClass.toString() + ", " + + "fields=" + Arrays.toString(this.fields) + ")"; + } + if (EQUALS_METHOD.equals(method)) { + return proxy == args[0]; + } + if (HASHCODE_METHOD.equals(method)) { + return System.identityHashCode(proxy); + } + if (GET_API_METHOD.equals(method)) { + return this.api; + } + + if (method.getDeclaringClass() == Object.class || method.isDefault()) { + return MethodHandles.lookup() + .in(method.getDeclaringClass()) + .unreflectSpecial(method, method.getDeclaringClass()) + .bindTo(proxy) + .invokeWithArguments(args); + } + + int methodIndex = GeneratedEventSpec.this.methods.indexOf(method); + if (methodIndex == -1) { + throw new UnsupportedOperationException("Method not supported: " + method); + } + + return this.fields[methodIndex]; + } + } + +} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventConfigReload.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventConfigReload.java deleted file mode 100644 index 908c13603..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventConfigReload.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.event.sync.ConfigReloadEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -public class EventConfigReload extends AbstractEvent implements ConfigReloadEvent { - - @Override - public String toString() { - return "ConfigReloadEvent()"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupCacheLoad.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupCacheLoad.java deleted file mode 100644 index 2e421a1e4..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupCacheLoad.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Group; -import me.lucko.luckperms.api.caching.GroupData; -import me.lucko.luckperms.api.event.group.GroupCacheLoadEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import javax.annotation.Nonnull; - -public class EventGroupCacheLoad extends AbstractEvent implements GroupCacheLoadEvent { - - private final Group group; - private final GroupData loadedData; - - public EventGroupCacheLoad(Group group, GroupData loadedData) { - this.group = group; - this.loadedData = loadedData; - } - - @Nonnull - @Override - public Group getGroup() { - return this.group; - } - - @Nonnull - @Override - public GroupData getLoadedData() { - return this.loadedData; - } - - @Override - public String toString() { - return "GroupCacheLoadEvent(group=" + this.getGroup() + ", loadedData=" + this.getLoadedData() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupCreate.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupCreate.java deleted file mode 100644 index 55cab3e34..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupCreate.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Group; -import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.api.event.group.GroupCreateEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import javax.annotation.Nonnull; - -public class EventGroupCreate extends AbstractEvent implements GroupCreateEvent { - - private final Group group; - private final CreationCause cause; - - public EventGroupCreate(Group group, CreationCause cause) { - this.group = group; - this.cause = cause; - } - - @Nonnull - @Override - public Group getGroup() { - return this.group; - } - - @Nonnull - @Override - public CreationCause getCause() { - return this.cause; - } - - @Override - public String toString() { - return "GroupCreateEvent(group=" + this.getGroup() + ", cause=" + this.getCause() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupDataRecalculate.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupDataRecalculate.java deleted file mode 100644 index a152b3cf2..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupDataRecalculate.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Group; -import me.lucko.luckperms.api.caching.GroupData; -import me.lucko.luckperms.api.event.group.GroupDataRecalculateEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import javax.annotation.Nonnull; - -public class EventGroupDataRecalculate extends AbstractEvent implements GroupDataRecalculateEvent { - - private final Group group; - private final GroupData data; - - public EventGroupDataRecalculate(Group group, GroupData data) { - this.group = group; - this.data = data; - } - - @Nonnull - @Override - public Group getGroup() { - return this.group; - } - - @Nonnull - @Override - public GroupData getData() { - return this.data; - } - - @Override - public String toString() { - return "GroupDataRecalculateEvent(group=" + this.getGroup() + ", data=" + this.getData() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupDelete.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupDelete.java deleted file mode 100644 index 7cd1adb88..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupDelete.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.api.event.cause.DeletionCause; -import me.lucko.luckperms.api.event.group.GroupDeleteEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.Set; - -import javax.annotation.Nonnull; - -public class EventGroupDelete extends AbstractEvent implements GroupDeleteEvent { - - private final String groupName; - private final Set existingData; - private final DeletionCause cause; - - public EventGroupDelete(String groupName, Set existingData, DeletionCause cause) { - this.groupName = groupName; - this.existingData = existingData; - this.cause = cause; - } - - @Nonnull - @Override - public String getGroupName() { - return this.groupName; - } - - @Nonnull - @Override - public Set getExistingData() { - return this.existingData; - } - - @Nonnull - @Override - public DeletionCause getCause() { - return this.cause; - } - - @Override - public String toString() { - return "GroupDeleteEvent(" + - "groupName=" + this.getGroupName() + ", " + - "existingData=" + this.getExistingData() + ", " + - "cause=" + this.getCause() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupLoad.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupLoad.java deleted file mode 100644 index 3289d4b6d..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupLoad.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Group; -import me.lucko.luckperms.api.event.group.GroupLoadEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import javax.annotation.Nonnull; - -public class EventGroupLoad extends AbstractEvent implements GroupLoadEvent { - - private final Group group; - - public EventGroupLoad(Group group) { - this.group = group; - } - - @Nonnull - @Override - public Group getGroup() { - return this.group; - } - - @Override - public String toString() { - return "GroupLoadEvent(group=" + this.getGroup() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupLoadAll.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupLoadAll.java deleted file mode 100644 index 933763e9a..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventGroupLoadAll.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.event.group.GroupLoadAllEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -public class EventGroupLoadAll extends AbstractEvent implements GroupLoadAllEvent { - - @Override - public String toString() { - return "GroupLoadAllEvent()"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogBroadcast.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogBroadcast.java deleted file mode 100644 index 57fa84ea6..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogBroadcast.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.LogEntry; -import me.lucko.luckperms.api.event.log.LogBroadcastEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.annotation.Nonnull; - -public class EventLogBroadcast extends AbstractEvent implements LogBroadcastEvent { - - private final AtomicBoolean cancellationState; - private final LogEntry entry; - private final Origin origin; - - public EventLogBroadcast(AtomicBoolean cancellationState, LogEntry entry, Origin origin) { - this.cancellationState = cancellationState; - this.entry = entry; - this.origin = origin; - } - - @Nonnull - @Override - public AtomicBoolean getCancellationState() { - return this.cancellationState; - } - - @Nonnull - @Override - public LogEntry getEntry() { - return this.entry; - } - - @Nonnull - @Override - public Origin getOrigin() { - return this.origin; - } - - @Override - public String toString() { - return "LogBroadcastEvent(" + - "cancellationState=" + this.getCancellationState() + ", " + - "entry=" + this.getEntry() + ", " + - "origin=" + this.getOrigin() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNetworkPublish.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNetworkPublish.java deleted file mode 100644 index 1735fa632..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNetworkPublish.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.LogEntry; -import me.lucko.luckperms.api.event.log.LogNetworkPublishEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.UUID; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.annotation.Nonnull; - -public class EventLogNetworkPublish extends AbstractEvent implements LogNetworkPublishEvent { - - private final AtomicBoolean cancellationState; - private final UUID logId; - private final LogEntry entry; - - public EventLogNetworkPublish(AtomicBoolean cancellationState, UUID logId, LogEntry entry) { - this.cancellationState = cancellationState; - this.logId = logId; - this.entry = entry; - } - - @Nonnull - @Override - public AtomicBoolean getCancellationState() { - return this.cancellationState; - } - - @Nonnull - @Override - public UUID getLogId() { - return this.logId; - } - - @Nonnull - @Override - public LogEntry getEntry() { - return this.entry; - } - - @Override - public String toString() { - return "LogNetworkPublishEvent(" + - "cancellationState=" + this.getCancellationState() + ", " + - "logId=" + this.getLogId() + ", " + - "entry=" + this.getEntry() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNotify.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNotify.java deleted file mode 100644 index 318514768..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogNotify.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Entity; -import me.lucko.luckperms.api.LogEntry; -import me.lucko.luckperms.api.event.log.LogNotifyEvent; -import me.lucko.luckperms.common.event.AbstractEvent; -import me.lucko.luckperms.common.event.model.SenderEntity; -import me.lucko.luckperms.common.sender.Sender; - -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.annotation.Nonnull; - -public class EventLogNotify extends AbstractEvent implements LogNotifyEvent { - - private final AtomicBoolean cancellationState; - private final LogEntry entry; - private final Origin origin; - private final Sender sender; - - private Entity notifiable; - - public EventLogNotify(AtomicBoolean cancellationState, LogEntry entry, Origin origin, Sender sender) { - this.cancellationState = cancellationState; - this.entry = entry; - this.origin = origin; - this.sender = sender; - } - - @Nonnull - @Override - public synchronized Entity getNotifiable() { - if (this.notifiable == null) { - this.notifiable = new SenderEntity(this.sender); - } - return this.notifiable; - } - - @Nonnull - @Override - public AtomicBoolean getCancellationState() { - return this.cancellationState; - } - - @Nonnull - @Override - public LogEntry getEntry() { - return this.entry; - } - - @Nonnull - @Override - public Origin getOrigin() { - return this.origin; - } - - @Override - public String toString() { - return "LogNotifyEvent(" + - "cancellationState=" + this.getCancellationState() + ", " + - "entry=" + this.getEntry() + ", " + - "origin=" + this.getOrigin() + ", " + - "notifiable=" + this.getNotifiable() + ")"; - } - -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogPublish.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogPublish.java deleted file mode 100644 index 3f40129c8..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogPublish.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.LogEntry; -import me.lucko.luckperms.api.event.log.LogPublishEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.annotation.Nonnull; - -public class EventLogPublish extends AbstractEvent implements LogPublishEvent { - - private final AtomicBoolean cancellationState; - private final LogEntry entry; - - public EventLogPublish(AtomicBoolean cancellationState, LogEntry entry) { - this.cancellationState = cancellationState; - this.entry = entry; - } - - @Nonnull - @Override - public AtomicBoolean getCancellationState() { - return this.cancellationState; - } - - @Nonnull - @Override - public LogEntry getEntry() { - return this.entry; - } - - @Override - public String toString() { - return "LogPublishEvent(cancellationState=" + this.getCancellationState() + ", entry=" + this.getEntry() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogReceive.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogReceive.java deleted file mode 100644 index 7fccae350..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventLogReceive.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.LogEntry; -import me.lucko.luckperms.api.event.log.LogReceiveEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.UUID; - -import javax.annotation.Nonnull; - -public class EventLogReceive extends AbstractEvent implements LogReceiveEvent { - - private final UUID logId; - private final LogEntry entry; - - public EventLogReceive(UUID logId, LogEntry entry) { - this.logId = logId; - this.entry = entry; - } - - @Nonnull - @Override - public UUID getLogId() { - return this.logId; - } - - @Nonnull - @Override - public LogEntry getEntry() { - return this.entry; - } - - @Override - public String toString() { - return "LogReceiveEvent(logId=" + this.getLogId() + ", entry=" + this.getEntry() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeAdd.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeAdd.java deleted file mode 100644 index 282427f91..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeAdd.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Group; -import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.api.PermissionHolder; -import me.lucko.luckperms.api.User; -import me.lucko.luckperms.api.event.node.NodeAddEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.Set; - -import javax.annotation.Nonnull; - -public class EventNodeAdd extends AbstractEvent implements NodeAddEvent { - - private final Node node; - private final PermissionHolder target; - private final Set dataBefore; - private final Set dataAfter; - - public EventNodeAdd(Node node, PermissionHolder target, Set dataBefore, Set dataAfter) { - this.node = node; - this.target = target; - this.dataBefore = dataBefore; - this.dataAfter = dataAfter; - } - - @Override - public boolean isUser() { - return this.target instanceof User; - } - - @Override - public boolean isGroup() { - return this.target instanceof Group; - } - - @Nonnull - @Override - public Node getNode() { - return this.node; - } - - @Nonnull - @Override - public PermissionHolder getTarget() { - return this.target; - } - - @Nonnull - @Override - public Set getDataBefore() { - return this.dataBefore; - } - - @Nonnull - @Override - public Set getDataAfter() { - return this.dataAfter; - } - - @Override - public String toString() { - return "NodeAddEvent(" + - "node=" + this.getNode() + ", " + - "target=" + this.getTarget() + ", " + - "dataBefore=" + this.getDataBefore() + ", " + - "dataAfter=" + this.getDataAfter() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeClear.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeClear.java deleted file mode 100644 index 76fb28150..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeClear.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Group; -import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.api.PermissionHolder; -import me.lucko.luckperms.api.User; -import me.lucko.luckperms.api.event.node.NodeClearEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.Set; - -import javax.annotation.Nonnull; - -public class EventNodeClear extends AbstractEvent implements NodeClearEvent { - - private final PermissionHolder target; - private final Set dataBefore; - private final Set dataAfter; - - public EventNodeClear(PermissionHolder target, Set dataBefore, Set dataAfter) { - this.target = target; - this.dataBefore = dataBefore; - this.dataAfter = dataAfter; - } - - @Override - public boolean isUser() { - return this.target instanceof User; - } - - @Override - public boolean isGroup() { - return this.target instanceof Group; - } - - @Nonnull - @Override - public PermissionHolder getTarget() { - return this.target; - } - - @Nonnull - @Override - public Set getDataBefore() { - return this.dataBefore; - } - - @Nonnull - @Override - public Set getDataAfter() { - return this.dataAfter; - } - - @Override - public String toString() { - return "NodeClearEvent(" + - "target=" + this.getTarget() + ", " + - "dataBefore=" + this.getDataBefore() + ", " + - "dataAfter=" + this.getDataAfter() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeRemove.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeRemove.java deleted file mode 100644 index 65ee6b3fd..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventNodeRemove.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Group; -import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.api.PermissionHolder; -import me.lucko.luckperms.api.User; -import me.lucko.luckperms.api.event.node.NodeRemoveEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.Set; - -import javax.annotation.Nonnull; - -public class EventNodeRemove extends AbstractEvent implements NodeRemoveEvent { - - private final Node node; - private final PermissionHolder target; - private final Set dataBefore; - private final Set dataAfter; - - public EventNodeRemove(Node node, PermissionHolder target, Set dataBefore, Set dataAfter) { - this.node = node; - this.target = target; - this.dataBefore = dataBefore; - this.dataAfter = dataAfter; - } - - @Override - public boolean isUser() { - return this.target instanceof User; - } - - @Override - public boolean isGroup() { - return this.target instanceof Group; - } - - @Nonnull - @Override - public Node getNode() { - return this.node; - } - - @Nonnull - @Override - public PermissionHolder getTarget() { - return this.target; - } - - @Nonnull - @Override - public Set getDataBefore() { - return this.dataBefore; - } - - @Nonnull - @Override - public Set getDataAfter() { - return this.dataAfter; - } - - @Override - public String toString() { - return "NodeRemoveEvent(" + - "node=" + this.getNode() + ", " + - "target=" + this.getTarget() + ", " + - "dataBefore=" + this.getDataBefore() + ", " + - "dataAfter=" + this.getDataAfter() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPlayerDataSave.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPlayerDataSave.java deleted file mode 100644 index c0167b757..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPlayerDataSave.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.PlayerSaveResult; -import me.lucko.luckperms.api.event.player.PlayerDataSaveEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.UUID; - -import javax.annotation.Nonnull; - -public class EventPlayerDataSave extends AbstractEvent implements PlayerDataSaveEvent { - private final UUID uuid; - private final String username; - private final PlayerSaveResult result; - - public EventPlayerDataSave(UUID uuid, String username, PlayerSaveResult result) { - this.uuid = uuid; - this.username = username; - this.result = result; - } - - @Nonnull - @Override - public UUID getUuid() { - return this.uuid; - } - - @Nonnull - @Override - public String getUsername() { - return this.username; - } - - @Nonnull - @Override - public PlayerSaveResult getResult() { - return this.result; - } - - @Override - public String toString() { - return "PlayerDataSaveEvent(" + - "uuid=" + this.uuid + ", " + - "username=" + this.username + ", " + - "result=" + this.result + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPostSync.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPostSync.java deleted file mode 100644 index 69fa8f9d9..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPostSync.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.event.sync.PostSyncEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -public class EventPostSync extends AbstractEvent implements PostSyncEvent { - - @Override - public String toString() { - return "PostSyncEvent()"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPreNetworkSync.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPreNetworkSync.java deleted file mode 100644 index 24bb9ee14..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPreNetworkSync.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.event.sync.PreNetworkSyncEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.UUID; -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.annotation.Nonnull; - -public class EventPreNetworkSync extends AbstractEvent implements PreNetworkSyncEvent { - - private final AtomicBoolean cancellationState; - private final UUID syncId; - - public EventPreNetworkSync(AtomicBoolean cancellationState, UUID syncId) { - this.cancellationState = cancellationState; - this.syncId = syncId; - } - - @Nonnull - @Override - public AtomicBoolean getCancellationState() { - return this.cancellationState; - } - - @Nonnull - @Override - public UUID getSyncId() { - return this.syncId; - } - - @Override - public String toString() { - return "PreNetworkSyncEvent(" + - "cancellationState=" + this.getCancellationState() + ", " + - "syncId=" + this.getSyncId() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPreSync.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPreSync.java deleted file mode 100644 index b9b62c57b..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPreSync.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.event.sync.PreSyncEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.concurrent.atomic.AtomicBoolean; - -import javax.annotation.Nonnull; - -public class EventPreSync extends AbstractEvent implements PreSyncEvent { - - private final AtomicBoolean cancellationState; - - public EventPreSync(AtomicBoolean cancellationState) { - this.cancellationState = cancellationState; - } - - @Nonnull - @Override - public AtomicBoolean getCancellationState() { - return this.cancellationState; - } - - @Override - public String toString() { - return "PreSyncEvent(cancellationState=" + this.getCancellationState() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackAddGroup.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackAddGroup.java deleted file mode 100644 index b7eb0f3d8..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackAddGroup.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Track; -import me.lucko.luckperms.api.event.track.mutate.TrackAddGroupEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.List; - -import javax.annotation.Nonnull; - -public class EventTrackAddGroup extends AbstractEvent implements TrackAddGroupEvent { - - private final String group; - private final Track track; - private final List dataBefore; - private final List dataAfter; - - public EventTrackAddGroup(String group, Track track, List dataBefore, List dataAfter) { - this.group = group; - this.track = track; - this.dataBefore = dataBefore; - this.dataAfter = dataAfter; - } - - @Nonnull - @Override - public String getGroup() { - return this.group; - } - - @Nonnull - @Override - public Track getTrack() { - return this.track; - } - - @Nonnull - @Override - public List getDataBefore() { - return this.dataBefore; - } - - @Nonnull - @Override - public List getDataAfter() { - return this.dataAfter; - } - - @Override - public String toString() { - return "TrackAddGroupEvent(" + - "group=" + this.getGroup() + ", " + - "track=" + this.getTrack() + ", " + - "dataBefore=" + this.getDataBefore() + ", " + - "dataAfter=" + this.getDataAfter() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackClear.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackClear.java deleted file mode 100644 index 383c9177b..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackClear.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Track; -import me.lucko.luckperms.api.event.track.mutate.TrackClearEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.List; - -import javax.annotation.Nonnull; - -public class EventTrackClear extends AbstractEvent implements TrackClearEvent { - - private final Track track; - private final List dataBefore; - private final List dataAfter; - - public EventTrackClear(Track track, List dataBefore, List dataAfter) { - this.track = track; - this.dataBefore = dataBefore; - this.dataAfter = dataAfter; - } - - @Nonnull - @Override - public Track getTrack() { - return this.track; - } - - @Nonnull - @Override - public List getDataBefore() { - return this.dataBefore; - } - - @Nonnull - @Override - public List getDataAfter() { - return this.dataAfter; - } - - @Override - public String toString() { - return "TrackClearEvent(" + - "track=" + this.getTrack() + ", " + - "dataBefore=" + this.getDataBefore() + ", " + - "dataAfter=" + this.getDataAfter() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackCreate.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackCreate.java deleted file mode 100644 index 26ecde559..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackCreate.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Track; -import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.api.event.track.TrackCreateEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import javax.annotation.Nonnull; - -public class EventTrackCreate extends AbstractEvent implements TrackCreateEvent { - - private final Track track; - private final CreationCause cause; - - public EventTrackCreate(Track track, CreationCause cause) { - this.track = track; - this.cause = cause; - } - - @Nonnull - @Override - public Track getTrack() { - return this.track; - } - - @Nonnull - @Override - public CreationCause getCause() { - return this.cause; - } - - @Override - public String toString() { - return "TrackCreateEvent(track=" + this.getTrack() + ", cause=" + this.getCause() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackDelete.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackDelete.java deleted file mode 100644 index 568a04e2d..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackDelete.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.event.cause.DeletionCause; -import me.lucko.luckperms.api.event.track.TrackDeleteEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.List; - -import javax.annotation.Nonnull; - -public class EventTrackDelete extends AbstractEvent implements TrackDeleteEvent { - - private final String trackName; - private final List existingData; - private final DeletionCause cause; - - public EventTrackDelete(String trackName, List existingData, DeletionCause cause) { - this.trackName = trackName; - this.existingData = existingData; - this.cause = cause; - } - - @Nonnull - @Override - public String getTrackName() { - return this.trackName; - } - - @Nonnull - @Override - public List getExistingData() { - return this.existingData; - } - - @Nonnull - @Override - public DeletionCause getCause() { - return this.cause; - } - - @Override - public String toString() { - return "TrackDeleteEvent(" + - "trackName=" + this.getTrackName() + ", " + - "existingData=" + this.getExistingData() + ", " + - "cause=" + this.getCause() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackLoad.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackLoad.java deleted file mode 100644 index 799fd726a..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackLoad.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Track; -import me.lucko.luckperms.api.event.track.TrackLoadEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import javax.annotation.Nonnull; - -public class EventTrackLoad extends AbstractEvent implements TrackLoadEvent { - - private final Track track; - - public EventTrackLoad(Track track) { - this.track = track; - } - - @Nonnull - @Override - public Track getTrack() { - return this.track; - } - - @Override - public String toString() { - return "TrackLoadEvent(track=" + this.getTrack() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackLoadAll.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackLoadAll.java deleted file mode 100644 index daadd0b63..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackLoadAll.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.event.track.TrackLoadAllEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -public class EventTrackLoadAll extends AbstractEvent implements TrackLoadAllEvent { - - @Override - public String toString() { - return "TrackLoadAllEvent()"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackRemoveGroup.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackRemoveGroup.java deleted file mode 100644 index 81b42b6f0..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventTrackRemoveGroup.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Track; -import me.lucko.luckperms.api.event.track.mutate.TrackRemoveGroupEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.List; - -import javax.annotation.Nonnull; - -public class EventTrackRemoveGroup extends AbstractEvent implements TrackRemoveGroupEvent { - - private final String group; - private final Track track; - private final List dataBefore; - private final List dataAfter; - - public EventTrackRemoveGroup(String group, Track track, List dataBefore, List dataAfter) { - this.group = group; - this.track = track; - this.dataBefore = dataBefore; - this.dataAfter = dataAfter; - } - - @Nonnull - @Override - public String getGroup() { - return this.group; - } - - @Nonnull - @Override - public Track getTrack() { - return this.track; - } - - @Nonnull - @Override - public List getDataBefore() { - return this.dataBefore; - } - - @Nonnull - @Override - public List getDataAfter() { - return this.dataAfter; - } - - @Override - public String toString() { - return "TrackRemoveGroupEvent(" + - "group=" + this.getGroup() + ", " + - "track=" + this.getTrack() + ", " + - "dataBefore=" + this.getDataBefore() + ", " + - "dataAfter=" + this.getDataAfter() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserCacheLoad.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserCacheLoad.java deleted file mode 100644 index 39435c66e..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserCacheLoad.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.User; -import me.lucko.luckperms.api.caching.UserData; -import me.lucko.luckperms.api.event.user.UserCacheLoadEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import javax.annotation.Nonnull; - -public class EventUserCacheLoad extends AbstractEvent implements UserCacheLoadEvent { - - private final User user; - private final UserData loadedData; - - public EventUserCacheLoad(User user, UserData loadedData) { - this.user = user; - this.loadedData = loadedData; - } - - @Nonnull - @Override - public User getUser() { - return this.user; - } - - @Nonnull - @Override - public UserData getLoadedData() { - return this.loadedData; - } - - @Override - public String toString() { - return "UserCacheLoadEvent(user=" + this.getUser() + ", loadedData=" + this.getLoadedData() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserDataRecalculate.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserDataRecalculate.java deleted file mode 100644 index 5943678f8..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserDataRecalculate.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.User; -import me.lucko.luckperms.api.caching.UserData; -import me.lucko.luckperms.api.event.user.UserDataRecalculateEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import javax.annotation.Nonnull; - -public class EventUserDataRecalculate extends AbstractEvent implements UserDataRecalculateEvent { - - private final User user; - private final UserData data; - - public EventUserDataRecalculate(User user, UserData data) { - this.user = user; - this.data = data; - } - - @Nonnull - @Override - public User getUser() { - return this.user; - } - - @Nonnull - @Override - public UserData getData() { - return this.data; - } - - @Override - public String toString() { - return "UserDataRecalculateEvent(user=" + this.getUser() + ", data=" + this.getData() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserDemote.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserDemote.java deleted file mode 100644 index 9b536eade..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserDemote.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Track; -import me.lucko.luckperms.api.User; -import me.lucko.luckperms.api.event.source.Source; -import me.lucko.luckperms.api.event.user.track.TrackAction; -import me.lucko.luckperms.api.event.user.track.UserDemoteEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.Optional; - -import javax.annotation.Nonnull; - -public class EventUserDemote extends AbstractEvent implements UserDemoteEvent { - - private final Track track; - private final User user; - - private final String groupFrom; - private final String groupTo; - - private final Source source; - - public EventUserDemote(Track track, User user, String groupFrom, String groupTo, Source source) { - this.track = track; - this.user = user; - this.groupFrom = groupFrom; - this.groupTo = groupTo; - this.source = source; - } - - @Nonnull - @Override - public Track getTrack() { - return this.track; - } - - @Nonnull - @Override - public User getUser() { - return this.user; - } - - @Nonnull - @Override - public TrackAction getAction() { - return TrackAction.DEMOTION; - } - - @Nonnull - @Override - public Optional getGroupFrom() { - return Optional.ofNullable(this.groupFrom); - } - - @Nonnull - @Override - public Optional getGroupTo() { - return Optional.ofNullable(this.groupTo); - } - - @Nonnull - @Override - public Source getSource() { - return this.source; - } - - @Override - public String toString() { - return "UserDemoteEvent(" + - "track=" + this.track + ", " + - "user=" + this.user + ", " + - "groupFrom=" + this.getGroupFrom() + ", " + - "groupTo=" + this.getGroupTo() + ", " + - "source=" + this.getSource() + ")"; - } - -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserFirstLogin.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserFirstLogin.java deleted file mode 100644 index c947cd90d..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserFirstLogin.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.event.user.UserFirstLoginEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.UUID; - -import javax.annotation.Nonnull; - -public class EventUserFirstLogin extends AbstractEvent implements UserFirstLoginEvent { - - private final UUID uuid; - private final String username; - - public EventUserFirstLogin(UUID uuid, String username) { - this.uuid = uuid; - this.username = username; - } - - @Nonnull - @Override - public UUID getUuid() { - return this.uuid; - } - - @Nonnull - @Override - public String getUsername() { - return this.username; - } - - @Override - public String toString() { - return "UserFirstLoginEvent(uuid=" + this.getUuid() + ", username=" + this.getUsername() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserLoad.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserLoad.java deleted file mode 100644 index 9565b7967..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserLoad.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.User; -import me.lucko.luckperms.api.event.user.UserLoadEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import javax.annotation.Nonnull; - -public class EventUserLoad extends AbstractEvent implements UserLoadEvent { - - private final User user; - - public EventUserLoad(User user) { - this.user = user; - } - - @Nonnull - @Override - public User getUser() { - return this.user; - } - - @Override - public String toString() { - return "UserLoadEvent(user=" + this.getUser() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserLoginProcess.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserLoginProcess.java deleted file mode 100644 index 0cfc596c8..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserLoginProcess.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.User; -import me.lucko.luckperms.api.event.user.UserLoginProcessEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.UUID; - -import javax.annotation.Nonnull; - -public class EventUserLoginProcess extends AbstractEvent implements UserLoginProcessEvent { - - private final UUID uuid; - private final String username; - private final User user; - - public EventUserLoginProcess(UUID uuid, String username, User user) { - this.uuid = uuid; - this.username = username; - this.user = user; - } - - @Nonnull - @Override - public UUID getUuid() { - return this.uuid; - } - - @Nonnull - @Override - public String getUsername() { - return this.username; - } - - @Override - public User getUser() { - return this.user; - } - - @Override - public String toString() { - return "UserLoginProcessEvent(uuid=" + this.getUuid() + ", username=" + this.getUsername() + ", user=" + this.getUser() + ")"; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserPromote.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserPromote.java deleted file mode 100644 index fdfccbbb3..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/event/impl/EventUserPromote.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * 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.common.event.impl; - -import me.lucko.luckperms.api.Track; -import me.lucko.luckperms.api.User; -import me.lucko.luckperms.api.event.source.Source; -import me.lucko.luckperms.api.event.user.track.TrackAction; -import me.lucko.luckperms.api.event.user.track.UserPromoteEvent; -import me.lucko.luckperms.common.event.AbstractEvent; - -import java.util.Optional; - -import javax.annotation.Nonnull; - -public class EventUserPromote extends AbstractEvent implements UserPromoteEvent { - - private final Track track; - private final User user; - - private final String groupFrom; - private final String groupTo; - - private final Source source; - - public EventUserPromote(Track track, User user, String groupFrom, String groupTo, Source source) { - this.track = track; - this.user = user; - this.groupFrom = groupFrom; - this.groupTo = groupTo; - this.source = source; - } - - @Nonnull - @Override - public Track getTrack() { - return this.track; - } - - @Nonnull - @Override - public User getUser() { - return this.user; - } - - @Nonnull - @Override - public TrackAction getAction() { - return TrackAction.PROMOTION; - } - - @Nonnull - @Override - public Optional getGroupFrom() { - return Optional.ofNullable(this.groupFrom); - } - - @Nonnull - @Override - public Optional getGroupTo() { - return Optional.ofNullable(this.groupTo); - } - - @Nonnull - @Override - public Source getSource() { - return this.source; - } - - @Override - public String toString() { - return "UserPromoteEvent(" + - "track=" + this.track + ", " + - "user=" + this.user + ", " + - "groupFrom=" + this.getGroupFrom() + ", " + - "groupTo=" + this.getGroupTo() + ", " + - "source=" + this.getSource() + ")"; - } - -} diff --git a/nukkit/pom.xml b/nukkit/pom.xml index c824969cd..956a7d8b6 100644 --- a/nukkit/pom.xml +++ b/nukkit/pom.xml @@ -56,6 +56,10 @@ net.kyori.text me.lucko.luckperms.lib.text + + net.kyori.event + me.lucko.luckperms.lib.eventbus + com.github.benmanes.caffeine me.lucko.luckperms.lib.caffeine diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java index 475368b1a..994b0f9ed 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/LPNukkitPlugin.java @@ -110,7 +110,7 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin { @Override protected Set getGlobalDependencies() { - return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP); + return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, Dependency.EVENT); } @Override diff --git a/sponge/pom.xml b/sponge/pom.xml index 567e126da..74810298d 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -59,6 +59,10 @@ net.kyori.text me.lucko.luckperms.lib.text + + net.kyori.event + me.lucko.luckperms.lib.eventbus + com.github.benmanes.caffeine me.lucko.luckperms.lib.caffeine diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java index aa5b9fedc..927af2ca8 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java @@ -112,7 +112,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin { @Override protected Set getGlobalDependencies() { - return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, + return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, Dependency.EVENT, Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_HOCON, Dependency.HOCON_CONFIG); }