From 63b890d5223800f072c54dd7f296bf28f2d8c86f Mon Sep 17 00:00:00 2001 From: Luck Date: Tue, 24 Dec 2019 13:05:48 +0000 Subject: [PATCH] Rename EventFactory --> EventDispatcher --- .../listeners/BukkitConnectionListener.java | 4 +- .../listeners/BungeeConnectionListener.java | 4 +- .../common/actionlog/LogDispatcher.java | 12 ++-- .../common/api/LuckPermsApiProvider.java | 2 +- .../common/config/AbstractConfiguration.java | 2 +- ...EventFactory.java => EventDispatcher.java} | 70 +++++++++---------- .../extension/SimpleExtensionManager.java | 4 +- .../messaging/LuckPermsMessagingService.java | 8 +-- .../lucko/luckperms/common/model/Group.java | 2 +- .../common/model/PermissionHolder.java | 14 ++-- .../lucko/luckperms/common/model/Track.java | 16 ++--- .../me/lucko/luckperms/common/model/User.java | 2 +- .../plugin/AbstractLuckPermsPlugin.java | 10 +-- .../common/plugin/LuckPermsPlugin.java | 8 +-- .../util/AbstractConnectionListener.java | 2 +- .../luckperms/common/storage/Storage.java | 20 +++--- .../luckperms/common/tasks/SyncTask.java | 4 +- .../listeners/NukkitConnectionListener.java | 4 +- .../listeners/SpongeConnectionListener.java | 4 +- .../listeners/VelocityConnectionListener.java | 4 +- 20 files changed, 98 insertions(+), 98 deletions(-) rename common/src/main/java/me/lucko/luckperms/common/event/{EventFactory.java => EventDispatcher.java} (81%) diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java index c40ca0cc5..50bb58e9c 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitConnectionListener.java @@ -115,7 +115,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme try { User user = loadUser(e.getUniqueId(), e.getName()); recordConnection(e.getUniqueId()); - this.plugin.getEventFactory().handlePlayerLoginProcess(e.getUniqueId(), e.getName(), user); + this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(e.getUniqueId(), e.getName(), user); } catch (Exception ex) { this.plugin.getLogger().severe("Exception occurred whilst loading data for " + e.getUniqueId() + " - " + e.getName()); ex.printStackTrace(); @@ -123,7 +123,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme // deny the connection this.deniedAsyncLogin.add(e.getUniqueId()); e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager())); - this.plugin.getEventFactory().handlePlayerLoginProcess(e.getUniqueId(), e.getName(), null); + this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(e.getUniqueId(), e.getName(), null); } } diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java b/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java index 6be44432b..eae373d2f 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/listeners/BungeeConnectionListener.java @@ -89,7 +89,7 @@ public class BungeeConnectionListener extends AbstractConnectionListener impleme try { User user = loadUser(c.getUniqueId(), c.getName()); recordConnection(c.getUniqueId()); - this.plugin.getEventFactory().handlePlayerLoginProcess(c.getUniqueId(), c.getName(), user); + this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(c.getUniqueId(), c.getName(), user); } catch (Exception ex) { this.plugin.getLogger().severe("Exception occurred whilst loading data for " + c.getUniqueId() + " - " + c.getName()); ex.printStackTrace(); @@ -100,7 +100,7 @@ public class BungeeConnectionListener extends AbstractConnectionListener impleme e.setCancelReason(TextComponent.fromLegacyText(Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager()))); e.setCancelled(true); } - this.plugin.getEventFactory().handlePlayerLoginProcess(c.getUniqueId(), c.getName(), null); + this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(c.getUniqueId(), c.getName(), null); } // finally, complete our intent to modify state, so the proxy can continue handling the connection. diff --git a/common/src/main/java/me/lucko/luckperms/common/actionlog/LogDispatcher.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/LogDispatcher.java index 9cb0c29b5..82dbf4c9e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/actionlog/LogDispatcher.java +++ b/common/src/main/java/me/lucko/luckperms/common/actionlog/LogDispatcher.java @@ -50,7 +50,7 @@ public class LogDispatcher { .filter(CommandPermission.LOG_NOTIFY::isAuthorized) .filter(s -> { boolean shouldCancel = LogNotify.isIgnoring(this.plugin, s.getUniqueId()) || (sender != null && s.getUniqueId().equals(sender.getUniqueId())); - return !this.plugin.getEventFactory().handleLogNotify(shouldCancel, entry, origin, s); + return !this.plugin.getEventDispatcher().dispatchLogNotify(shouldCancel, entry, origin, s); }) .forEach(s -> Message.LOG.send(s, entry.getSourceFriendlyString(), @@ -62,7 +62,7 @@ public class LogDispatcher { public void dispatch(LoggedAction entry, Sender sender) { // set the event to cancelled if the sender is import - if (!this.plugin.getEventFactory().handleLogPublish(sender.isImport(), entry)) { + if (!this.plugin.getEventDispatcher().dispatchLogPublish(sender.isImport(), entry)) { this.plugin.getStorage().logAction(entry); } @@ -77,13 +77,13 @@ public class LogDispatcher { } boolean shouldCancel = !this.plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY); - if (!this.plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL)) { + if (!this.plugin.getEventDispatcher().dispatchLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL)) { broadcast(entry, LogNotifyEvent.Origin.LOCAL, sender); } } public void dispatchFromApi(LoggedAction entry) { - if (!this.plugin.getEventFactory().handleLogPublish(false, entry)) { + if (!this.plugin.getEventDispatcher().dispatchLogPublish(false, entry)) { try { this.plugin.getStorage().logAction(entry).get(); } catch (Exception e) { @@ -98,14 +98,14 @@ public class LogDispatcher { this.plugin.getMessagingService().ifPresent(extendedMessagingService -> extendedMessagingService.pushLog(entry)); boolean shouldCancel = !this.plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY); - if (!this.plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL_API)) { + if (!this.plugin.getEventDispatcher().dispatchLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL_API)) { broadcast(entry, LogNotifyEvent.Origin.LOCAL_API, null); } } public void dispatchFromRemote(LoggedAction entry) { boolean shouldCancel = !this.plugin.getConfiguration().get(ConfigKeys.BROADCAST_RECEIVED_LOG_ENTRIES) || !this.plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY); - if (!this.plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.REMOTE)) { + if (!this.plugin.getEventDispatcher().dispatchLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.REMOTE)) { broadcast(entry, LogNotifyEvent.Origin.REMOTE, null); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java b/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java index def04a46d..bcfacb664 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/LuckPermsApiProvider.java @@ -121,7 +121,7 @@ public class LuckPermsApiProvider implements LuckPerms { @Override public @NonNull EventBus getEventBus() { - return this.plugin.getEventFactory().getEventBus(); + return this.plugin.getEventDispatcher().getEventBus(); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/config/AbstractConfiguration.java b/common/src/main/java/me/lucko/luckperms/common/config/AbstractConfiguration.java index 28b4c582d..0ec176f07 100644 --- a/common/src/main/java/me/lucko/luckperms/common/config/AbstractConfiguration.java +++ b/common/src/main/java/me/lucko/luckperms/common/config/AbstractConfiguration.java @@ -93,7 +93,7 @@ public class AbstractConfiguration implements LuckPermsConfiguration { this.adapter.reload(); load(); - getPlugin().getEventFactory().handleConfigReload(); + getPlugin().getEventDispatcher().dispatchConfigReload(); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java b/common/src/main/java/me/lucko/luckperms/common/event/EventDispatcher.java similarity index 81% rename from common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java rename to common/src/main/java/me/lucko/luckperms/common/event/EventDispatcher.java index 2a90b78cc..71ff9007a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/EventDispatcher.java @@ -97,10 +97,10 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; -public final class EventFactory { +public final class EventDispatcher { private final AbstractEventBus eventBus; - public EventFactory(AbstractEventBus eventBus) { + public EventDispatcher(AbstractEventBus eventBus) { this.eventBus = eventBus; } @@ -135,31 +135,31 @@ public final class EventFactory { return (T) GeneratedEventSpec.lookup(eventClass).newInstance(this.eventBus.getApiProvider(), params); } - public void handleExtensionLoad(Extension extension) { + public void dispatchExtensionLoad(Extension extension) { post(ExtensionLoadEvent.class, () -> generate(ExtensionLoadEvent.class, extension)); } - public void handleGroupCacheLoad(Group group, GroupCachedDataManager data) { + public void dispatchGroupCacheLoad(Group group, GroupCachedDataManager data) { post(GroupCacheLoadEvent.class, () -> generate(GroupCacheLoadEvent.class, group.getApiDelegate(), data)); } - public void handleGroupCreate(Group group, CreationCause cause) { + public void dispatchGroupCreate(Group group, CreationCause cause) { post(GroupCreateEvent.class, () -> generate(GroupCreateEvent.class, group.getApiDelegate(), cause)); } - public void handleGroupDelete(Group group, DeletionCause cause) { + public void dispatchGroupDelete(Group group, DeletionCause cause) { post(GroupDeleteEvent.class, () -> generate(GroupDeleteEvent.class, group.getName(), ImmutableSet.copyOf(group.normalData().immutable().values()), cause)); } - public void handleGroupLoadAll() { + public void dispatchGroupLoadAll() { post(GroupLoadAllEvent.class, () -> generate(GroupLoadAllEvent.class)); } - public void handleGroupLoad(Group group) { + public void dispatchGroupLoad(Group group) { post(GroupLoadEvent.class, () -> generate(GroupLoadEvent.class, group.getApiDelegate())); } - public boolean handleLogBroadcast(boolean initialState, Action entry, LogBroadcastEvent.Origin origin) { + public boolean dispatchLogBroadcast(boolean initialState, Action entry, LogBroadcastEvent.Origin origin) { if (!shouldPost(LogBroadcastEvent.class)) { return initialState; } @@ -169,7 +169,7 @@ public final class EventFactory { return cancel.get(); } - public boolean handleLogPublish(boolean initialState, Action entry) { + public boolean dispatchLogPublish(boolean initialState, Action entry) { if (!shouldPost(LogPublishEvent.class)) { return initialState; } @@ -179,7 +179,7 @@ public final class EventFactory { return cancel.get(); } - public boolean handleLogNetworkPublish(boolean initialState, UUID id, Action entry) { + public boolean dispatchLogNetworkPublish(boolean initialState, UUID id, Action entry) { if (!shouldPost(LogNetworkPublishEvent.class)) { return initialState; } @@ -189,7 +189,7 @@ public final class EventFactory { return cancel.get(); } - public boolean handleLogNotify(boolean initialState, Action entry, LogNotifyEvent.Origin origin, Sender sender) { + public boolean dispatchLogNotify(boolean initialState, Action entry, LogNotifyEvent.Origin origin, Sender sender) { if (!shouldPost(LogNotifyEvent.class)) { return initialState; } @@ -199,31 +199,31 @@ public final class EventFactory { return cancel.get(); } - public void handleLogReceive(UUID id, Action entry) { + public void dispatchLogReceive(UUID id, Action entry) { post(LogReceiveEvent.class, () -> generate(LogReceiveEvent.class, id, entry)); } - public void handleNodeAdd(Node node, PermissionHolder target, DataType dataType, Collection before, Collection after) { + public void dispatchNodeAdd(Node node, PermissionHolder target, DataType dataType, Collection before, Collection after) { post(NodeAddEvent.class, () -> generate(NodeAddEvent.class, getDelegate(target), dataType, ImmutableSet.copyOf(before), ImmutableSet.copyOf(after), node)); } - public void handleNodeClear(PermissionHolder target, DataType dataType, Collection before, Collection after) { + public void dispatchNodeClear(PermissionHolder target, DataType dataType, Collection before, Collection after) { post(NodeClearEvent.class, () -> generate(NodeClearEvent.class, getDelegate(target), dataType, ImmutableSet.copyOf(before), ImmutableSet.copyOf(after))); } - public void handleNodeRemove(Node node, PermissionHolder target, DataType dataType, Collection before, Collection after) { + public void dispatchNodeRemove(Node node, PermissionHolder target, DataType dataType, Collection before, Collection after) { post(NodeRemoveEvent.class, () -> generate(NodeRemoveEvent.class, getDelegate(target), dataType, ImmutableSet.copyOf(before), ImmutableSet.copyOf(after), node)); } - public void handleConfigReload() { + public void dispatchConfigReload() { post(ConfigReloadEvent.class, () -> generate(ConfigReloadEvent.class)); } - public void handlePostSync() { + public void dispatchPostSync() { post(PostSyncEvent.class, () -> generate(PostSyncEvent.class)); } - public boolean handleNetworkPreSync(boolean initialState, UUID id) { + public boolean dispatchNetworkPreSync(boolean initialState, UUID id) { if (!shouldPost(PreNetworkSyncEvent.class)) { return initialState; } @@ -233,7 +233,7 @@ public final class EventFactory { return cancel.get(); } - public boolean handlePreSync(boolean initialState) { + public boolean dispatchPreSync(boolean initialState) { if (!shouldPost(PreSyncEvent.class)) { return initialState; } @@ -243,39 +243,39 @@ public final class EventFactory { return cancel.get(); } - public void handleTrackCreate(Track track, CreationCause cause) { + public void dispatchTrackCreate(Track track, CreationCause cause) { post(TrackCreateEvent.class, () -> generate(TrackCreateEvent.class, track.getApiDelegate(), cause)); } - public void handleTrackDelete(Track track, DeletionCause cause) { + public void dispatchTrackDelete(Track track, DeletionCause cause) { post(TrackDeleteEvent.class, () -> generate(TrackDeleteEvent.class, track.getName(), ImmutableList.copyOf(track.getGroups()), cause)); } - public void handleTrackLoadAll() { + public void dispatchTrackLoadAll() { post(TrackLoadAllEvent.class, () -> generate(TrackLoadAllEvent.class)); } - public void handleTrackLoad(Track track) { + public void dispatchTrackLoad(Track track) { post(TrackLoadEvent.class, () -> generate(TrackLoadEvent.class, track.getApiDelegate())); } - public void handleTrackAddGroup(Track track, String group, List before, List after) { + public void dispatchTrackAddGroup(Track track, String group, List before, List after) { post(TrackAddGroupEvent.class, () -> generate(TrackAddGroupEvent.class, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.copyOf(after), group)); } - public void handleTrackClear(Track track, List before) { + public void dispatchTrackClear(Track track, List before) { post(TrackClearEvent.class, () -> generate(TrackClearEvent.class, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.of())); } - public void handleTrackRemoveGroup(Track track, String group, List before, List after) { + public void dispatchTrackRemoveGroup(Track track, String group, List before, List after) { post(TrackRemoveGroupEvent.class, () -> generate(TrackRemoveGroupEvent.class, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.copyOf(after), group)); } - public void handleUserCacheLoad(User user, UserCachedDataManager data) { + public void dispatchUserCacheLoad(User user, UserCachedDataManager data) { post(UserCacheLoadEvent.class, () -> generate(UserCacheLoadEvent.class, new ApiUser(user), data)); } - public void handleDataRecalculate(PermissionHolder holder) { + public void dispatchDataRecalculate(PermissionHolder holder) { if (holder.getType() == HolderType.USER) { User user = (User) holder; post(UserDataRecalculateEvent.class, () -> generate(UserDataRecalculateEvent.class, user.getApiDelegate(), user.getCachedData())); @@ -285,11 +285,11 @@ public final class EventFactory { } } - public void handleUserFirstLogin(UUID uniqueId, String username) { + public void dispatchUserFirstLogin(UUID uniqueId, String username) { post(UserFirstLoginEvent.class, () -> generate(UserFirstLoginEvent.class, uniqueId, username)); } - public void handlePlayerLoginProcess(UUID uniqueId, String username, User user) { + public void dispatchPlayerLoginProcess(UUID uniqueId, String username, User user) { if (!shouldPost(PlayerLoginProcessEvent.class)) { return; } @@ -297,22 +297,22 @@ public final class EventFactory { post(generate(PlayerLoginProcessEvent.class, uniqueId, username, new ApiUser(user))); } - public void handlePlayerDataSave(UUID uniqueId, String username, PlayerSaveResult result) { + public void dispatchPlayerDataSave(UUID uniqueId, String username, PlayerSaveResult result) { post(PlayerDataSaveEvent.class, () -> generate(PlayerDataSaveEvent.class, uniqueId, username, result)); } - public void handleUserLoad(User user) { + public void dispatchUserLoad(User user) { post(UserLoadEvent.class, () -> generate(UserLoadEvent.class, new ApiUser(user))); } - public void handleUserDemote(User user, Track track, String from, String to, @Nullable Sender source) { + public void dispatchUserDemote(User user, Track track, String from, String to, @Nullable Sender source) { post(UserDemoteEvent.class, () -> { Source s = source == null ? UnknownSource.INSTANCE : new EntitySourceImpl(new SenderPlatformEntity(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) { + public void dispatchUserPromote(User user, Track track, String from, String to, @Nullable Sender source) { post(UserPromoteEvent.class, () -> { Source s = source == null ? UnknownSource.INSTANCE : new EntitySourceImpl(new SenderPlatformEntity(source)); return generate(UserPromoteEvent.class, s, track.getApiDelegate(), new ApiUser(user), Optional.ofNullable(from), Optional.ofNullable(to)); diff --git a/common/src/main/java/me/lucko/luckperms/common/extension/SimpleExtensionManager.java b/common/src/main/java/me/lucko/luckperms/common/extension/SimpleExtensionManager.java index bfcf18a89..79b07a53e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/extension/SimpleExtensionManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/extension/SimpleExtensionManager.java @@ -82,7 +82,7 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable { this.plugin.getLogger().info("Loading extension: " + extension.getClass().getName()); this.extensions.add(new LoadedExtension(extension, null)); extension.load(); - this.plugin.getEventFactory().handleExtensionLoad(extension); + this.plugin.getEventDispatcher().dispatchExtensionLoad(extension); } public void loadExtensions(Path directory) { @@ -171,7 +171,7 @@ public class SimpleExtensionManager implements ExtensionManager, AutoCloseable { this.extensions.add(new LoadedExtension(extension, path)); extension.load(); - this.plugin.getEventFactory().handleExtensionLoad(extension); + this.plugin.getEventDispatcher().dispatchExtensionLoad(extension); return extension; } diff --git a/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java b/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java index dc7023d0a..2020dcccc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java +++ b/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java @@ -131,7 +131,7 @@ public class LuckPermsMessagingService implements InternalMessagingService, Inco this.plugin.getBootstrap().getScheduler().executeAsync(() -> { UUID requestId = generatePingId(); - if (this.plugin.getEventFactory().handleLogNetworkPublish(!this.plugin.getConfiguration().get(ConfigKeys.PUSH_LOG_ENTRIES), requestId, logEntry)) { + if (this.plugin.getEventDispatcher().dispatchLogNetworkPublish(!this.plugin.getConfiguration().get(ConfigKeys.PUSH_LOG_ENTRIES), requestId, logEntry)) { return; } @@ -233,7 +233,7 @@ public class LuckPermsMessagingService implements InternalMessagingService, Inco this.plugin.getLogger().info("[Messaging] Received update ping with id: " + msg.getId()); - if (this.plugin.getEventFactory().handleNetworkPreSync(false, msg.getId())) { + if (this.plugin.getEventDispatcher().dispatchNetworkPreSync(false, msg.getId())) { return; } @@ -248,7 +248,7 @@ public class LuckPermsMessagingService implements InternalMessagingService, Inco this.plugin.getLogger().info("[Messaging] Received user update ping for '" + user.getPlainDisplayName() + "' with id: " + msg.getId()); - if (this.plugin.getEventFactory().handleNetworkPreSync(false, msg.getId())) { + if (this.plugin.getEventDispatcher().dispatchNetworkPreSync(false, msg.getId())) { return; } @@ -256,7 +256,7 @@ public class LuckPermsMessagingService implements InternalMessagingService, Inco } else if (message instanceof ActionLogMessage) { ActionLogMessage msg = (ActionLogMessage) message; - this.plugin.getEventFactory().handleLogReceive(msg.getId(), msg.getAction()); + this.plugin.getEventDispatcher().dispatchLogReceive(msg.getId(), msg.getAction()); this.plugin.getLogDispatcher().dispatchFromRemote((LoggedAction) msg.getAction()); } else { throw new IllegalArgumentException("Unknown message type: " + message.getClass().getName()); diff --git a/common/src/main/java/me/lucko/luckperms/common/model/Group.java b/common/src/main/java/me/lucko/luckperms/common/model/Group.java index 420852b89..676251b8a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/Group.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/Group.java @@ -68,7 +68,7 @@ public class Group extends PermissionHolder { this.name = name.toLowerCase(); this.cachedData = new GroupCachedDataManager(this); - getPlugin().getEventFactory().handleGroupCacheLoad(this, this.cachedData); + getPlugin().getEventDispatcher().dispatchGroupCacheLoad(this, this.cachedData); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java index 89bdf904a..b237eb950 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java @@ -230,7 +230,7 @@ public abstract class PermissionHolder { this.transientNodes.invalidate(); getCachedData().invalidate(); - getPlugin().getEventFactory().handleDataRecalculate(this); + getPlugin().getEventDispatcher().dispatchDataRecalculate(this); } public void setNodes(DataType type, Collection set) { @@ -390,7 +390,7 @@ public abstract class PermissionHolder { // call event ImmutableCollection after = getData(dataType).immutable().values(); for (Node r : removed) { - this.plugin.getEventFactory().handleNodeRemove(r, this, dataType, before, after); + this.plugin.getEventDispatcher().dispatchNodeRemove(r, this, dataType, before, after); } } return work; @@ -421,7 +421,7 @@ public abstract class PermissionHolder { ImmutableCollection after = data.immutable().values(); if (callEvent) { - this.plugin.getEventFactory().handleNodeAdd(node, this, dataType, before, after); + this.plugin.getEventDispatcher().dispatchNodeAdd(node, this, dataType, before, after); } return DataMutateResult.SUCCESS; @@ -459,7 +459,7 @@ public abstract class PermissionHolder { invalidateCache(); ImmutableCollection after = data.immutable().values(); - this.plugin.getEventFactory().handleNodeAdd(newNode, this, dataType, before, after); + this.plugin.getEventDispatcher().dispatchNodeAdd(newNode, this, dataType, before, after); return new MergedNodeResult(DataMutateResult.SUCCESS, newNode); } @@ -481,7 +481,7 @@ public abstract class PermissionHolder { invalidateCache(); ImmutableCollection after = getData(dataType).immutable().values(); - this.plugin.getEventFactory().handleNodeRemove(node, this, dataType, before, after); + this.plugin.getEventDispatcher().dispatchNodeRemove(node, this, dataType, before, after); return DataMutateResult.SUCCESS; } @@ -507,7 +507,7 @@ public abstract class PermissionHolder { invalidateCache(); ImmutableCollection after = data.immutable().values(); - this.plugin.getEventFactory().handleNodeClear(this, dataType, before, after); + this.plugin.getEventDispatcher().dispatchNodeClear(this, dataType, before, after); return true; } @@ -534,7 +534,7 @@ public abstract class PermissionHolder { return false; } - this.plugin.getEventFactory().handleNodeClear(this, dataType, before, after); + this.plugin.getEventDispatcher().dispatchNodeClear(this, dataType, before, after); return true; } diff --git a/common/src/main/java/me/lucko/luckperms/common/model/Track.java b/common/src/main/java/me/lucko/luckperms/common/model/Track.java index d54d473ac..8485149a0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/Track.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/Track.java @@ -184,7 +184,7 @@ public final class Track { this.groups.add(group.getName()); List after = ImmutableList.copyOf(this.groups); - this.plugin.getEventFactory().handleTrackAddGroup(this, group.getName(), before, after); + this.plugin.getEventDispatcher().dispatchTrackAddGroup(this, group.getName(), before, after); return DataMutateResult.SUCCESS; } @@ -205,7 +205,7 @@ public final class Track { this.groups.add(position, group.getName()); List after = ImmutableList.copyOf(this.groups); - this.plugin.getEventFactory().handleTrackAddGroup(this, group.getName(), before, after); + this.plugin.getEventDispatcher().dispatchTrackAddGroup(this, group.getName(), before, after); return DataMutateResult.SUCCESS; } @@ -234,7 +234,7 @@ public final class Track { this.groups.remove(group); List after = ImmutableList.copyOf(this.groups); - this.plugin.getEventFactory().handleTrackRemoveGroup(this, group, before, after); + this.plugin.getEventDispatcher().dispatchTrackRemoveGroup(this, group, before, after); return DataMutateResult.SUCCESS; } @@ -264,7 +264,7 @@ public final class Track { public void clearGroups() { List before = ImmutableList.copyOf(this.groups); this.groups.clear(); - this.plugin.getEventFactory().handleTrackClear(this, before); + this.plugin.getEventDispatcher().dispatchTrackClear(this, before); } public PromotionResult promote(User user, ContextSet context, Predicate nextGroupPermissionChecker, @Nullable Sender sender, boolean addToFirst) { @@ -296,7 +296,7 @@ public final class Track { } user.setNode(DataType.NORMAL, Inheritance.builder(nextGroup.getName()).withContext(context).build(), true); - this.plugin.getEventFactory().handleUserPromote(user, this, null, first, sender); + this.plugin.getEventDispatcher().dispatchUserPromote(user, this, null, first, sender); return PromotionResults.addedToFirst(first); } @@ -328,7 +328,7 @@ public final class Track { user.getPrimaryGroup().setStoredValue(nextGroup.getName()); } - this.plugin.getEventFactory().handleUserPromote(user, this, old, nextGroup.getName(), sender); + this.plugin.getEventDispatcher().dispatchUserPromote(user, this, old, nextGroup.getName(), sender); return PromotionResults.success(old, nextGroup.getName()); } @@ -366,7 +366,7 @@ public final class Track { } user.unsetNode(DataType.NORMAL, oldNode); - this.plugin.getEventFactory().handleUserDemote(user, this, old, null, sender); + this.plugin.getEventDispatcher().dispatchUserDemote(user, this, old, null, sender); return DemotionResults.removedFromFirst(old); } @@ -382,7 +382,7 @@ public final class Track { user.getPrimaryGroup().setStoredValue(previousGroup.getName()); } - this.plugin.getEventFactory().handleUserDemote(user, this, old, previousGroup.getName(), sender); + this.plugin.getEventDispatcher().dispatchUserDemote(user, this, old, previousGroup.getName(), sender); return DemotionResults.success(old, previousGroup.getName()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/model/User.java b/common/src/main/java/me/lucko/luckperms/common/model/User.java index acefe3898..d9dc9db93 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/User.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/User.java @@ -63,7 +63,7 @@ public class User extends PermissionHolder { this.uniqueId = uniqueId; this.primaryGroup = plugin.getConfiguration().get(ConfigKeys.PRIMARY_GROUP_CALCULATION).apply(this); this.cachedData = new UserCachedDataManager(this); - getPlugin().getEventFactory().handleUserCacheLoad(this, this.cachedData); + getPlugin().getEventDispatcher().dispatchUserCacheLoad(this, this.cachedData); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java index db9157bab..128437e73 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java @@ -38,7 +38,7 @@ import me.lucko.luckperms.common.context.LPStaticContextsCalculator; import me.lucko.luckperms.common.dependencies.Dependency; import me.lucko.luckperms.common.dependencies.DependencyManager; import me.lucko.luckperms.common.event.AbstractEventBus; -import me.lucko.luckperms.common.event.EventFactory; +import me.lucko.luckperms.common.event.EventDispatcher; import me.lucko.luckperms.common.extension.SimpleExtensionManager; import me.lucko.luckperms.common.inheritance.InheritanceHandler; import me.lucko.luckperms.common.locale.LocaleManager; @@ -85,7 +85,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { private InheritanceHandler inheritanceHandler; private CalculatorFactory calculatorFactory; private LuckPermsApiProvider apiProvider; - private EventFactory eventFactory; + private EventDispatcher eventDispatcher; private SimpleExtensionManager extensionManager; /** @@ -170,7 +170,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { // register with the LP API this.apiProvider = new LuckPermsApiProvider(this); - this.eventFactory = new EventFactory(provideEventBus(this.apiProvider)); + this.eventDispatcher = new EventDispatcher(provideEventBus(this.apiProvider)); ApiRegistrationUtil.registerProvider(this.apiProvider); registerApiOnPlatform(this.apiProvider); @@ -353,8 +353,8 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { } @Override - public EventFactory getEventFactory() { - return this.eventFactory; + public EventDispatcher getEventDispatcher() { + return this.eventDispatcher; } private void displayBanner(Sender sender) { diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java index 1ac7ab84b..5ec15c58e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java @@ -33,7 +33,7 @@ import me.lucko.luckperms.common.command.abstraction.Command; import me.lucko.luckperms.common.config.LuckPermsConfiguration; import me.lucko.luckperms.common.context.ContextManager; import me.lucko.luckperms.common.dependencies.DependencyManager; -import me.lucko.luckperms.common.event.EventFactory; +import me.lucko.luckperms.common.event.EventDispatcher; import me.lucko.luckperms.common.extension.SimpleExtensionManager; import me.lucko.luckperms.common.inheritance.InheritanceHandler; import me.lucko.luckperms.common.locale.LocaleManager; @@ -134,11 +134,11 @@ public interface LuckPermsPlugin { PluginLogger getLogger(); /** - * Gets the event factory + * Gets the event dispatcher * - * @return the event factory + * @return the event dispatcher */ - EventFactory getEventFactory(); + EventDispatcher getEventDispatcher(); /** * Returns the class implementing the LuckPermsAPI on this platform. diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/util/AbstractConnectionListener.java b/common/src/main/java/me/lucko/luckperms/common/plugin/util/AbstractConnectionListener.java index 353328f65..62f5e3f1d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/util/AbstractConnectionListener.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/util/AbstractConnectionListener.java @@ -71,7 +71,7 @@ public abstract class AbstractConnectionListener { // fire UserFirstLogin event if (saveResult.includes(PlayerSaveResult.Outcome.CLEAN_INSERT)) { - this.plugin.getEventFactory().handleUserFirstLogin(uniqueId, username); + this.plugin.getEventDispatcher().dispatchUserFirstLogin(uniqueId, username); } // most likely because ip forwarding is not setup correctly diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java b/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java index bab967018..f0ec2535b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java @@ -147,7 +147,7 @@ public class Storage { return makeFuture(() -> { User user = this.implementation.loadUser(uniqueId, username); if (user != null) { - this.plugin.getEventFactory().handleUserLoad(user); + this.plugin.getEventDispatcher().dispatchUserLoad(user); } return user; }); @@ -173,7 +173,7 @@ public class Storage { return makeFuture(() -> { Group group = this.implementation.createAndLoadGroup(name); if (group != null) { - this.plugin.getEventFactory().handleGroupCreate(group, cause); + this.plugin.getEventDispatcher().dispatchGroupCreate(group, cause); } return group; }); @@ -183,7 +183,7 @@ public class Storage { return makeFuture(() -> { Optional group = this.implementation.loadGroup(name); if (group.isPresent()) { - this.plugin.getEventFactory().handleGroupLoad(group.get()); + this.plugin.getEventDispatcher().dispatchGroupLoad(group.get()); } return group; }); @@ -192,7 +192,7 @@ public class Storage { public CompletableFuture loadAllGroups() { return makeFuture(() -> { this.implementation.loadAllGroups(); - this.plugin.getEventFactory().handleGroupLoadAll(); + this.plugin.getEventDispatcher().dispatchGroupLoadAll(); }); } @@ -203,7 +203,7 @@ public class Storage { public CompletableFuture deleteGroup(Group group, DeletionCause cause) { return makeFuture(() -> { this.implementation.deleteGroup(group); - this.plugin.getEventFactory().handleGroupDelete(group, cause); + this.plugin.getEventDispatcher().dispatchGroupDelete(group, cause); }); } @@ -219,7 +219,7 @@ public class Storage { return makeFuture(() -> { Track track = this.implementation.createAndLoadTrack(name); if (track != null) { - this.plugin.getEventFactory().handleTrackCreate(track, cause); + this.plugin.getEventDispatcher().dispatchTrackCreate(track, cause); } return track; }); @@ -229,7 +229,7 @@ public class Storage { return makeFuture(() -> { Optional track = this.implementation.loadTrack(name); if (track.isPresent()) { - this.plugin.getEventFactory().handleTrackLoad(track.get()); + this.plugin.getEventDispatcher().dispatchTrackLoad(track.get()); } return track; }); @@ -238,7 +238,7 @@ public class Storage { public CompletableFuture loadAllTracks() { return makeFuture(() -> { this.implementation.loadAllTracks(); - this.plugin.getEventFactory().handleTrackLoadAll(); + this.plugin.getEventDispatcher().dispatchTrackLoadAll(); }); } @@ -249,7 +249,7 @@ public class Storage { public CompletableFuture deleteTrack(Track track, DeletionCause cause) { return makeFuture(() -> { this.implementation.deleteTrack(track); - this.plugin.getEventFactory().handleTrackDelete(track, cause); + this.plugin.getEventDispatcher().dispatchTrackDelete(track, cause); }); } @@ -257,7 +257,7 @@ public class Storage { return makeFuture(() -> { PlayerSaveResult result = this.implementation.savePlayerData(uniqueId, username); if (result != null) { - this.plugin.getEventFactory().handlePlayerDataSave(uniqueId, username, result); + this.plugin.getEventDispatcher().dispatchPlayerDataSave(uniqueId, username, result); } return result; }); diff --git a/common/src/main/java/me/lucko/luckperms/common/tasks/SyncTask.java b/common/src/main/java/me/lucko/luckperms/common/tasks/SyncTask.java index b99e1a2fe..7fbea1e50 100644 --- a/common/src/main/java/me/lucko/luckperms/common/tasks/SyncTask.java +++ b/common/src/main/java/me/lucko/luckperms/common/tasks/SyncTask.java @@ -59,7 +59,7 @@ public class SyncTask implements Runnable { */ @Override public void run() { - if (this.plugin.getEventFactory().handlePreSync(false)) { + if (this.plugin.getEventDispatcher().dispatchPreSync(false)) { return; } @@ -80,7 +80,7 @@ public class SyncTask implements Runnable { this.plugin.performPlatformDataSync(); - this.plugin.getEventFactory().handlePostSync(); + this.plugin.getEventDispatcher().dispatchPostSync(); } public static class Buffer extends BufferedRequest { diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitConnectionListener.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitConnectionListener.java index f4a3ad5ef..4f12c2430 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitConnectionListener.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/listeners/NukkitConnectionListener.java @@ -86,7 +86,7 @@ public class NukkitConnectionListener extends AbstractConnectionListener impleme try { User user = loadUser(e.getUuid(), e.getName()); recordConnection(e.getUuid()); - this.plugin.getEventFactory().handlePlayerLoginProcess(e.getUuid(), e.getName(), user); + this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(e.getUuid(), e.getName(), user); } catch (Exception ex) { this.plugin.getLogger().severe("Exception occurred whilst loading data for " + e.getUuid() + " - " + e.getName()); ex.printStackTrace(); @@ -94,7 +94,7 @@ public class NukkitConnectionListener extends AbstractConnectionListener impleme // deny the connection this.deniedAsyncLogin.add(e.getUuid()); e.disAllow(Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager())); - this.plugin.getEventFactory().handlePlayerLoginProcess(e.getUuid(), e.getName(), null); + this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(e.getUuid(), e.getName(), null); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java b/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java index b47546363..ed8801019 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongeConnectionListener.java @@ -88,7 +88,7 @@ public class SpongeConnectionListener extends AbstractConnectionListener { try { User user = loadUser(profile.getUniqueId(), username); recordConnection(profile.getUniqueId()); - this.plugin.getEventFactory().handlePlayerLoginProcess(profile.getUniqueId(), username, user); + this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(profile.getUniqueId(), username, user); } catch (Exception ex) { this.plugin.getLogger().severe("Exception occurred whilst loading data for " + profile.getUniqueId() + " - " + profile.getName()); ex.printStackTrace(); @@ -99,7 +99,7 @@ public class SpongeConnectionListener extends AbstractConnectionListener { e.setMessageCancelled(false); //noinspection deprecation e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_DATABASE_ERROR.asString(this.plugin.getLocaleManager()))); - this.plugin.getEventFactory().handlePlayerLoginProcess(profile.getUniqueId(), username, null); + this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(profile.getUniqueId(), username, null); } } diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/listeners/VelocityConnectionListener.java b/velocity/src/main/java/me/lucko/luckperms/velocity/listeners/VelocityConnectionListener.java index 8c77dd6be..a1482b25e 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/listeners/VelocityConnectionListener.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/listeners/VelocityConnectionListener.java @@ -88,7 +88,7 @@ public class VelocityConnectionListener extends AbstractConnectionListener { User user = loadUser(p.getUniqueId(), p.getUsername()); recordConnection(p.getUniqueId()); e.setProvider(new PlayerPermissionProvider(p, user, this.plugin.getContextManager().getCacheFor(p))); - this.plugin.getEventFactory().handlePlayerLoginProcess(p.getUniqueId(), p.getUsername(), user); + this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(p.getUniqueId(), p.getUsername(), user); } catch (Exception ex) { this.plugin.getLogger().severe("Exception occurred whilst loading data for " + p.getUniqueId() + " - " + p.getUsername()); ex.printStackTrace(); @@ -98,7 +98,7 @@ public class VelocityConnectionListener extends AbstractConnectionListener { // cancel the login attempt this.deniedLogin.add(p.getUniqueId()); } - this.plugin.getEventFactory().handlePlayerLoginProcess(p.getUniqueId(), p.getUsername(), null); + this.plugin.getEventDispatcher().dispatchPlayerLoginProcess(p.getUniqueId(), p.getUsername(), null); } }