From 31df29194bdb70d890eb3971912a09b0ae7b1289 Mon Sep 17 00:00:00 2001 From: Luck Date: Thu, 1 Feb 2018 21:33:32 +0000 Subject: [PATCH] Add source to UserPromote & UserDemote events (#722) --- .../java/me/lucko/luckperms/api/Entity.java | 87 +++++++++++++++++++ .../me/lucko/luckperms/api/event/Sourced.java | 50 +++++++++++ .../api/event/log/LogNotifyEvent.java | 43 +++------ .../api/event/source/EntitySource.java | 47 ++++++++++ .../luckperms/api/event/source/Source.java | 67 ++++++++++++++ .../api/event/user/track/UserTrackEvent.java | 3 +- .../common/actionlog/LogDispatcher.java | 9 +- .../common/commands/impl/user/UserDemote.java | 4 +- .../commands/impl/user/UserPromote.java | 4 +- .../luckperms/common/event/EventFactory.java | 13 +-- .../common/event/impl/EventConfigReload.java | 2 +- .../event/impl/EventGroupCacheLoad.java | 2 +- .../common/event/impl/EventGroupCreate.java | 2 +- .../event/impl/EventGroupDataRecalculate.java | 2 +- .../common/event/impl/EventGroupDelete.java | 5 +- .../common/event/impl/EventGroupLoad.java | 2 +- .../common/event/impl/EventGroupLoadAll.java | 2 +- .../common/event/impl/EventLogBroadcast.java | 5 +- .../event/impl/EventLogNetworkPublish.java | 5 +- .../common/event/impl/EventLogNotify.java | 60 +++---------- .../common/event/impl/EventLogPublish.java | 2 +- .../common/event/impl/EventLogReceive.java | 2 +- .../common/event/impl/EventNodeAdd.java | 6 +- .../common/event/impl/EventNodeClear.java | 5 +- .../common/event/impl/EventNodeRemove.java | 6 +- .../common/event/impl/EventPostSync.java | 2 +- .../event/impl/EventPreNetworkSync.java | 4 +- .../common/event/impl/EventPreSync.java | 2 +- .../common/event/impl/EventTrackAddGroup.java | 6 +- .../common/event/impl/EventTrackClear.java | 5 +- .../common/event/impl/EventTrackCreate.java | 2 +- .../common/event/impl/EventTrackDelete.java | 5 +- .../common/event/impl/EventTrackLoad.java | 2 +- .../common/event/impl/EventTrackLoadAll.java | 2 +- .../event/impl/EventTrackRemoveGroup.java | 6 +- .../common/event/impl/EventUserCacheLoad.java | 2 +- .../event/impl/EventUserDataRecalculate.java | 2 +- .../common/event/impl/EventUserDemote.java | 19 +++- .../event/impl/EventUserFirstLogin.java | 2 +- .../common/event/impl/EventUserLoad.java | 2 +- .../event/impl/EventUserLoginProcess.java | 2 +- .../common/event/impl/EventUserPromote.java | 19 +++- .../common/event/model/EntitySender.java | 72 +++++++++++++++ .../common/event/model/SourceEntity.java | 56 ++++++++++++ .../common/event/model/SourceUnknown.java | 49 +++++++++++ 45 files changed, 570 insertions(+), 126 deletions(-) create mode 100644 api/src/main/java/me/lucko/luckperms/api/Entity.java create mode 100644 api/src/main/java/me/lucko/luckperms/api/event/Sourced.java create mode 100644 api/src/main/java/me/lucko/luckperms/api/event/source/EntitySource.java create mode 100644 api/src/main/java/me/lucko/luckperms/api/event/source/Source.java create mode 100644 common/src/main/java/me/lucko/luckperms/common/event/model/EntitySender.java create mode 100644 common/src/main/java/me/lucko/luckperms/common/event/model/SourceEntity.java create mode 100644 common/src/main/java/me/lucko/luckperms/common/event/model/SourceUnknown.java diff --git a/api/src/main/java/me/lucko/luckperms/api/Entity.java b/api/src/main/java/me/lucko/luckperms/api/Entity.java new file mode 100644 index 000000000..4f0d512ac --- /dev/null +++ b/api/src/main/java/me/lucko/luckperms/api/Entity.java @@ -0,0 +1,87 @@ +/* + * 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.api; + +import java.util.UUID; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Represents an entity on the server. + * + *

This does not relate directly to a "Minecraft Entity". The closest + * comparison is to a "CommandSender" or "CommandSource" in Bukkit/Sponge.

+ * + *

The various types of {@link Entity} are detailed in {@link Type}.

+ * + * @since 4.1 + */ +public interface Entity { + + /** + * Gets the unique id of the entity, if it has one. + * + *

For players, this returns their uuid assigned by the server.

+ * + * @return the uuid of the object, if available + */ + @Nullable + UUID getUniqueId(); + + /** + * Gets the name of the object + * + * @return the object name + */ + @Nonnull + String getName(); + + /** + * Gets the entities type. + * + * @return the type + */ + @Nonnull + Type getType(); + + /** + * The different types of {@link Entity} + */ + enum Type { + + /** + * Represents a player connected to the server + */ + PLAYER, + + /** + * Represents the server console + */ + CONSOLE + } + +} 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 new file mode 100644 index 000000000..c1ec7a30c --- /dev/null +++ b/api/src/main/java/me/lucko/luckperms/api/event/Sourced.java @@ -0,0 +1,50 @@ +/* + * 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.api.event; + +import me.lucko.luckperms.api.event.source.Source; + +import javax.annotation.Nonnull; + +/** + * Represents an event with a {@link Source}. + * + * @since 4.1 + */ +public interface Sourced { + + /** + * Gets the events source. + * + *

Never returns null. In situations where the source is unknown, a + * {@link Source} with type {@link Source.Type#UNKNOWN} is returned.

+ * + * @return the source + */ + @Nonnull + Source getSource(); + +} 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 20a7d2726..299bcf2b2 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 @@ -25,13 +25,11 @@ package me.lucko.luckperms.api.event.log; +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 java.util.Optional; -import java.util.UUID; - import javax.annotation.Nonnull; /** @@ -60,7 +58,7 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable { * @return the origin of the log */ @Nonnull - LogBroadcastEvent.Origin getOrigin(); + Origin getOrigin(); /** * Gets the object to be notified. @@ -68,46 +66,27 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable { * @return the object to notify */ @Nonnull - Notifiable getNotifiable(); + Entity getNotifiable(); /** - * Represents an object which could be notified as a result of a - * {@link LogNotifyEvent}. + * Represents where a log entry is from */ - interface Notifiable { + enum Origin { /** - * Gets a {@link UUID} for the object, if it has one. - * - *

For Players, this method returns their unique id.

- * - * @return the uuid of the object, if available + * Marks a log entry which originated from the current server instance */ - @Nonnull - Optional getUuid(); + LOCAL, /** - * Gets the name of the object - * - * @return the name + * Marks a log entry which originated from an API call on the current server instance */ - @Nonnull - String getName(); + LOCAL_API, /** - * Gets if the object is a console - * - * @return if the object is a console + * Marks a log entry which was sent to this server via the messaging service */ - boolean isConsole(); - - /** - * Gets if the object is a player - * - * @return if the object is a player - */ - boolean isPlayer(); - + REMOTE } } diff --git a/api/src/main/java/me/lucko/luckperms/api/event/source/EntitySource.java b/api/src/main/java/me/lucko/luckperms/api/event/source/EntitySource.java new file mode 100644 index 000000000..746ebc455 --- /dev/null +++ b/api/src/main/java/me/lucko/luckperms/api/event/source/EntitySource.java @@ -0,0 +1,47 @@ +/* + * 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.api.event.source; + +import me.lucko.luckperms.api.Entity; + +import javax.annotation.Nonnull; + +/** + * Represents an {@link Entity} which was the {@link Source} of something. + * + * @since 4.1 + */ +public interface EntitySource extends Source { + + /** + * Gets the entity. + * + * @return the entity + */ + @Nonnull + Entity getEntity(); + +} diff --git a/api/src/main/java/me/lucko/luckperms/api/event/source/Source.java b/api/src/main/java/me/lucko/luckperms/api/event/source/Source.java new file mode 100644 index 000000000..ded9e6d54 --- /dev/null +++ b/api/src/main/java/me/lucko/luckperms/api/event/source/Source.java @@ -0,0 +1,67 @@ +/* + * 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.api.event.source; + +import me.lucko.luckperms.api.Entity; + +import javax.annotation.Nonnull; + +/** + * Represents the source of an event. + * + *

Could also be described as the "thing" that caused an event to occur.

+ * + * @since 4.1 + */ +public interface Source { + + /** + * Gets the source type + * + * @return the type + */ + @Nonnull + Type getType(); + + /** + * Represents a type of source + */ + enum Type { + + /** + * Represents an {@link Entity} source + * + * @see EntitySource + */ + ENTITY, + + /** + * Represents an unknown source + */ + UNKNOWN + } + +} 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 690f08db8..4c8ead719 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.Sourced; import java.util.Optional; @@ -36,7 +37,7 @@ import javax.annotation.Nonnull; /** * Called when a user interacts with a track through a promotion or demotion */ -public interface UserTrackEvent extends LuckPermsEvent { +public interface UserTrackEvent extends LuckPermsEvent, Sourced { /** * Gets the track involved in the event 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 361edd088..77d4b4989 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 @@ -26,6 +26,7 @@ package me.lucko.luckperms.common.actionlog; import me.lucko.luckperms.api.event.log.LogBroadcastEvent; +import me.lucko.luckperms.api.event.log.LogNotifyEvent; import me.lucko.luckperms.common.commands.CommandPermission; import me.lucko.luckperms.common.commands.impl.log.LogNotify; import me.lucko.luckperms.common.commands.sender.Sender; @@ -43,7 +44,7 @@ public class LogDispatcher { this.plugin = plugin; } - private void broadcast(ExtendedLogEntry entry, LogBroadcastEvent.Origin origin, Sender sender) { + private void broadcast(ExtendedLogEntry entry, LogNotifyEvent.Origin origin, Sender sender) { this.plugin.getOnlineSenders() .filter(CommandPermission.LOG_NOTIFY::isAuthorized) .filter(s -> { @@ -76,7 +77,7 @@ public class LogDispatcher { boolean shouldCancel = !this.plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY); if (!this.plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL)) { - broadcast(entry, LogBroadcastEvent.Origin.LOCAL, sender); + broadcast(entry, LogNotifyEvent.Origin.LOCAL, sender); } } @@ -97,14 +98,14 @@ public class LogDispatcher { boolean shouldCancel = !this.plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY); if (!this.plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL_API)) { - broadcast(entry, LogBroadcastEvent.Origin.LOCAL_API, null); + broadcast(entry, LogNotifyEvent.Origin.LOCAL_API, null); } } public void dispatchFromRemote(ExtendedLogEntry 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)) { - broadcast(entry, LogBroadcastEvent.Origin.LOCAL_API, null); + broadcast(entry, LogNotifyEvent.Origin.LOCAL_API, null); } } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java index c4fe88f48..1c47fbdf0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java @@ -133,7 +133,7 @@ public class UserDemote extends SubCommand { .build().submit(plugin, sender); save(user, sender, plugin); - plugin.getEventFactory().handleUserDemote(user, track, old, null); + plugin.getEventFactory().handleUserDemote(user, track, old, null, sender); return CommandResult.SUCCESS; } @@ -160,7 +160,7 @@ public class UserDemote extends SubCommand { .build().submit(plugin, sender); save(user, sender, plugin); - plugin.getEventFactory().handleUserDemote(user, track, old, previousGroup.getName()); + plugin.getEventFactory().handleUserDemote(user, track, old, previousGroup.getName(), sender); return CommandResult.SUCCESS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java index ba798e511..ecda5d85a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java @@ -120,7 +120,7 @@ public class UserPromote extends SubCommand { .build().submit(plugin, sender); save(user, sender, plugin); - plugin.getEventFactory().handleUserPromote(user, track, null, first); + plugin.getEventFactory().handleUserPromote(user, track, null, first, sender); return CommandResult.SUCCESS; } @@ -177,7 +177,7 @@ public class UserPromote extends SubCommand { .build().submit(plugin, sender); save(user, sender, plugin); - plugin.getEventFactory().handleUserPromote(user, track, old, nextGroup.getName()); + plugin.getEventFactory().handleUserPromote(user, track, old, nextGroup.getName(), sender); return CommandResult.SUCCESS; } 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 ba24a79b7..4f6df8f2f 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 @@ -36,6 +36,7 @@ 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.log.LogBroadcastEvent; +import me.lucko.luckperms.api.event.log.LogNotifyEvent; import me.lucko.luckperms.common.api.LuckPermsApiProvider; import me.lucko.luckperms.common.api.delegates.model.ApiPermissionHolder; import me.lucko.luckperms.common.api.delegates.model.ApiUser; @@ -72,6 +73,8 @@ 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.model.EntitySender; +import me.lucko.luckperms.common.event.model.SourceEntity; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; @@ -153,7 +156,7 @@ public final class EventFactory { return cancel.get(); } - public boolean handleLogNotify(boolean initialState, LogEntry entry, LogBroadcastEvent.Origin origin, Sender sender) { + 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); @@ -264,13 +267,13 @@ public final class EventFactory { fireEvent(event); } - public void handleUserDemote(User user, Track track, String from, String to) { - EventUserDemote event = new EventUserDemote(track.getApiDelegate(), new ApiUser(user), from, to); + public void handleUserDemote(User user, Track track, String from, String to, Sender source) { + EventUserDemote event = new EventUserDemote(track.getApiDelegate(), new ApiUser(user), from, to, new SourceEntity(new EntitySender(source))); fireEventAsync(event); } - public void handleUserPromote(User user, Track track, String from, String to) { - EventUserPromote event = new EventUserPromote(track.getApiDelegate(), new ApiUser(user), from, to); + public void handleUserPromote(User user, Track track, String from, String to, Sender source) { + EventUserPromote event = new EventUserPromote(track.getApiDelegate(), new ApiUser(user), from, to, new SourceEntity(new EntitySender(source))); fireEventAsync(event); } 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 index 04ec6b9d3..908c13603 100644 --- 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 @@ -32,6 +32,6 @@ public class EventConfigReload extends AbstractEvent implements ConfigReloadEven @Override public String toString() { - return "EventConfigReload()"; + 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 index 31489aed1..2e421a1e4 100644 --- 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 @@ -56,6 +56,6 @@ public class EventGroupCacheLoad extends AbstractEvent implements GroupCacheLoad @Override public String toString() { - return "EventGroupCacheLoad(group=" + this.getGroup() + ", loadedData=" + this.getLoadedData() + ")"; + 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 index 632250cef..55cab3e34 100644 --- 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 @@ -56,6 +56,6 @@ public class EventGroupCreate extends AbstractEvent implements GroupCreateEvent @Override public String toString() { - return "EventGroupCreate(group=" + this.getGroup() + ", cause=" + this.getCause() + ")"; + 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 index 416cf90e3..a152b3cf2 100644 --- 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 @@ -56,6 +56,6 @@ public class EventGroupDataRecalculate extends AbstractEvent implements GroupDat @Override public String toString() { - return "EventGroupDataRecalculate(group=" + this.getGroup() + ", data=" + this.getData() + ")"; + 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 index eacc131c4..7cd1adb88 100644 --- 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 @@ -66,6 +66,9 @@ public class EventGroupDelete extends AbstractEvent implements GroupDeleteEvent @Override public String toString() { - return "EventGroupDelete(groupName=" + this.getGroupName() + ", existingData=" + this.getExistingData() + ", cause=" + this.getCause() + ")"; + 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 index 305d7f91a..3289d4b6d 100644 --- 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 @@ -47,6 +47,6 @@ public class EventGroupLoad extends AbstractEvent implements GroupLoadEvent { @Override public String toString() { - return "EventGroupLoad(group=" + this.getGroup() + ")"; + 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 index b411fce54..933763e9a 100644 --- 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 @@ -32,6 +32,6 @@ public class EventGroupLoadAll extends AbstractEvent implements GroupLoadAllEven @Override public String toString() { - return "EventGroupLoadAll()"; + 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 index 43a79c0c5..57fa84ea6 100644 --- 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 @@ -65,6 +65,9 @@ public class EventLogBroadcast extends AbstractEvent implements LogBroadcastEven @Override public String toString() { - return "EventLogBroadcast(cancellationState=" + this.getCancellationState() + ", entry=" + this.getEntry() + ", origin=" + this.getOrigin() + ")"; + 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 index 2afc2880c..1735fa632 100644 --- 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 @@ -66,6 +66,9 @@ public class EventLogNetworkPublish extends AbstractEvent implements LogNetworkP @Override public String toString() { - return "EventLogNetworkPublish(cancellationState=" + this.getCancellationState() + ", logId=" + this.getLogId() + ", entry=" + this.getEntry() + ")"; + 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 index fbe77a347..ee6ccb469 100644 --- 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 @@ -25,14 +25,13 @@ 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.LogBroadcastEvent; import me.lucko.luckperms.api.event.log.LogNotifyEvent; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.event.AbstractEvent; +import me.lucko.luckperms.common.event.model.EntitySender; -import java.util.Optional; -import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nonnull; @@ -41,12 +40,12 @@ public class EventLogNotify extends AbstractEvent implements LogNotifyEvent { private final AtomicBoolean cancellationState; private final LogEntry entry; - private final LogBroadcastEvent.Origin origin; + private final Origin origin; private final Sender sender; - private Notifiable notifiable; + private Entity notifiable; - public EventLogNotify(AtomicBoolean cancellationState, LogEntry entry, LogBroadcastEvent.Origin origin, Sender sender) { + public EventLogNotify(AtomicBoolean cancellationState, LogEntry entry, Origin origin, Sender sender) { this.cancellationState = cancellationState; this.entry = entry; this.origin = origin; @@ -55,9 +54,9 @@ public class EventLogNotify extends AbstractEvent implements LogNotifyEvent { @Nonnull @Override - public synchronized Notifiable getNotifiable() { + public synchronized Entity getNotifiable() { if (this.notifiable == null) { - this.notifiable = new SenderNotifiable(this.sender); + this.notifiable = new EntitySender(this.sender); } return this.notifiable; } @@ -76,50 +75,17 @@ public class EventLogNotify extends AbstractEvent implements LogNotifyEvent { @Nonnull @Override - public LogBroadcastEvent.Origin getOrigin() { + public Origin getOrigin() { return this.origin; } - public Sender getSender() { - return this.sender; - } - @Override public String toString() { - return "EventLogNotify(cancellationState=" + this.getCancellationState() + ", entry=" + this.getEntry() + ", origin=" + this.getOrigin() + ", sender=" + this.getSender() + ", notifiable=" + this.getNotifiable() + ")"; - } - - private static final class SenderNotifiable implements Notifiable { - private final Sender sender; - - public SenderNotifiable(Sender sender) { - this.sender = sender; - } - - @Nonnull - @Override - public Optional getUuid() { - if (this.sender.isConsole()) { - return Optional.empty(); - } - return Optional.of(this.sender.getUuid()); - } - - @Nonnull - @Override - public String getName() { - return this.sender.getName(); - } - - @Override - public boolean isConsole() { - return this.sender.isConsole(); - } - - @Override - public boolean isPlayer() { - return !this.sender.isConsole(); - } + 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 index 262cb80e8..3f40129c8 100644 --- 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 @@ -57,6 +57,6 @@ public class EventLogPublish extends AbstractEvent implements LogPublishEvent { @Override public String toString() { - return "EventLogPublish(cancellationState=" + this.getCancellationState() + ", entry=" + this.getEntry() + ")"; + 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 index bc271ebe5..7fccae350 100644 --- 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 @@ -57,6 +57,6 @@ public class EventLogReceive extends AbstractEvent implements LogReceiveEvent { @Override public String toString() { - return "EventLogReceive(logId=" + this.getLogId() + ", entry=" + this.getEntry() + ")"; + 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 index 436d1d0f9..282427f91 100644 --- 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 @@ -86,6 +86,10 @@ public class EventNodeAdd extends AbstractEvent implements NodeAddEvent { @Override public String toString() { - return "EventNodeAdd(node=" + this.getNode() + ", target=" + this.getTarget() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")"; + 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 index ab8c78b26..76fb28150 100644 --- 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 @@ -78,6 +78,9 @@ public class EventNodeClear extends AbstractEvent implements NodeClearEvent { @Override public String toString() { - return "EventNodeClear(target=" + this.getTarget() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")"; + 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 index b51c4975c..65ee6b3fd 100644 --- 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 @@ -86,6 +86,10 @@ public class EventNodeRemove extends AbstractEvent implements NodeRemoveEvent { @Override public String toString() { - return "EventNodeRemove(node=" + this.getNode() + ", target=" + this.getTarget() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")"; + 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/EventPostSync.java b/common/src/main/java/me/lucko/luckperms/common/event/impl/EventPostSync.java index e7c6efa28..69fa8f9d9 100644 --- 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 @@ -32,6 +32,6 @@ public class EventPostSync extends AbstractEvent implements PostSyncEvent { @Override public String toString() { - return "EventPostSync()"; + 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 index 8b9dc4303..24bb9ee14 100644 --- 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 @@ -57,6 +57,8 @@ public class EventPreNetworkSync extends AbstractEvent implements PreNetworkSync @Override public String toString() { - return "EventPreNetworkSync(cancellationState=" + this.getCancellationState() + ", syncId=" + this.getSyncId() + ")"; + 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 index 10c998bd0..b9b62c57b 100644 --- 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 @@ -48,6 +48,6 @@ public class EventPreSync extends AbstractEvent implements PreSyncEvent { @Override public String toString() { - return "EventPreSync(cancellationState=" + this.getCancellationState() + ")"; + 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 index 783a59602..b7eb0f3d8 100644 --- 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 @@ -73,6 +73,10 @@ public class EventTrackAddGroup extends AbstractEvent implements TrackAddGroupEv @Override public String toString() { - return "EventTrackAddGroup(group=" + this.getGroup() + ", track=" + this.getTrack() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")"; + 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 index bcde2c090..383c9177b 100644 --- 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 @@ -65,6 +65,9 @@ public class EventTrackClear extends AbstractEvent implements TrackClearEvent { @Override public String toString() { - return "EventTrackClear(track=" + this.getTrack() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")"; + 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 index 79e0ac38d..26ecde559 100644 --- 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 @@ -56,6 +56,6 @@ public class EventTrackCreate extends AbstractEvent implements TrackCreateEvent @Override public String toString() { - return "EventTrackCreate(track=" + this.getTrack() + ", cause=" + this.getCause() + ")"; + 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 index 86e3f8d2e..568a04e2d 100644 --- 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 @@ -65,6 +65,9 @@ public class EventTrackDelete extends AbstractEvent implements TrackDeleteEvent @Override public String toString() { - return "EventTrackDelete(trackName=" + this.getTrackName() + ", existingData=" + this.getExistingData() + ", cause=" + this.getCause() + ")"; + 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 index e66635a89..799fd726a 100644 --- 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 @@ -47,6 +47,6 @@ public class EventTrackLoad extends AbstractEvent implements TrackLoadEvent { @Override public String toString() { - return "EventTrackLoad(track=" + this.getTrack() + ")"; + 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 index 32313202b..daadd0b63 100644 --- 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 @@ -32,6 +32,6 @@ public class EventTrackLoadAll extends AbstractEvent implements TrackLoadAllEven @Override public String toString() { - return "EventTrackLoadAll()"; + 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 index 80b570ad2..81b42b6f0 100644 --- 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 @@ -73,6 +73,10 @@ public class EventTrackRemoveGroup extends AbstractEvent implements TrackRemoveG @Override public String toString() { - return "EventTrackRemoveGroup(group=" + this.getGroup() + ", track=" + this.getTrack() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")"; + 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 index b42927f07..39435c66e 100644 --- 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 @@ -56,6 +56,6 @@ public class EventUserCacheLoad extends AbstractEvent implements UserCacheLoadEv @Override public String toString() { - return "EventUserCacheLoad(user=" + this.getUser() + ", loadedData=" + this.getLoadedData() + ")"; + 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 index f4ab49f07..5943678f8 100644 --- 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 @@ -56,6 +56,6 @@ public class EventUserDataRecalculate extends AbstractEvent implements UserDataR @Override public String toString() { - return "EventUserDataRecalculate(user=" + this.getUser() + ", data=" + this.getData() + ")"; + 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 index c499b8ab9..9b536eade 100644 --- 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 @@ -27,6 +27,7 @@ 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; @@ -43,11 +44,14 @@ public class EventUserDemote extends AbstractEvent implements UserDemoteEvent { private final String groupFrom; private final String groupTo; - public EventUserDemote(Track track, User user, String groupFrom, 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 @@ -80,9 +84,20 @@ public class EventUserDemote extends AbstractEvent implements UserDemoteEvent { return Optional.ofNullable(this.groupTo); } + @Nonnull + @Override + public Source getSource() { + return this.source; + } + @Override public String toString() { - return "EventUserDemote(track=" + this.track + ", user=" + this.user + ", groupFrom=" + this.getGroupFrom() + ", groupTo=" + this.getGroupTo() + ")"; + 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 index 4907232cc..c947cd90d 100644 --- 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 @@ -56,6 +56,6 @@ public class EventUserFirstLogin extends AbstractEvent implements UserFirstLogin @Override public String toString() { - return "EventUserFirstLogin(uuid=" + this.getUuid() + ", username=" + this.getUsername() + ")"; + 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 index 62a7fb7ad..9565b7967 100644 --- 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 @@ -47,6 +47,6 @@ public class EventUserLoad extends AbstractEvent implements UserLoadEvent { @Override public String toString() { - return "EventUserLoad(user=" + this.getUser() + ")"; + 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 index 63f2d1589..0cfc596c8 100644 --- 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 @@ -64,6 +64,6 @@ public class EventUserLoginProcess extends AbstractEvent implements UserLoginPro @Override public String toString() { - return "EventUserLoginProcess(uuid=" + this.getUuid() + ", username=" + this.getUsername() + ", user=" + this.getUser() + ")"; + 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 index 786f5ad56..fdfccbbb3 100644 --- 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 @@ -27,6 +27,7 @@ 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; @@ -43,11 +44,14 @@ public class EventUserPromote extends AbstractEvent implements UserPromoteEvent private final String groupFrom; private final String groupTo; - public EventUserPromote(Track track, User user, String groupFrom, 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 @@ -80,9 +84,20 @@ public class EventUserPromote extends AbstractEvent implements UserPromoteEvent return Optional.ofNullable(this.groupTo); } + @Nonnull + @Override + public Source getSource() { + return this.source; + } + @Override public String toString() { - return "EventUserPromote(track=" + this.track + ", user=" + this.user + ", groupFrom=" + this.getGroupFrom() + ", groupTo=" + this.getGroupTo() + ")"; + return "UserPromoteEvent(" + + "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/model/EntitySender.java b/common/src/main/java/me/lucko/luckperms/common/event/model/EntitySender.java new file mode 100644 index 000000000..768072f72 --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/event/model/EntitySender.java @@ -0,0 +1,72 @@ +/* + * 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.model; + +import me.lucko.luckperms.api.Entity; +import me.lucko.luckperms.common.commands.sender.Sender; + +import java.util.UUID; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class EntitySender implements Entity { + private final Sender sender; + + public EntitySender(Sender sender) { + this.sender = sender; + } + + @Nullable + @Override + public UUID getUniqueId() { + if (this.sender.isConsole()) { + return null; + } + return this.sender.getUuid(); + } + + @Nonnull + @Override + public String getName() { + return this.sender.getName(); + } + + @Nonnull + @Override + public Type getType() { + if (this.sender.isConsole()) { + return Type.CONSOLE; + } else { + return Type.PLAYER; + } + } + + @Override + public String toString() { + return "Sender(type=" + getType() + ", sender=" + this.sender + ")"; + } +} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/model/SourceEntity.java b/common/src/main/java/me/lucko/luckperms/common/event/model/SourceEntity.java new file mode 100644 index 000000000..67352c7b1 --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/event/model/SourceEntity.java @@ -0,0 +1,56 @@ +/* + * 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.model; + +import me.lucko.luckperms.api.Entity; +import me.lucko.luckperms.api.event.source.EntitySource; + +import javax.annotation.Nonnull; + +public class SourceEntity implements EntitySource { + private final Entity entity; + + public SourceEntity(Entity entity) { + this.entity = entity; + } + + @Nonnull + @Override + public Entity getEntity() { + return this.entity; + } + + @Nonnull + @Override + public Type getType() { + return Type.ENTITY; + } + + @Override + public String toString() { + return "Sender(type=ENTITY, entity=" + this.entity + ")"; + } +} diff --git a/common/src/main/java/me/lucko/luckperms/common/event/model/SourceUnknown.java b/common/src/main/java/me/lucko/luckperms/common/event/model/SourceUnknown.java new file mode 100644 index 000000000..3e985bbfb --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/event/model/SourceUnknown.java @@ -0,0 +1,49 @@ +/* + * 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.model; + +import me.lucko.luckperms.api.event.source.Source; + +import javax.annotation.Nonnull; + +public final class SourceUnknown implements Source { + private static final Source INSTANCE = new SourceUnknown(); + + private SourceUnknown() { + + } + + @Nonnull + @Override + public Type getType() { + return Type.UNKNOWN; + } + + @Override + public String toString() { + return "Source(type=UNKNOWN)"; + } +}