Rename EventFactory --> EventDispatcher

This commit is contained in:
Luck 2019-12-24 13:05:48 +00:00
parent cd5c8d7cdf
commit 63b890d522
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
20 changed files with 98 additions and 98 deletions

View File

@ -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);
}
}

View File

@ -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.

View File

@ -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);
}
}

View File

@ -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

View File

@ -93,7 +93,7 @@ public class AbstractConfiguration implements LuckPermsConfiguration {
this.adapter.reload();
load();
getPlugin().getEventFactory().handleConfigReload();
getPlugin().getEventDispatcher().dispatchConfigReload();
}
@Override

View File

@ -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<? extends Node> before, Collection<? extends Node> after) {
public void dispatchNodeAdd(Node node, PermissionHolder target, DataType dataType, Collection<? extends Node> before, Collection<? extends Node> 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<? extends Node> before, Collection<? extends Node> after) {
public void dispatchNodeClear(PermissionHolder target, DataType dataType, Collection<? extends Node> before, Collection<? extends Node> 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<? extends Node> before, Collection<? extends Node> after) {
public void dispatchNodeRemove(Node node, PermissionHolder target, DataType dataType, Collection<? extends Node> before, Collection<? extends Node> 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<String> before, List<String> after) {
public void dispatchTrackAddGroup(Track track, String group, List<String> before, List<String> after) {
post(TrackAddGroupEvent.class, () -> generate(TrackAddGroupEvent.class, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.copyOf(after), group));
}
public void handleTrackClear(Track track, List<String> before) {
public void dispatchTrackClear(Track track, List<String> before) {
post(TrackClearEvent.class, () -> generate(TrackClearEvent.class, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.of()));
}
public void handleTrackRemoveGroup(Track track, String group, List<String> before, List<String> after) {
public void dispatchTrackRemoveGroup(Track track, String group, List<String> before, List<String> 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));

View File

@ -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;
}

View File

@ -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());

View File

@ -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

View File

@ -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<? extends Node> set) {
@ -390,7 +390,7 @@ public abstract class PermissionHolder {
// call event
ImmutableCollection<? extends Node> 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<? extends Node> 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<? extends Node> 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<? extends Node> 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<? extends Node> 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;
}

View File

@ -184,7 +184,7 @@ public final class Track {
this.groups.add(group.getName());
List<String> 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<String> 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<String> 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<String> 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<String> 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());
}

View File

@ -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

View File

@ -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) {

View File

@ -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.

View File

@ -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

View File

@ -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> 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<Void> loadAllGroups() {
return makeFuture(() -> {
this.implementation.loadAllGroups();
this.plugin.getEventFactory().handleGroupLoadAll();
this.plugin.getEventDispatcher().dispatchGroupLoadAll();
});
}
@ -203,7 +203,7 @@ public class Storage {
public CompletableFuture<Void> 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> 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<Void> loadAllTracks() {
return makeFuture(() -> {
this.implementation.loadAllTracks();
this.plugin.getEventFactory().handleTrackLoadAll();
this.plugin.getEventDispatcher().dispatchTrackLoadAll();
});
}
@ -249,7 +249,7 @@ public class Storage {
public CompletableFuture<Void> 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;
});

View File

@ -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<Void> {

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}