mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 03:25:19 +01:00
Completely rework event system
* Event instances are now generated dynamically at runtime. The performance hit of creating proxies at runtime is negligible in this case. * A better EventBus implementation is now being used internally, API contracts are unaffected.
This commit is contained in:
parent
efa666445f
commit
b8466beee5
@ -40,6 +40,7 @@ public interface Cancellable {
|
||||
* @return the cancellation
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(-1)
|
||||
AtomicBoolean getCancellationState();
|
||||
|
||||
/**
|
||||
|
@ -23,24 +23,27 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event;
|
||||
package me.lucko.luckperms.api.event;
|
||||
|
||||
import me.lucko.luckperms.api.LuckPermsApi;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
/**
|
||||
* Represents the position of a parameter within an event.
|
||||
*
|
||||
* <p>This is an implementation detail and should not be relied upon.</p>
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Param {
|
||||
|
||||
public abstract class AbstractEvent implements LuckPermsEvent {
|
||||
/**
|
||||
* Gets the index of the parameter.
|
||||
*
|
||||
* @return the index
|
||||
*/
|
||||
int value();
|
||||
|
||||
private LuckPermsApi api = null;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LuckPermsApi getApi() {
|
||||
return this.api;
|
||||
}
|
||||
|
||||
void setApi(LuckPermsApi api) {
|
||||
this.api = api;
|
||||
}
|
||||
}
|
@ -45,6 +45,7 @@ public interface Sourced {
|
||||
* @return the source
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(-1)
|
||||
Source getSource();
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.api.event.group;
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.caching.GroupData;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -44,6 +45,7 @@ public interface GroupCacheLoadEvent extends LuckPermsEvent {
|
||||
* @return the group
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
Group getGroup();
|
||||
|
||||
/**
|
||||
@ -52,6 +54,7 @@ public interface GroupCacheLoadEvent extends LuckPermsEvent {
|
||||
* @return the loaded data
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
GroupData getLoadedData();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.group;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -42,6 +43,7 @@ public interface GroupCreateEvent extends LuckPermsEvent {
|
||||
* @return the new group
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
Group getGroup();
|
||||
|
||||
/**
|
||||
@ -50,6 +52,7 @@ public interface GroupCreateEvent extends LuckPermsEvent {
|
||||
* @return the cause of the creation
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
CreationCause getCause();
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.api.event.group;
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.caching.GroupData;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -44,6 +45,7 @@ public interface GroupDataRecalculateEvent extends LuckPermsEvent {
|
||||
* @return the group
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
Group getGroup();
|
||||
|
||||
/**
|
||||
@ -52,6 +54,7 @@ public interface GroupDataRecalculateEvent extends LuckPermsEvent {
|
||||
* @return the data
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
GroupData getData();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.group;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||
|
||||
import java.util.Set;
|
||||
@ -44,6 +45,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent {
|
||||
* @return the name of the deleted group
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
String getGroupName();
|
||||
|
||||
/**
|
||||
@ -52,6 +54,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent {
|
||||
* @return a copy of the groups existing data
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
Set<Node> getExistingData();
|
||||
|
||||
/**
|
||||
@ -60,6 +63,7 @@ public interface GroupDeleteEvent extends LuckPermsEvent {
|
||||
* @return the cause of the deletion
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(2)
|
||||
DeletionCause getCause();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.group;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -43,6 +44,7 @@ public interface GroupLoadEvent extends LuckPermsEvent {
|
||||
* @return the group that was loaded
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
Group getGroup();
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.api.event.log;
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -42,6 +43,7 @@ public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable {
|
||||
* @return the log entry to be broadcasted
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
LogEntry getEntry();
|
||||
|
||||
/**
|
||||
@ -51,6 +53,7 @@ public interface LogBroadcastEvent extends LuckPermsEvent, Cancellable {
|
||||
* @since 3.3
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
Origin getOrigin();
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.api.event.log;
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -46,6 +47,7 @@ public interface LogNetworkPublishEvent extends LuckPermsEvent, Cancellable {
|
||||
* @return the id of the log entry being published
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
UUID getLogId();
|
||||
|
||||
/**
|
||||
@ -54,6 +56,7 @@ public interface LogNetworkPublishEvent extends LuckPermsEvent, Cancellable {
|
||||
* @return the log entry to be published
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
LogEntry getEntry();
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import me.lucko.luckperms.api.Entity;
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -50,6 +51,7 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable {
|
||||
* @return the log entry to be sent
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
LogEntry getEntry();
|
||||
|
||||
/**
|
||||
@ -58,6 +60,7 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable {
|
||||
* @return the origin of the log
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
Origin getOrigin();
|
||||
|
||||
/**
|
||||
@ -66,6 +69,7 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable {
|
||||
* @return the object to notify
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(2)
|
||||
Entity getNotifiable();
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.api.event.log;
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -42,6 +43,7 @@ public interface LogPublishEvent extends LuckPermsEvent, Cancellable {
|
||||
* @return the log entry to be published
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
LogEntry getEntry();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.log;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -45,6 +46,7 @@ public interface LogReceiveEvent extends LuckPermsEvent {
|
||||
* @return the id of the log entry being received
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
UUID getLogId();
|
||||
|
||||
/**
|
||||
@ -53,6 +55,7 @@ public interface LogReceiveEvent extends LuckPermsEvent {
|
||||
* @return the log entry being received
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
LogEntry getEntry();
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
package me.lucko.luckperms.api.event.node;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -40,6 +41,7 @@ public interface NodeAddEvent extends NodeMutateEvent {
|
||||
* @return the node that was added
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(3)
|
||||
Node getNode();
|
||||
|
||||
}
|
||||
|
@ -25,9 +25,12 @@
|
||||
|
||||
package me.lucko.luckperms.api.event.node;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ -44,6 +47,7 @@ public interface NodeMutateEvent extends LuckPermsEvent {
|
||||
* @return the event target
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
PermissionHolder getTarget();
|
||||
|
||||
/**
|
||||
@ -52,6 +56,7 @@ public interface NodeMutateEvent extends LuckPermsEvent {
|
||||
* @return the data before the change
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
Set<Node> getDataBefore();
|
||||
|
||||
/**
|
||||
@ -60,6 +65,7 @@ public interface NodeMutateEvent extends LuckPermsEvent {
|
||||
* @return the data after the change
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(2)
|
||||
Set<Node> getDataAfter();
|
||||
|
||||
/**
|
||||
@ -69,7 +75,9 @@ public interface NodeMutateEvent extends LuckPermsEvent {
|
||||
*
|
||||
* @return if the event is targeting a user
|
||||
*/
|
||||
boolean isUser();
|
||||
default boolean isUser() {
|
||||
return getTarget() instanceof User;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the target of this event is a {@link me.lucko.luckperms.api.Group}
|
||||
@ -78,6 +86,8 @@ public interface NodeMutateEvent extends LuckPermsEvent {
|
||||
*
|
||||
* @return if the event is targeting a group
|
||||
*/
|
||||
boolean isGroup();
|
||||
default boolean isGroup() {
|
||||
return getTarget() instanceof Group;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
package me.lucko.luckperms.api.event.node;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -40,6 +41,7 @@ public interface NodeRemoveEvent extends NodeMutateEvent {
|
||||
* @return the node that was removed
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(3)
|
||||
Node getNode();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.player;
|
||||
|
||||
import me.lucko.luckperms.api.PlayerSaveResult;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.manager.UserManager;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -48,6 +49,7 @@ public interface PlayerDataSaveEvent extends LuckPermsEvent {
|
||||
* @return the uuid
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
UUID getUuid();
|
||||
|
||||
/**
|
||||
@ -56,6 +58,7 @@ public interface PlayerDataSaveEvent extends LuckPermsEvent {
|
||||
* @return the username
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
String getUsername();
|
||||
|
||||
/**
|
||||
@ -64,6 +67,7 @@ public interface PlayerDataSaveEvent extends LuckPermsEvent {
|
||||
* @return the result
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(2)
|
||||
PlayerSaveResult getResult();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.sync;
|
||||
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -43,6 +44,7 @@ public interface PreNetworkSyncEvent extends LuckPermsEvent, Cancellable {
|
||||
* @return the id of the sync request
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
UUID getSyncId();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.track;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -42,6 +43,7 @@ public interface TrackCreateEvent extends LuckPermsEvent {
|
||||
* @return the new track
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
Track getTrack();
|
||||
|
||||
/**
|
||||
@ -50,6 +52,7 @@ public interface TrackCreateEvent extends LuckPermsEvent {
|
||||
* @return the cause of the creation
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
CreationCause getCause();
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
package me.lucko.luckperms.api.event.track;
|
||||
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||
|
||||
import java.util.List;
|
||||
@ -43,6 +44,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent {
|
||||
* @return the name of the deleted track
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
String getTrackName();
|
||||
|
||||
/**
|
||||
@ -51,6 +53,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent {
|
||||
* @return a copy of the tracks existing data
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
List<String> getExistingData();
|
||||
|
||||
/**
|
||||
@ -59,6 +62,7 @@ public interface TrackDeleteEvent extends LuckPermsEvent {
|
||||
* @return the cause of the deletion
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(2)
|
||||
DeletionCause getCause();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.track;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -43,6 +44,7 @@ public interface TrackLoadEvent extends LuckPermsEvent {
|
||||
* @return the track that was loaded
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
Track getTrack();
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
package me.lucko.luckperms.api.event.track.mutate;
|
||||
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
@ -38,6 +40,7 @@ public interface TrackAddGroupEvent extends TrackMutateEvent {
|
||||
* @return the group that was added
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(3)
|
||||
String getGroup();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.track.mutate;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -43,6 +44,7 @@ public interface TrackMutateEvent extends LuckPermsEvent {
|
||||
* @return the track that was mutated
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
Track getTrack();
|
||||
|
||||
/**
|
||||
@ -51,6 +53,7 @@ public interface TrackMutateEvent extends LuckPermsEvent {
|
||||
* @return the data before the change
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
List<String> getDataBefore();
|
||||
|
||||
/**
|
||||
@ -59,6 +62,7 @@ public interface TrackMutateEvent extends LuckPermsEvent {
|
||||
* @return the data after the change
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(2)
|
||||
List<String> getDataAfter();
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
package me.lucko.luckperms.api.event.track.mutate;
|
||||
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
@ -38,6 +40,7 @@ public interface TrackRemoveGroupEvent extends TrackMutateEvent {
|
||||
* @return the group that was removed
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(3)
|
||||
String getGroup();
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.api.event.user;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.caching.UserData;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -42,6 +43,7 @@ public interface UserCacheLoadEvent extends LuckPermsEvent {
|
||||
* @return the user
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
User getUser();
|
||||
|
||||
/**
|
||||
@ -50,6 +52,7 @@ public interface UserCacheLoadEvent extends LuckPermsEvent {
|
||||
* @return the loaded data
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
UserData getLoadedData();
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.api.event.user;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.caching.UserData;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -42,6 +43,7 @@ public interface UserDataRecalculateEvent extends LuckPermsEvent {
|
||||
* @return the user
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
User getUser();
|
||||
|
||||
/**
|
||||
@ -50,6 +52,7 @@ public interface UserDataRecalculateEvent extends LuckPermsEvent {
|
||||
* @return the data
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
UserData getData();
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
package me.lucko.luckperms.api.event.user;
|
||||
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -50,6 +51,7 @@ public interface UserFirstLoginEvent extends LuckPermsEvent {
|
||||
* @return the uuid of the user
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
UUID getUuid();
|
||||
|
||||
/**
|
||||
@ -58,6 +60,7 @@ public interface UserFirstLoginEvent extends LuckPermsEvent {
|
||||
* @return the username of the user
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
String getUsername();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.user;
|
||||
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -41,6 +42,7 @@ public interface UserLoadEvent extends LuckPermsEvent {
|
||||
* @return the user that was loaded
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
User getUser();
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.user;
|
||||
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -52,6 +53,7 @@ public interface UserLoginProcessEvent extends LuckPermsEvent {
|
||||
* @return the uuid of the connection which was processed
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
UUID getUuid();
|
||||
|
||||
/**
|
||||
@ -60,6 +62,7 @@ public interface UserLoginProcessEvent extends LuckPermsEvent {
|
||||
* @return the username of the connection which was processed
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
String getUsername();
|
||||
|
||||
/**
|
||||
@ -67,6 +70,8 @@ public interface UserLoginProcessEvent extends LuckPermsEvent {
|
||||
*
|
||||
* @return the user instance
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(2)
|
||||
User getUser();
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
package me.lucko.luckperms.api.event.user.track;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Called when a user is demoted down a track.
|
||||
*
|
||||
@ -32,4 +34,9 @@ package me.lucko.luckperms.api.event.user.track;
|
||||
*/
|
||||
public interface UserDemoteEvent extends UserTrackEvent {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
default TrackAction getAction() {
|
||||
return TrackAction.DEMOTION;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
package me.lucko.luckperms.api.event.user.track;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Called when a user is promoted up a track.
|
||||
*
|
||||
@ -32,4 +34,9 @@ package me.lucko.luckperms.api.event.user.track;
|
||||
*/
|
||||
public interface UserPromoteEvent extends UserTrackEvent {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
default TrackAction getAction() {
|
||||
return TrackAction.PROMOTION;
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.api.event.user.track;
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.event.Sourced;
|
||||
|
||||
import java.util.Optional;
|
||||
@ -45,6 +46,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced {
|
||||
* @return the track involved in the event
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(0)
|
||||
Track getTrack();
|
||||
|
||||
/**
|
||||
@ -53,6 +55,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced {
|
||||
* @return the user involved in the event
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(1)
|
||||
User getUser();
|
||||
|
||||
/**
|
||||
@ -71,6 +74,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced {
|
||||
* @return the group the user was promoted/demoted from
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(2)
|
||||
Optional<String> getGroupFrom();
|
||||
|
||||
/**
|
||||
@ -79,6 +83,7 @@ public interface UserTrackEvent extends LuckPermsEvent, Sourced {
|
||||
* @return the group the user was promoted/demoted to
|
||||
*/
|
||||
@Nonnull
|
||||
@Param(3)
|
||||
Optional<String> getGroupTo();
|
||||
|
||||
}
|
||||
|
@ -66,6 +66,10 @@
|
||||
<pattern>net.kyori.text</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.text</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.event</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.eventbus</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.benmanes.caffeine</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.caffeine</shadedPattern>
|
||||
|
@ -123,7 +123,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
||||
|
||||
@Override
|
||||
protected Set<Dependency> getGlobalDependencies() {
|
||||
EnumSet<Dependency> dependencies = EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
|
||||
EnumSet<Dependency> dependencies = EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, Dependency.EVENT);
|
||||
if (isBrigadierSupported()) {
|
||||
dependencies.add(Dependency.COMMODORE);
|
||||
}
|
||||
|
@ -56,6 +56,10 @@
|
||||
<pattern>net.kyori.text</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.text</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.event</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.eventbus</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.benmanes.caffeine</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.caffeine</shadedPattern>
|
||||
|
@ -94,7 +94,7 @@ public class LPBungeePlugin extends AbstractLuckPermsPlugin {
|
||||
|
||||
@Override
|
||||
protected Set<Dependency> getGlobalDependencies() {
|
||||
return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
|
||||
return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, Dependency.EVENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,6 +70,24 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- event -->
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>event-api</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.checkerframework</groupId>
|
||||
<artifactId>checker-qual</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- gson -->
|
||||
<dependency>
|
||||
|
@ -67,6 +67,13 @@ public enum Dependency {
|
||||
"drQpwf+oI1+DPrn0iCvEtoID+xXR3dpZK5ySaBrUiok=",
|
||||
Relocation.of("text", "net{}kyori{}text")
|
||||
),
|
||||
EVENT(
|
||||
"net{}kyori",
|
||||
"event-api",
|
||||
"2.0.1",
|
||||
"4XVmowvKHCmO38ZO2jeZKh/mD00xBg73zau79s4kTe4=",
|
||||
Relocation.of("eventbus", "net{}kyori{}event")
|
||||
),
|
||||
CAFFEINE(
|
||||
"com{}github{}ben-manes{}caffeine",
|
||||
"caffeine",
|
||||
|
@ -25,33 +25,26 @@
|
||||
|
||||
package me.lucko.luckperms.common.event;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.EventBus;
|
||||
import me.lucko.luckperms.api.event.EventHandler;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import net.kyori.event.EventSubscriber;
|
||||
import net.kyori.event.SimpleEventBus;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Simple implementation of EventBus.
|
||||
*/
|
||||
public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
||||
|
||||
/**
|
||||
@ -65,26 +58,9 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
||||
private final LuckPermsApiProvider apiProvider;
|
||||
|
||||
/**
|
||||
* The registered handlers in this event bus
|
||||
* The delegate event bus
|
||||
*/
|
||||
private final Multimap<Class<? extends LuckPermsEvent>, LuckPermsEventHandler<?>> handlerMap = Multimaps.newSetMultimap(new ConcurrentHashMap<>(), ConcurrentHashMap::newKeySet);
|
||||
|
||||
/**
|
||||
* A cache of event class --> applicable handlers.
|
||||
*
|
||||
* A registered "handler" will be passed all possible events it can handle, according to
|
||||
* {@link Class#isAssignableFrom(Class)}.
|
||||
*/
|
||||
private final LoadingCache<Class<? extends LuckPermsEvent>, List<LuckPermsEventHandler<?>>> handlerCache = Caffeine.newBuilder()
|
||||
.build(eventClass -> {
|
||||
ImmutableList.Builder<LuckPermsEventHandler<?>> matched = ImmutableList.builder();
|
||||
AbstractEventBus.this.handlerMap.asMap().forEach((clazz, handlers) -> {
|
||||
if (clazz.isAssignableFrom(eventClass)) {
|
||||
matched.addAll(handlers);
|
||||
}
|
||||
});
|
||||
return matched.build();
|
||||
});
|
||||
private final Bus bus = new Bus();
|
||||
|
||||
protected AbstractEventBus(LuckPermsPlugin plugin, LuckPermsApiProvider apiProvider) {
|
||||
this.plugin = plugin;
|
||||
@ -95,6 +71,23 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
public LuckPermsApiProvider getApiProvider() {
|
||||
return this.apiProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the given plugin object is a valid plugin instance for the platform
|
||||
*
|
||||
* @param plugin the object
|
||||
* @return a plugin
|
||||
* @throws IllegalArgumentException if the plugin is invalid
|
||||
*/
|
||||
protected abstract P checkPlugin(Object plugin) throws IllegalArgumentException;
|
||||
|
||||
public void post(LuckPermsEvent event) {
|
||||
this.bus.post(event);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T extends LuckPermsEvent> EventHandler<T> subscribe(@Nonnull Class<T> eventClass, @Nonnull Consumer<? super T> handler) {
|
||||
@ -112,36 +105,6 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
||||
return registerSubscription(eventClass, handler, checkPlugin(plugin));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@Nonnull Class<T> eventClass) {
|
||||
Collection<LuckPermsEventHandler<?>> handlers = this.handlerMap.asMap().get(eventClass);
|
||||
ImmutableSet.Builder<EventHandler<T>> ret = ImmutableSet.builder();
|
||||
for (LuckPermsEventHandler<?> handler : handlers) {
|
||||
//noinspection unchecked
|
||||
ret.add((EventHandler<T>) handler);
|
||||
}
|
||||
return ret.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the given plugin object is a valid plugin instance for the platform
|
||||
*
|
||||
* @param plugin the object
|
||||
* @return a plugin
|
||||
* @throws IllegalArgumentException if the plugin is invalid
|
||||
*/
|
||||
protected abstract P checkPlugin(Object plugin) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Registers a subscription for the given class, handler and plugin
|
||||
*
|
||||
* @param eventClass the event class
|
||||
* @param handler the handler
|
||||
* @param plugin the plugin, nullable
|
||||
* @param <T> the event type
|
||||
* @return the resultant handler
|
||||
*/
|
||||
private <T extends LuckPermsEvent> EventHandler<T> registerSubscription(Class<T> eventClass, Consumer<? super T> handler, Object plugin) {
|
||||
if (!eventClass.isInterface()) {
|
||||
throw new IllegalArgumentException("class " + eventClass + " is not an interface");
|
||||
@ -151,20 +114,28 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
||||
}
|
||||
|
||||
LuckPermsEventHandler<T> eventHandler = new LuckPermsEventHandler<>(this, eventClass, handler, plugin);
|
||||
this.handlerMap.put(eventClass, eventHandler);
|
||||
this.handlerCache.invalidateAll();
|
||||
this.bus.register(eventClass, eventHandler);
|
||||
|
||||
return eventHandler;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T extends LuckPermsEvent> Set<EventHandler<T>> getHandlers(@Nonnull Class<T> eventClass) {
|
||||
Set<LuckPermsEventHandler<?>> handlers = this.bus.getHandlers();
|
||||
handlers.removeIf(h -> !h.getEventClass().isAssignableFrom(eventClass));
|
||||
|
||||
//noinspection unchecked
|
||||
return (Set) ImmutableSet.copyOf(handlers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a specific handler from the bus
|
||||
*
|
||||
* @param handler the handler to remove
|
||||
*/
|
||||
public void unregisterHandler(LuckPermsEventHandler<?> handler) {
|
||||
this.handlerMap.remove(handler.getEventClass(), handler);
|
||||
this.handlerCache.invalidateAll();
|
||||
this.bus.unregister(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,54 +144,35 @@ public abstract class AbstractEventBus<P> implements EventBus, AutoCloseable {
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
protected void unregisterHandlers(P plugin) {
|
||||
List<LuckPermsEventHandler<?>> handlers = new ArrayList<>(this.handlerMap.values());
|
||||
for (LuckPermsEventHandler<?> handler : handlers) {
|
||||
if (handler.getPlugin() == plugin) {
|
||||
handler.unregister();
|
||||
}
|
||||
}
|
||||
this.bus.unregisterMatching(sub -> ((LuckPermsEventHandler) sub).getPlugin() == plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters all handlers in this event bus
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
List<LuckPermsEventHandler<?>> handlers = new ArrayList<>(this.handlerMap.values());
|
||||
for (LuckPermsEventHandler<?> handler : handlers) {
|
||||
handler.unregister();
|
||||
}
|
||||
this.bus.unregisterAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires the given event to all registered handlers in this event bus
|
||||
*
|
||||
* @param event the event to fire
|
||||
*/
|
||||
public void fireEvent(LuckPermsEvent event) {
|
||||
if (event instanceof AbstractEvent) {
|
||||
((AbstractEvent) event).setApi(this.apiProvider);
|
||||
private static final class Bus extends SimpleEventBus<LuckPermsEvent> {
|
||||
|
||||
@Override
|
||||
public void unregisterMatching(@Nonnull Predicate<EventSubscriber<?>> predicate) {
|
||||
super.unregisterMatching(predicate);
|
||||
}
|
||||
|
||||
List<LuckPermsEventHandler<?>> handlers = this.handlerCache.get(event.getClass());
|
||||
if (handlers == null) {
|
||||
return;
|
||||
public void unregisterAll() {
|
||||
unregisterMatching(Predicates.alwaysTrue());
|
||||
}
|
||||
|
||||
for (LuckPermsEventHandler<?> handler : handlers) {
|
||||
handler.handle(event);
|
||||
}
|
||||
}
|
||||
public Set<LuckPermsEventHandler<?>> getHandlers() {
|
||||
Set<LuckPermsEventHandler<?>> handlers = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Fires the given event asynchronously to all registered handlers in this event bus
|
||||
*
|
||||
* @param event the event to fire
|
||||
*/
|
||||
public void fireEventAsync(LuckPermsEvent event) {
|
||||
if (event instanceof Cancellable) {
|
||||
throw new IllegalArgumentException("cannot call Cancellable event async");
|
||||
// bit of a hack
|
||||
unregisterMatching(sub -> {
|
||||
handlers.add((LuckPermsEventHandler<?>) sub);
|
||||
return false;
|
||||
});
|
||||
|
||||
return handlers;
|
||||
}
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> fireEvent(event));
|
||||
}
|
||||
}
|
||||
|
@ -33,47 +33,47 @@ import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.PlayerSaveResult;
|
||||
import me.lucko.luckperms.api.caching.GroupData;
|
||||
import me.lucko.luckperms.api.caching.UserData;
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||
import me.lucko.luckperms.api.event.group.GroupCacheLoadEvent;
|
||||
import me.lucko.luckperms.api.event.group.GroupCreateEvent;
|
||||
import me.lucko.luckperms.api.event.group.GroupDataRecalculateEvent;
|
||||
import me.lucko.luckperms.api.event.group.GroupDeleteEvent;
|
||||
import me.lucko.luckperms.api.event.group.GroupLoadAllEvent;
|
||||
import me.lucko.luckperms.api.event.group.GroupLoadEvent;
|
||||
import me.lucko.luckperms.api.event.log.LogBroadcastEvent;
|
||||
import me.lucko.luckperms.api.event.log.LogNetworkPublishEvent;
|
||||
import me.lucko.luckperms.api.event.log.LogNotifyEvent;
|
||||
import me.lucko.luckperms.api.event.log.LogPublishEvent;
|
||||
import me.lucko.luckperms.api.event.log.LogReceiveEvent;
|
||||
import me.lucko.luckperms.api.event.node.NodeAddEvent;
|
||||
import me.lucko.luckperms.api.event.node.NodeClearEvent;
|
||||
import me.lucko.luckperms.api.event.node.NodeRemoveEvent;
|
||||
import me.lucko.luckperms.api.event.player.PlayerDataSaveEvent;
|
||||
import me.lucko.luckperms.api.event.source.Source;
|
||||
import me.lucko.luckperms.api.event.sync.ConfigReloadEvent;
|
||||
import me.lucko.luckperms.api.event.sync.PostSyncEvent;
|
||||
import me.lucko.luckperms.api.event.sync.PreNetworkSyncEvent;
|
||||
import me.lucko.luckperms.api.event.sync.PreSyncEvent;
|
||||
import me.lucko.luckperms.api.event.track.TrackCreateEvent;
|
||||
import me.lucko.luckperms.api.event.track.TrackDeleteEvent;
|
||||
import me.lucko.luckperms.api.event.track.TrackLoadAllEvent;
|
||||
import me.lucko.luckperms.api.event.track.TrackLoadEvent;
|
||||
import me.lucko.luckperms.api.event.track.mutate.TrackAddGroupEvent;
|
||||
import me.lucko.luckperms.api.event.track.mutate.TrackClearEvent;
|
||||
import me.lucko.luckperms.api.event.track.mutate.TrackRemoveGroupEvent;
|
||||
import me.lucko.luckperms.api.event.user.UserCacheLoadEvent;
|
||||
import me.lucko.luckperms.api.event.user.UserDataRecalculateEvent;
|
||||
import me.lucko.luckperms.api.event.user.UserFirstLoginEvent;
|
||||
import me.lucko.luckperms.api.event.user.UserLoadEvent;
|
||||
import me.lucko.luckperms.api.event.user.UserLoginProcessEvent;
|
||||
import me.lucko.luckperms.api.event.user.track.UserDemoteEvent;
|
||||
import me.lucko.luckperms.api.event.user.track.UserPromoteEvent;
|
||||
import me.lucko.luckperms.common.api.delegates.model.ApiPermissionHolder;
|
||||
import me.lucko.luckperms.common.api.delegates.model.ApiUser;
|
||||
import me.lucko.luckperms.common.event.impl.EventConfigReload;
|
||||
import me.lucko.luckperms.common.event.impl.EventGroupCacheLoad;
|
||||
import me.lucko.luckperms.common.event.impl.EventGroupCreate;
|
||||
import me.lucko.luckperms.common.event.impl.EventGroupDataRecalculate;
|
||||
import me.lucko.luckperms.common.event.impl.EventGroupDelete;
|
||||
import me.lucko.luckperms.common.event.impl.EventGroupLoad;
|
||||
import me.lucko.luckperms.common.event.impl.EventGroupLoadAll;
|
||||
import me.lucko.luckperms.common.event.impl.EventLogBroadcast;
|
||||
import me.lucko.luckperms.common.event.impl.EventLogNetworkPublish;
|
||||
import me.lucko.luckperms.common.event.impl.EventLogNotify;
|
||||
import me.lucko.luckperms.common.event.impl.EventLogPublish;
|
||||
import me.lucko.luckperms.common.event.impl.EventLogReceive;
|
||||
import me.lucko.luckperms.common.event.impl.EventNodeAdd;
|
||||
import me.lucko.luckperms.common.event.impl.EventNodeClear;
|
||||
import me.lucko.luckperms.common.event.impl.EventNodeRemove;
|
||||
import me.lucko.luckperms.common.event.impl.EventPlayerDataSave;
|
||||
import me.lucko.luckperms.common.event.impl.EventPostSync;
|
||||
import me.lucko.luckperms.common.event.impl.EventPreNetworkSync;
|
||||
import me.lucko.luckperms.common.event.impl.EventPreSync;
|
||||
import me.lucko.luckperms.common.event.impl.EventTrackAddGroup;
|
||||
import me.lucko.luckperms.common.event.impl.EventTrackClear;
|
||||
import me.lucko.luckperms.common.event.impl.EventTrackCreate;
|
||||
import me.lucko.luckperms.common.event.impl.EventTrackDelete;
|
||||
import me.lucko.luckperms.common.event.impl.EventTrackLoad;
|
||||
import me.lucko.luckperms.common.event.impl.EventTrackLoadAll;
|
||||
import me.lucko.luckperms.common.event.impl.EventTrackRemoveGroup;
|
||||
import me.lucko.luckperms.common.event.impl.EventUserCacheLoad;
|
||||
import me.lucko.luckperms.common.event.impl.EventUserDataRecalculate;
|
||||
import me.lucko.luckperms.common.event.impl.EventUserDemote;
|
||||
import me.lucko.luckperms.common.event.impl.EventUserFirstLogin;
|
||||
import me.lucko.luckperms.common.event.impl.EventUserLoad;
|
||||
import me.lucko.luckperms.common.event.impl.EventUserLoginProcess;
|
||||
import me.lucko.luckperms.common.event.impl.EventUserPromote;
|
||||
import me.lucko.luckperms.common.event.gen.GeneratedEventSpec;
|
||||
import me.lucko.luckperms.common.event.model.EntitySourceImpl;
|
||||
import me.lucko.luckperms.common.event.model.SenderEntity;
|
||||
import me.lucko.luckperms.common.event.model.UnknownSource;
|
||||
@ -85,15 +85,17 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class EventFactory {
|
||||
private final AbstractEventBus eventBus;
|
||||
private final AbstractEventBus<?> eventBus;
|
||||
|
||||
public EventFactory(AbstractEventBus eventBus) {
|
||||
public EventFactory(AbstractEventBus<?> eventBus) {
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
|
||||
@ -101,193 +103,174 @@ public final class EventFactory {
|
||||
return this.eventBus;
|
||||
}
|
||||
|
||||
private void fireEventAsync(LuckPermsEvent event) {
|
||||
this.eventBus.fireEventAsync(event);
|
||||
private void post(LuckPermsEvent event) {
|
||||
this.eventBus.post(event);
|
||||
}
|
||||
|
||||
private void fireEvent(LuckPermsEvent event) {
|
||||
this.eventBus.fireEvent(event);
|
||||
private void post(Supplier<LuckPermsEvent> supplier) {
|
||||
this.eventBus.getPlugin().getBootstrap().getScheduler().executeAsync(() -> {
|
||||
LuckPermsEvent event = supplier.get();
|
||||
if (event instanceof Cancellable) {
|
||||
throw new RuntimeException("Cancellable event posted async: " + event);
|
||||
}
|
||||
this.eventBus.post(event);
|
||||
});
|
||||
}
|
||||
|
||||
private LuckPermsEvent generate(Class<? extends LuckPermsEvent> eventClass, Object... params) {
|
||||
return GeneratedEventSpec.lookup(eventClass).newInstance(this.eventBus.getApiProvider(), params);
|
||||
}
|
||||
|
||||
public void handleGroupCacheLoad(Group group, GroupData data) {
|
||||
EventGroupCacheLoad event = new EventGroupCacheLoad(group.getApiDelegate(), data);
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(GroupCacheLoadEvent.class, group.getApiDelegate(), data));
|
||||
}
|
||||
|
||||
public void handleGroupCreate(Group group, CreationCause cause) {
|
||||
EventGroupCreate event = new EventGroupCreate(group.getApiDelegate(), cause);
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(GroupCreateEvent.class, group.getApiDelegate(), cause));
|
||||
}
|
||||
|
||||
public void handleGroupDelete(Group group, DeletionCause cause) {
|
||||
EventGroupDelete event = new EventGroupDelete(group.getName(), ImmutableSet.copyOf(group.enduringData().immutable().values()), cause);
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(GroupDeleteEvent.class, group.getName(), ImmutableSet.copyOf(group.enduringData().immutable().values()), cause));
|
||||
}
|
||||
|
||||
public void handleGroupLoadAll() {
|
||||
EventGroupLoadAll event = new EventGroupLoadAll();
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(GroupLoadAllEvent.class));
|
||||
}
|
||||
|
||||
public void handleGroupLoad(Group group) {
|
||||
EventGroupLoad event = new EventGroupLoad(group.getApiDelegate());
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(GroupLoadEvent.class, group.getApiDelegate()));
|
||||
}
|
||||
|
||||
public boolean handleLogBroadcast(boolean initialState, LogEntry entry, LogBroadcastEvent.Origin origin) {
|
||||
AtomicBoolean cancel = new AtomicBoolean(initialState);
|
||||
EventLogBroadcast event = new EventLogBroadcast(cancel, entry, origin);
|
||||
fireEvent(event);
|
||||
post(generate(LogBroadcastEvent.class, cancel, entry, origin));
|
||||
return cancel.get();
|
||||
}
|
||||
|
||||
public boolean handleLogPublish(boolean initialState, LogEntry entry) {
|
||||
AtomicBoolean cancel = new AtomicBoolean(initialState);
|
||||
EventLogPublish event = new EventLogPublish(cancel, entry);
|
||||
fireEvent(event);
|
||||
post(generate(LogPublishEvent.class, cancel, entry));
|
||||
return cancel.get();
|
||||
}
|
||||
|
||||
public boolean handleLogNetworkPublish(boolean initialState, UUID id, LogEntry entry) {
|
||||
AtomicBoolean cancel = new AtomicBoolean(initialState);
|
||||
EventLogNetworkPublish event = new EventLogNetworkPublish(cancel, id, entry);
|
||||
fireEvent(event);
|
||||
post(generate(LogNetworkPublishEvent.class, cancel, id, entry));
|
||||
return cancel.get();
|
||||
}
|
||||
|
||||
public boolean handleLogNotify(boolean initialState, LogEntry entry, LogNotifyEvent.Origin origin, Sender sender) {
|
||||
AtomicBoolean cancel = new AtomicBoolean(initialState);
|
||||
EventLogNotify event = new EventLogNotify(cancel, entry, origin, sender);
|
||||
fireEvent(event);
|
||||
post(generate(LogNotifyEvent.class, cancel, entry, origin, new SenderEntity(sender)));
|
||||
return cancel.get();
|
||||
}
|
||||
|
||||
public void handleLogReceive(UUID id, LogEntry entry) {
|
||||
EventLogReceive event = new EventLogReceive(id, entry);
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(LogReceiveEvent.class, id, entry));
|
||||
}
|
||||
|
||||
public void handleNodeAdd(Node node, PermissionHolder target, Collection<? extends Node> before, Collection<? extends Node> after) {
|
||||
EventNodeAdd event = new EventNodeAdd(node, getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after));
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(NodeAddEvent.class, getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after), node));
|
||||
}
|
||||
|
||||
public void handleNodeClear(PermissionHolder target, Collection<? extends Node> before, Collection<? extends Node> after) {
|
||||
EventNodeClear event = new EventNodeClear(getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after));
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(NodeClearEvent.class, getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after)));
|
||||
}
|
||||
|
||||
public void handleNodeRemove(Node node, PermissionHolder target, Collection<? extends Node> before, Collection<? extends Node> after) {
|
||||
EventNodeRemove event = new EventNodeRemove(node, getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after));
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(NodeRemoveEvent.class, getDelegate(target), ImmutableSet.copyOf(before), ImmutableSet.copyOf(after), node));
|
||||
}
|
||||
|
||||
public void handleConfigReload() {
|
||||
EventConfigReload event = new EventConfigReload();
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(ConfigReloadEvent.class));
|
||||
}
|
||||
|
||||
public void handlePostSync() {
|
||||
EventPostSync event = new EventPostSync();
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(PostSyncEvent.class));
|
||||
}
|
||||
|
||||
public boolean handleNetworkPreSync(boolean initialState, UUID id) {
|
||||
AtomicBoolean cancel = new AtomicBoolean(initialState);
|
||||
EventPreNetworkSync event = new EventPreNetworkSync(cancel, id);
|
||||
fireEvent(event);
|
||||
post(generate(PreNetworkSyncEvent.class, cancel, id));
|
||||
return cancel.get();
|
||||
}
|
||||
|
||||
public boolean handlePreSync(boolean initialState) {
|
||||
AtomicBoolean cancel = new AtomicBoolean(initialState);
|
||||
EventPreSync event = new EventPreSync(cancel);
|
||||
fireEvent(event);
|
||||
post(generate(PreSyncEvent.class, cancel));
|
||||
return cancel.get();
|
||||
}
|
||||
|
||||
public void handleTrackCreate(Track track, CreationCause cause) {
|
||||
EventTrackCreate event = new EventTrackCreate(track.getApiDelegate(), cause);
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(TrackCreateEvent.class, track.getApiDelegate(), cause));
|
||||
}
|
||||
|
||||
public void handleTrackDelete(Track track, DeletionCause cause) {
|
||||
EventTrackDelete event = new EventTrackDelete(track.getName(), ImmutableList.copyOf(track.getGroups()), cause);
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(TrackDeleteEvent.class, track.getName(), ImmutableList.copyOf(track.getGroups()), cause));
|
||||
}
|
||||
|
||||
public void handleTrackLoadAll() {
|
||||
EventTrackLoadAll event = new EventTrackLoadAll();
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(TrackLoadAllEvent.class));
|
||||
}
|
||||
|
||||
public void handleTrackLoad(Track track) {
|
||||
EventTrackLoad event = new EventTrackLoad(track.getApiDelegate());
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(TrackLoadEvent.class, track.getApiDelegate()));
|
||||
}
|
||||
|
||||
public void handleTrackAddGroup(Track track, String group, List<String> before, List<String> after) {
|
||||
EventTrackAddGroup event = new EventTrackAddGroup(group, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.copyOf(after));
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(TrackAddGroupEvent.class, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.copyOf(after), group));
|
||||
}
|
||||
|
||||
public void handleTrackClear(Track track, List<String> before) {
|
||||
EventTrackClear event = new EventTrackClear(track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.of());
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(TrackClearEvent.class, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.of()));
|
||||
}
|
||||
|
||||
public void handleTrackRemoveGroup(Track track, String group, List<String> before, List<String> after) {
|
||||
EventTrackRemoveGroup event = new EventTrackRemoveGroup(group, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.copyOf(after));
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(TrackRemoveGroupEvent.class, track.getApiDelegate(), ImmutableList.copyOf(before), ImmutableList.copyOf(after), group));
|
||||
}
|
||||
|
||||
public void handleUserCacheLoad(User user, UserData data) {
|
||||
EventUserCacheLoad event = new EventUserCacheLoad(new ApiUser(user), data);
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(UserCacheLoadEvent.class, new ApiUser(user), data));
|
||||
}
|
||||
|
||||
public void handleDataRecalculate(PermissionHolder holder) {
|
||||
if (holder.getType().isUser()) {
|
||||
User user = (User) holder;
|
||||
EventUserDataRecalculate event = new EventUserDataRecalculate(user.getApiDelegate(), user.getCachedData());
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(UserDataRecalculateEvent.class, user.getApiDelegate(), user.getCachedData()));
|
||||
} else {
|
||||
Group group = (Group) holder;
|
||||
EventGroupDataRecalculate event = new EventGroupDataRecalculate(group.getApiDelegate(), group.getCachedData());
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(GroupDataRecalculateEvent.class, group.getApiDelegate(), group.getCachedData()));
|
||||
}
|
||||
}
|
||||
|
||||
public void handleUserFirstLogin(UUID uuid, String username) {
|
||||
EventUserFirstLogin event = new EventUserFirstLogin(uuid, username);
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(UserFirstLoginEvent.class, uuid, username));
|
||||
}
|
||||
|
||||
public void handlePlayerDataSave(UUID uuid, String username, PlayerSaveResult result) {
|
||||
EventPlayerDataSave event = new EventPlayerDataSave(uuid, username, result);
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(PlayerDataSaveEvent.class, uuid, username, result));
|
||||
}
|
||||
|
||||
public void handleUserLoad(User user) {
|
||||
EventUserLoad event = new EventUserLoad(new ApiUser(user));
|
||||
fireEventAsync(event);
|
||||
post(() -> generate(UserLoadEvent.class, new ApiUser(user)));
|
||||
}
|
||||
|
||||
public void handleUserLoginProcess(UUID uuid, String username, User user) {
|
||||
EventUserLoginProcess event = new EventUserLoginProcess(uuid, username, new ApiUser(user));
|
||||
fireEvent(event);
|
||||
post(() -> generate(UserLoginProcessEvent.class, uuid, username, new ApiUser(user)));
|
||||
}
|
||||
|
||||
public void handleUserDemote(User user, Track track, String from, String to, @Nullable Sender source) {
|
||||
Source s = source == null ? UnknownSource.INSTANCE : new EntitySourceImpl(new SenderEntity(source));
|
||||
EventUserDemote event = new EventUserDemote(track.getApiDelegate(), new ApiUser(user), from, to, s);
|
||||
fireEventAsync(event);
|
||||
post(() -> {
|
||||
Source s = source == null ? UnknownSource.INSTANCE : new EntitySourceImpl(new SenderEntity(source));
|
||||
return generate(UserDemoteEvent.class, s, track.getApiDelegate(), new ApiUser(user), Optional.ofNullable(from), Optional.ofNullable(to));
|
||||
});
|
||||
}
|
||||
|
||||
public void handleUserPromote(User user, Track track, String from, String to, @Nullable Sender source) {
|
||||
Source s = source == null ? UnknownSource.INSTANCE : new EntitySourceImpl(new SenderEntity(source));
|
||||
EventUserPromote event = new EventUserPromote(track.getApiDelegate(), new ApiUser(user), from, to, s);
|
||||
fireEventAsync(event);
|
||||
post(() -> {
|
||||
Source s = source == null ? UnknownSource.INSTANCE : new EntitySourceImpl(new SenderEntity(source));
|
||||
return generate(UserPromoteEvent.class, s, track.getApiDelegate(), new ApiUser(user), Optional.ofNullable(from), Optional.ofNullable(to));
|
||||
});
|
||||
}
|
||||
|
||||
private static ApiPermissionHolder getDelegate(PermissionHolder holder) {
|
||||
|
@ -28,6 +28,8 @@ package me.lucko.luckperms.common.event;
|
||||
import me.lucko.luckperms.api.event.EventHandler;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
|
||||
import net.kyori.event.EventSubscriber;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
||||
@ -40,7 +42,7 @@ import javax.annotation.Nullable;
|
||||
*
|
||||
* @param <T> the event type
|
||||
*/
|
||||
public class LuckPermsEventHandler<T extends LuckPermsEvent> implements EventHandler<T> {
|
||||
public class LuckPermsEventHandler<T extends LuckPermsEvent> implements EventHandler<T>, EventSubscriber<T> {
|
||||
|
||||
/**
|
||||
* The event bus which created this handler
|
||||
@ -101,11 +103,10 @@ public class LuckPermsEventHandler<T extends LuckPermsEvent> implements EventHan
|
||||
return this.callCount.get();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") // we know that this method will never be called if the class doesn't match eventClass
|
||||
void handle(LuckPermsEvent event) {
|
||||
@Override
|
||||
public void invoke(T event) throws Throwable {
|
||||
try {
|
||||
T t = (T) event;
|
||||
this.consumer.accept(t);
|
||||
this.consumer.accept(event);
|
||||
this.callCount.incrementAndGet();
|
||||
} catch (Throwable t) {
|
||||
this.eventBus.getPlugin().getLogger().warn("Unable to pass event " + event.getClass().getSimpleName() + " to handler " + this.consumer.getClass().getName());
|
||||
|
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.gen;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import me.lucko.luckperms.api.LuckPermsApi;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents the generated specification for an instance of a given {@link LuckPermsEvent}.
|
||||
*/
|
||||
public class GeneratedEventSpec {
|
||||
|
||||
private static final Method TO_STRING_METHOD;
|
||||
private static final Method EQUALS_METHOD;
|
||||
private static final Method HASHCODE_METHOD;
|
||||
private static final Method GET_API_METHOD;
|
||||
static {
|
||||
try {
|
||||
TO_STRING_METHOD = Object.class.getMethod("toString");
|
||||
EQUALS_METHOD = Object.class.getMethod("equals", Object.class);
|
||||
HASHCODE_METHOD = Object.class.getMethod("hashCode");
|
||||
GET_API_METHOD = LuckPermsEvent.class.getMethod("getApi");
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final LoadingCache<Class<? extends LuckPermsEvent>, GeneratedEventSpec> CACHE = Caffeine.newBuilder()
|
||||
.build(GeneratedEventSpec::new);
|
||||
|
||||
public static GeneratedEventSpec lookup(Class<? extends LuckPermsEvent> event) {
|
||||
return CACHE.get(event);
|
||||
}
|
||||
|
||||
private final Class<? extends LuckPermsEvent> eventClass;
|
||||
private final List<Method> methods;
|
||||
private final List<Class<?>> returnTypes;
|
||||
|
||||
private GeneratedEventSpec(Class<? extends LuckPermsEvent> eventClass) {
|
||||
this.eventClass = eventClass;
|
||||
|
||||
List<Method> methods = new ArrayList<>();
|
||||
for (Method method : eventClass.getMethods()) {
|
||||
if (method.isDefault()) {
|
||||
continue;
|
||||
}
|
||||
if (GET_API_METHOD.equals(method)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
methods.add(method);
|
||||
}
|
||||
methods.sort(Comparator.comparingInt(o -> o.isAnnotationPresent(Param.class) ? o.getAnnotation(Param.class).value() : 0));
|
||||
this.methods = ImmutableList.copyOf(methods);
|
||||
|
||||
this.returnTypes = this.methods.stream()
|
||||
.map(Method::getReturnType)
|
||||
.collect(ImmutableCollectors.toList());
|
||||
}
|
||||
|
||||
public LuckPermsEvent newInstance(LuckPermsApi api, Object... params) {
|
||||
if (params.length != this.methods.size()) {
|
||||
throw new IllegalStateException("param length differs from number of methods. expected " + this.methods.size() + " - " + this.methods);
|
||||
}
|
||||
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
Object param = params[i];
|
||||
Class<?> expectedType = this.returnTypes.get(i);
|
||||
if (!expectedType.isInstance(param)) {
|
||||
throw new IllegalArgumentException("Parameter at index " + i + " cannot be assigned to " + expectedType);
|
||||
}
|
||||
}
|
||||
|
||||
EventInvocationHandler eventInvocationHandler = new EventInvocationHandler(api, params);
|
||||
return (LuckPermsEvent) Proxy.newProxyInstance(GeneratedEventSpec.class.getClassLoader(), new Class[]{this.eventClass}, eventInvocationHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* An invocation handler bound to a set of parameters, used to implement the event as a proxy.
|
||||
*/
|
||||
private final class EventInvocationHandler implements InvocationHandler {
|
||||
private final LuckPermsApi api;
|
||||
private final Object[] fields;
|
||||
|
||||
EventInvocationHandler(LuckPermsApi api, Object[] fields) {
|
||||
this.api = api;
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
if (TO_STRING_METHOD.equals(method)) {
|
||||
return "GeneratedEvent(" +
|
||||
"proxy=" + proxy + ", " +
|
||||
"class=" + GeneratedEventSpec.this.eventClass.toString() + ", " +
|
||||
"fields=" + Arrays.toString(this.fields) + ")";
|
||||
}
|
||||
if (EQUALS_METHOD.equals(method)) {
|
||||
return proxy == args[0];
|
||||
}
|
||||
if (HASHCODE_METHOD.equals(method)) {
|
||||
return System.identityHashCode(proxy);
|
||||
}
|
||||
if (GET_API_METHOD.equals(method)) {
|
||||
return this.api;
|
||||
}
|
||||
|
||||
if (method.getDeclaringClass() == Object.class || method.isDefault()) {
|
||||
return MethodHandles.lookup()
|
||||
.in(method.getDeclaringClass())
|
||||
.unreflectSpecial(method, method.getDeclaringClass())
|
||||
.bindTo(proxy)
|
||||
.invokeWithArguments(args);
|
||||
}
|
||||
|
||||
int methodIndex = GeneratedEventSpec.this.methods.indexOf(method);
|
||||
if (methodIndex == -1) {
|
||||
throw new UnsupportedOperationException("Method not supported: " + method);
|
||||
}
|
||||
|
||||
return this.fields[methodIndex];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.event.sync.ConfigReloadEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
public class EventConfigReload extends AbstractEvent implements ConfigReloadEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConfigReloadEvent()";
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.caching.GroupData;
|
||||
import me.lucko.luckperms.api.event.group.GroupCacheLoadEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventGroupCacheLoad extends AbstractEvent implements GroupCacheLoadEvent {
|
||||
|
||||
private final Group group;
|
||||
private final GroupData loadedData;
|
||||
|
||||
public EventGroupCacheLoad(Group group, GroupData loadedData) {
|
||||
this.group = group;
|
||||
this.loadedData = loadedData;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Group getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public GroupData getLoadedData() {
|
||||
return this.loadedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GroupCacheLoadEvent(group=" + this.getGroup() + ", loadedData=" + this.getLoadedData() + ")";
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.api.event.group.GroupCreateEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventGroupCreate extends AbstractEvent implements GroupCreateEvent {
|
||||
|
||||
private final Group group;
|
||||
private final CreationCause cause;
|
||||
|
||||
public EventGroupCreate(Group group, CreationCause cause) {
|
||||
this.group = group;
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Group getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CreationCause getCause() {
|
||||
return this.cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GroupCreateEvent(group=" + this.getGroup() + ", cause=" + this.getCause() + ")";
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.caching.GroupData;
|
||||
import me.lucko.luckperms.api.event.group.GroupDataRecalculateEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventGroupDataRecalculate extends AbstractEvent implements GroupDataRecalculateEvent {
|
||||
|
||||
private final Group group;
|
||||
private final GroupData data;
|
||||
|
||||
public EventGroupDataRecalculate(Group group, GroupData data) {
|
||||
this.group = group;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Group getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public GroupData getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GroupDataRecalculateEvent(group=" + this.getGroup() + ", data=" + this.getData() + ")";
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||
import me.lucko.luckperms.api.event.group.GroupDeleteEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventGroupDelete extends AbstractEvent implements GroupDeleteEvent {
|
||||
|
||||
private final String groupName;
|
||||
private final Set<Node> existingData;
|
||||
private final DeletionCause cause;
|
||||
|
||||
public EventGroupDelete(String groupName, Set<Node> existingData, DeletionCause cause) {
|
||||
this.groupName = groupName;
|
||||
this.existingData = existingData;
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getGroupName() {
|
||||
return this.groupName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Node> getExistingData() {
|
||||
return this.existingData;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DeletionCause getCause() {
|
||||
return this.cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GroupDeleteEvent(" +
|
||||
"groupName=" + this.getGroupName() + ", " +
|
||||
"existingData=" + this.getExistingData() + ", " +
|
||||
"cause=" + this.getCause() + ")";
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.event.group.GroupLoadEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventGroupLoad extends AbstractEvent implements GroupLoadEvent {
|
||||
|
||||
private final Group group;
|
||||
|
||||
public EventGroupLoad(Group group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Group getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GroupLoadEvent(group=" + this.getGroup() + ")";
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.event.group.GroupLoadAllEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
public class EventGroupLoadAll extends AbstractEvent implements GroupLoadAllEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GroupLoadAllEvent()";
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.log.LogBroadcastEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventLogBroadcast extends AbstractEvent implements LogBroadcastEvent {
|
||||
|
||||
private final AtomicBoolean cancellationState;
|
||||
private final LogEntry entry;
|
||||
private final Origin origin;
|
||||
|
||||
public EventLogBroadcast(AtomicBoolean cancellationState, LogEntry entry, Origin origin) {
|
||||
this.cancellationState = cancellationState;
|
||||
this.entry = entry;
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AtomicBoolean getCancellationState() {
|
||||
return this.cancellationState;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LogEntry getEntry() {
|
||||
return this.entry;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Origin getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogBroadcastEvent(" +
|
||||
"cancellationState=" + this.getCancellationState() + ", " +
|
||||
"entry=" + this.getEntry() + ", " +
|
||||
"origin=" + this.getOrigin() + ")";
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.log.LogNetworkPublishEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventLogNetworkPublish extends AbstractEvent implements LogNetworkPublishEvent {
|
||||
|
||||
private final AtomicBoolean cancellationState;
|
||||
private final UUID logId;
|
||||
private final LogEntry entry;
|
||||
|
||||
public EventLogNetworkPublish(AtomicBoolean cancellationState, UUID logId, LogEntry entry) {
|
||||
this.cancellationState = cancellationState;
|
||||
this.logId = logId;
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AtomicBoolean getCancellationState() {
|
||||
return this.cancellationState;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UUID getLogId() {
|
||||
return this.logId;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LogEntry getEntry() {
|
||||
return this.entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogNetworkPublishEvent(" +
|
||||
"cancellationState=" + this.getCancellationState() + ", " +
|
||||
"logId=" + this.getLogId() + ", " +
|
||||
"entry=" + this.getEntry() + ")";
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.log.LogNotifyEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
import me.lucko.luckperms.common.event.model.SenderEntity;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventLogNotify extends AbstractEvent implements LogNotifyEvent {
|
||||
|
||||
private final AtomicBoolean cancellationState;
|
||||
private final LogEntry entry;
|
||||
private final Origin origin;
|
||||
private final Sender sender;
|
||||
|
||||
private Entity notifiable;
|
||||
|
||||
public EventLogNotify(AtomicBoolean cancellationState, LogEntry entry, Origin origin, Sender sender) {
|
||||
this.cancellationState = cancellationState;
|
||||
this.entry = entry;
|
||||
this.origin = origin;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public synchronized Entity getNotifiable() {
|
||||
if (this.notifiable == null) {
|
||||
this.notifiable = new SenderEntity(this.sender);
|
||||
}
|
||||
return this.notifiable;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AtomicBoolean getCancellationState() {
|
||||
return this.cancellationState;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LogEntry getEntry() {
|
||||
return this.entry;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Origin getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogNotifyEvent(" +
|
||||
"cancellationState=" + this.getCancellationState() + ", " +
|
||||
"entry=" + this.getEntry() + ", " +
|
||||
"origin=" + this.getOrigin() + ", " +
|
||||
"notifiable=" + this.getNotifiable() + ")";
|
||||
}
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.log.LogPublishEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventLogPublish extends AbstractEvent implements LogPublishEvent {
|
||||
|
||||
private final AtomicBoolean cancellationState;
|
||||
private final LogEntry entry;
|
||||
|
||||
public EventLogPublish(AtomicBoolean cancellationState, LogEntry entry) {
|
||||
this.cancellationState = cancellationState;
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AtomicBoolean getCancellationState() {
|
||||
return this.cancellationState;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LogEntry getEntry() {
|
||||
return this.entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogPublishEvent(cancellationState=" + this.getCancellationState() + ", entry=" + this.getEntry() + ")";
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.log.LogReceiveEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventLogReceive extends AbstractEvent implements LogReceiveEvent {
|
||||
|
||||
private final UUID logId;
|
||||
private final LogEntry entry;
|
||||
|
||||
public EventLogReceive(UUID logId, LogEntry entry) {
|
||||
this.logId = logId;
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UUID getLogId() {
|
||||
return this.logId;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LogEntry getEntry() {
|
||||
return this.entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogReceiveEvent(logId=" + this.getLogId() + ", entry=" + this.getEntry() + ")";
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.node.NodeAddEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventNodeAdd extends AbstractEvent implements NodeAddEvent {
|
||||
|
||||
private final Node node;
|
||||
private final PermissionHolder target;
|
||||
private final Set<Node> dataBefore;
|
||||
private final Set<Node> dataAfter;
|
||||
|
||||
public EventNodeAdd(Node node, PermissionHolder target, Set<Node> dataBefore, Set<Node> dataAfter) {
|
||||
this.node = node;
|
||||
this.target = target;
|
||||
this.dataBefore = dataBefore;
|
||||
this.dataAfter = dataAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUser() {
|
||||
return this.target instanceof User;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGroup() {
|
||||
return this.target instanceof Group;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node getNode() {
|
||||
return this.node;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public PermissionHolder getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Node> getDataBefore() {
|
||||
return this.dataBefore;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Node> getDataAfter() {
|
||||
return this.dataAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NodeAddEvent(" +
|
||||
"node=" + this.getNode() + ", " +
|
||||
"target=" + this.getTarget() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.node.NodeClearEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventNodeClear extends AbstractEvent implements NodeClearEvent {
|
||||
|
||||
private final PermissionHolder target;
|
||||
private final Set<Node> dataBefore;
|
||||
private final Set<Node> dataAfter;
|
||||
|
||||
public EventNodeClear(PermissionHolder target, Set<Node> dataBefore, Set<Node> dataAfter) {
|
||||
this.target = target;
|
||||
this.dataBefore = dataBefore;
|
||||
this.dataAfter = dataAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUser() {
|
||||
return this.target instanceof User;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGroup() {
|
||||
return this.target instanceof Group;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public PermissionHolder getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Node> getDataBefore() {
|
||||
return this.dataBefore;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Node> getDataAfter() {
|
||||
return this.dataAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NodeClearEvent(" +
|
||||
"target=" + this.getTarget() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Group;
|
||||
import me.lucko.luckperms.api.Node;
|
||||
import me.lucko.luckperms.api.PermissionHolder;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.node.NodeRemoveEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventNodeRemove extends AbstractEvent implements NodeRemoveEvent {
|
||||
|
||||
private final Node node;
|
||||
private final PermissionHolder target;
|
||||
private final Set<Node> dataBefore;
|
||||
private final Set<Node> dataAfter;
|
||||
|
||||
public EventNodeRemove(Node node, PermissionHolder target, Set<Node> dataBefore, Set<Node> dataAfter) {
|
||||
this.node = node;
|
||||
this.target = target;
|
||||
this.dataBefore = dataBefore;
|
||||
this.dataAfter = dataAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUser() {
|
||||
return this.target instanceof User;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGroup() {
|
||||
return this.target instanceof Group;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Node getNode() {
|
||||
return this.node;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public PermissionHolder getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Node> getDataBefore() {
|
||||
return this.dataBefore;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<Node> getDataAfter() {
|
||||
return this.dataAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NodeRemoveEvent(" +
|
||||
"node=" + this.getNode() + ", " +
|
||||
"target=" + this.getTarget() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.PlayerSaveResult;
|
||||
import me.lucko.luckperms.api.event.player.PlayerDataSaveEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventPlayerDataSave extends AbstractEvent implements PlayerDataSaveEvent {
|
||||
private final UUID uuid;
|
||||
private final String username;
|
||||
private final PlayerSaveResult result;
|
||||
|
||||
public EventPlayerDataSave(UUID uuid, String username, PlayerSaveResult result) {
|
||||
this.uuid = uuid;
|
||||
this.username = username;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public PlayerSaveResult getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PlayerDataSaveEvent(" +
|
||||
"uuid=" + this.uuid + ", " +
|
||||
"username=" + this.username + ", " +
|
||||
"result=" + this.result + ")";
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.event.sync.PostSyncEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
public class EventPostSync extends AbstractEvent implements PostSyncEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PostSyncEvent()";
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.event.sync.PreNetworkSyncEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventPreNetworkSync extends AbstractEvent implements PreNetworkSyncEvent {
|
||||
|
||||
private final AtomicBoolean cancellationState;
|
||||
private final UUID syncId;
|
||||
|
||||
public EventPreNetworkSync(AtomicBoolean cancellationState, UUID syncId) {
|
||||
this.cancellationState = cancellationState;
|
||||
this.syncId = syncId;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AtomicBoolean getCancellationState() {
|
||||
return this.cancellationState;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UUID getSyncId() {
|
||||
return this.syncId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PreNetworkSyncEvent(" +
|
||||
"cancellationState=" + this.getCancellationState() + ", " +
|
||||
"syncId=" + this.getSyncId() + ")";
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.event.sync.PreSyncEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventPreSync extends AbstractEvent implements PreSyncEvent {
|
||||
|
||||
private final AtomicBoolean cancellationState;
|
||||
|
||||
public EventPreSync(AtomicBoolean cancellationState) {
|
||||
this.cancellationState = cancellationState;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AtomicBoolean getCancellationState() {
|
||||
return this.cancellationState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PreSyncEvent(cancellationState=" + this.getCancellationState() + ")";
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.event.track.mutate.TrackAddGroupEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventTrackAddGroup extends AbstractEvent implements TrackAddGroupEvent {
|
||||
|
||||
private final String group;
|
||||
private final Track track;
|
||||
private final List<String> dataBefore;
|
||||
private final List<String> dataAfter;
|
||||
|
||||
public EventTrackAddGroup(String group, Track track, List<String> dataBefore, List<String> dataAfter) {
|
||||
this.group = group;
|
||||
this.track = track;
|
||||
this.dataBefore = dataBefore;
|
||||
this.dataAfter = dataAfter;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Track getTrack() {
|
||||
return this.track;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getDataBefore() {
|
||||
return this.dataBefore;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getDataAfter() {
|
||||
return this.dataAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TrackAddGroupEvent(" +
|
||||
"group=" + this.getGroup() + ", " +
|
||||
"track=" + this.getTrack() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.event.track.mutate.TrackClearEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventTrackClear extends AbstractEvent implements TrackClearEvent {
|
||||
|
||||
private final Track track;
|
||||
private final List<String> dataBefore;
|
||||
private final List<String> dataAfter;
|
||||
|
||||
public EventTrackClear(Track track, List<String> dataBefore, List<String> dataAfter) {
|
||||
this.track = track;
|
||||
this.dataBefore = dataBefore;
|
||||
this.dataAfter = dataAfter;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Track getTrack() {
|
||||
return this.track;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getDataBefore() {
|
||||
return this.dataBefore;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getDataAfter() {
|
||||
return this.dataAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TrackClearEvent(" +
|
||||
"track=" + this.getTrack() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.api.event.track.TrackCreateEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventTrackCreate extends AbstractEvent implements TrackCreateEvent {
|
||||
|
||||
private final Track track;
|
||||
private final CreationCause cause;
|
||||
|
||||
public EventTrackCreate(Track track, CreationCause cause) {
|
||||
this.track = track;
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Track getTrack() {
|
||||
return this.track;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CreationCause getCause() {
|
||||
return this.cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TrackCreateEvent(track=" + this.getTrack() + ", cause=" + this.getCause() + ")";
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||
import me.lucko.luckperms.api.event.track.TrackDeleteEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventTrackDelete extends AbstractEvent implements TrackDeleteEvent {
|
||||
|
||||
private final String trackName;
|
||||
private final List<String> existingData;
|
||||
private final DeletionCause cause;
|
||||
|
||||
public EventTrackDelete(String trackName, List<String> existingData, DeletionCause cause) {
|
||||
this.trackName = trackName;
|
||||
this.existingData = existingData;
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTrackName() {
|
||||
return this.trackName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getExistingData() {
|
||||
return this.existingData;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DeletionCause getCause() {
|
||||
return this.cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TrackDeleteEvent(" +
|
||||
"trackName=" + this.getTrackName() + ", " +
|
||||
"existingData=" + this.getExistingData() + ", " +
|
||||
"cause=" + this.getCause() + ")";
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.event.track.TrackLoadEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventTrackLoad extends AbstractEvent implements TrackLoadEvent {
|
||||
|
||||
private final Track track;
|
||||
|
||||
public EventTrackLoad(Track track) {
|
||||
this.track = track;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Track getTrack() {
|
||||
return this.track;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TrackLoadEvent(track=" + this.getTrack() + ")";
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.event.track.TrackLoadAllEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
public class EventTrackLoadAll extends AbstractEvent implements TrackLoadAllEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TrackLoadAllEvent()";
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.event.track.mutate.TrackRemoveGroupEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventTrackRemoveGroup extends AbstractEvent implements TrackRemoveGroupEvent {
|
||||
|
||||
private final String group;
|
||||
private final Track track;
|
||||
private final List<String> dataBefore;
|
||||
private final List<String> dataAfter;
|
||||
|
||||
public EventTrackRemoveGroup(String group, Track track, List<String> dataBefore, List<String> dataAfter) {
|
||||
this.group = group;
|
||||
this.track = track;
|
||||
this.dataBefore = dataBefore;
|
||||
this.dataAfter = dataAfter;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Track getTrack() {
|
||||
return this.track;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getDataBefore() {
|
||||
return this.dataBefore;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<String> getDataAfter() {
|
||||
return this.dataAfter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TrackRemoveGroupEvent(" +
|
||||
"group=" + this.getGroup() + ", " +
|
||||
"track=" + this.getTrack() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.caching.UserData;
|
||||
import me.lucko.luckperms.api.event.user.UserCacheLoadEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventUserCacheLoad extends AbstractEvent implements UserCacheLoadEvent {
|
||||
|
||||
private final User user;
|
||||
private final UserData loadedData;
|
||||
|
||||
public EventUserCacheLoad(User user, UserData loadedData) {
|
||||
this.user = user;
|
||||
this.loadedData = loadedData;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public User getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UserData getLoadedData() {
|
||||
return this.loadedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserCacheLoadEvent(user=" + this.getUser() + ", loadedData=" + this.getLoadedData() + ")";
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.caching.UserData;
|
||||
import me.lucko.luckperms.api.event.user.UserDataRecalculateEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventUserDataRecalculate extends AbstractEvent implements UserDataRecalculateEvent {
|
||||
|
||||
private final User user;
|
||||
private final UserData data;
|
||||
|
||||
public EventUserDataRecalculate(User user, UserData data) {
|
||||
this.user = user;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public User getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UserData getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserDataRecalculateEvent(user=" + this.getUser() + ", data=" + this.getData() + ")";
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.source.Source;
|
||||
import me.lucko.luckperms.api.event.user.track.TrackAction;
|
||||
import me.lucko.luckperms.api.event.user.track.UserDemoteEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventUserDemote extends AbstractEvent implements UserDemoteEvent {
|
||||
|
||||
private final Track track;
|
||||
private final User user;
|
||||
|
||||
private final String groupFrom;
|
||||
private final String groupTo;
|
||||
|
||||
private final Source source;
|
||||
|
||||
public EventUserDemote(Track track, User user, String groupFrom, String groupTo, Source source) {
|
||||
this.track = track;
|
||||
this.user = user;
|
||||
this.groupFrom = groupFrom;
|
||||
this.groupTo = groupTo;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Track getTrack() {
|
||||
return this.track;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public User getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TrackAction getAction() {
|
||||
return TrackAction.DEMOTION;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getGroupFrom() {
|
||||
return Optional.ofNullable(this.groupFrom);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getGroupTo() {
|
||||
return Optional.ofNullable(this.groupTo);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Source getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserDemoteEvent(" +
|
||||
"track=" + this.track + ", " +
|
||||
"user=" + this.user + ", " +
|
||||
"groupFrom=" + this.getGroupFrom() + ", " +
|
||||
"groupTo=" + this.getGroupTo() + ", " +
|
||||
"source=" + this.getSource() + ")";
|
||||
}
|
||||
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.event.user.UserFirstLoginEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventUserFirstLogin extends AbstractEvent implements UserFirstLoginEvent {
|
||||
|
||||
private final UUID uuid;
|
||||
private final String username;
|
||||
|
||||
public EventUserFirstLogin(UUID uuid, String username) {
|
||||
this.uuid = uuid;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserFirstLoginEvent(uuid=" + this.getUuid() + ", username=" + this.getUsername() + ")";
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.user.UserLoadEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventUserLoad extends AbstractEvent implements UserLoadEvent {
|
||||
|
||||
private final User user;
|
||||
|
||||
public EventUserLoad(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public User getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserLoadEvent(user=" + this.getUser() + ")";
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.user.UserLoginProcessEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventUserLoginProcess extends AbstractEvent implements UserLoginProcessEvent {
|
||||
|
||||
private final UUID uuid;
|
||||
private final String username;
|
||||
private final User user;
|
||||
|
||||
public EventUserLoginProcess(UUID uuid, String username, User user) {
|
||||
this.uuid = uuid;
|
||||
this.username = username;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserLoginProcessEvent(uuid=" + this.getUuid() + ", username=" + this.getUsername() + ", user=" + this.getUser() + ")";
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.source.Source;
|
||||
import me.lucko.luckperms.api.event.user.track.TrackAction;
|
||||
import me.lucko.luckperms.api.event.user.track.UserPromoteEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class EventUserPromote extends AbstractEvent implements UserPromoteEvent {
|
||||
|
||||
private final Track track;
|
||||
private final User user;
|
||||
|
||||
private final String groupFrom;
|
||||
private final String groupTo;
|
||||
|
||||
private final Source source;
|
||||
|
||||
public EventUserPromote(Track track, User user, String groupFrom, String groupTo, Source source) {
|
||||
this.track = track;
|
||||
this.user = user;
|
||||
this.groupFrom = groupFrom;
|
||||
this.groupTo = groupTo;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Track getTrack() {
|
||||
return this.track;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public User getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TrackAction getAction() {
|
||||
return TrackAction.PROMOTION;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getGroupFrom() {
|
||||
return Optional.ofNullable(this.groupFrom);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<String> getGroupTo() {
|
||||
return Optional.ofNullable(this.groupTo);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Source getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserPromoteEvent(" +
|
||||
"track=" + this.track + ", " +
|
||||
"user=" + this.user + ", " +
|
||||
"groupFrom=" + this.getGroupFrom() + ", " +
|
||||
"groupTo=" + this.getGroupTo() + ", " +
|
||||
"source=" + this.getSource() + ")";
|
||||
}
|
||||
|
||||
}
|
@ -56,6 +56,10 @@
|
||||
<pattern>net.kyori.text</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.text</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.event</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.eventbus</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.benmanes.caffeine</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.caffeine</shadedPattern>
|
||||
|
@ -110,7 +110,7 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin {
|
||||
|
||||
@Override
|
||||
protected Set<Dependency> getGlobalDependencies() {
|
||||
return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP);
|
||||
return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, Dependency.EVENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,6 +59,10 @@
|
||||
<pattern>net.kyori.text</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.text</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.event</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.eventbus</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.benmanes.caffeine</pattern>
|
||||
<shadedPattern>me.lucko.luckperms.lib.caffeine</shadedPattern>
|
||||
|
@ -112,7 +112,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
|
||||
|
||||
@Override
|
||||
protected Set<Dependency> getGlobalDependencies() {
|
||||
return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP,
|
||||
return EnumSet.of(Dependency.TEXT, Dependency.CAFFEINE, Dependency.OKIO, Dependency.OKHTTP, Dependency.EVENT,
|
||||
Dependency.CONFIGURATE_CORE, Dependency.CONFIGURATE_HOCON, Dependency.HOCON_CONFIG);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user