mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
Add source to UserPromote & UserDemote events (#722)
This commit is contained in:
parent
a1a2e189b6
commit
31df29194b
87
api/src/main/java/me/lucko/luckperms/api/Entity.java
Normal file
87
api/src/main/java/me/lucko/luckperms/api/Entity.java
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.api;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an entity on the server.
|
||||
*
|
||||
* <p>This does not relate directly to a "Minecraft Entity". The closest
|
||||
* comparison is to a "CommandSender" or "CommandSource" in Bukkit/Sponge.</p>
|
||||
*
|
||||
* <p>The various types of {@link Entity} are detailed in {@link Type}.</p>
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface Entity {
|
||||
|
||||
/**
|
||||
* Gets the unique id of the entity, if it has one.
|
||||
*
|
||||
* <p>For players, this returns their uuid assigned by the server.</p>
|
||||
*
|
||||
* @return the uuid of the object, if available
|
||||
*/
|
||||
@Nullable
|
||||
UUID getUniqueId();
|
||||
|
||||
/**
|
||||
* Gets the name of the object
|
||||
*
|
||||
* @return the object name
|
||||
*/
|
||||
@Nonnull
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gets the entities type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
@Nonnull
|
||||
Type getType();
|
||||
|
||||
/**
|
||||
* The different types of {@link Entity}
|
||||
*/
|
||||
enum Type {
|
||||
|
||||
/**
|
||||
* Represents a player connected to the server
|
||||
*/
|
||||
PLAYER,
|
||||
|
||||
/**
|
||||
* Represents the server console
|
||||
*/
|
||||
CONSOLE
|
||||
}
|
||||
|
||||
}
|
50
api/src/main/java/me/lucko/luckperms/api/event/Sourced.java
Normal file
50
api/src/main/java/me/lucko/luckperms/api/event/Sourced.java
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.api.event;
|
||||
|
||||
import me.lucko.luckperms.api.event.source.Source;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Represents an event with a {@link Source}.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface Sourced {
|
||||
|
||||
/**
|
||||
* Gets the events source.
|
||||
*
|
||||
* <p>Never returns null. In situations where the source is unknown, a
|
||||
* {@link Source} with type {@link Source.Type#UNKNOWN} is returned.</p>
|
||||
*
|
||||
* @return the source
|
||||
*/
|
||||
@Nonnull
|
||||
Source getSource();
|
||||
|
||||
}
|
@ -25,13 +25,11 @@
|
||||
|
||||
package me.lucko.luckperms.api.event.log;
|
||||
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.Cancellable;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
@ -60,7 +58,7 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable {
|
||||
* @return the origin of the log
|
||||
*/
|
||||
@Nonnull
|
||||
LogBroadcastEvent.Origin getOrigin();
|
||||
Origin getOrigin();
|
||||
|
||||
/**
|
||||
* Gets the object to be notified.
|
||||
@ -68,46 +66,27 @@ public interface LogNotifyEvent extends LuckPermsEvent, Cancellable {
|
||||
* @return the object to notify
|
||||
*/
|
||||
@Nonnull
|
||||
Notifiable getNotifiable();
|
||||
Entity getNotifiable();
|
||||
|
||||
/**
|
||||
* Represents an object which could be notified as a result of a
|
||||
* {@link LogNotifyEvent}.
|
||||
* Represents where a log entry is from
|
||||
*/
|
||||
interface Notifiable {
|
||||
enum Origin {
|
||||
|
||||
/**
|
||||
* Gets a {@link UUID} for the object, if it has one.
|
||||
*
|
||||
* <p>For Players, this method returns their unique id.</p>
|
||||
*
|
||||
* @return the uuid of the object, if available
|
||||
* Marks a log entry which originated from the current server instance
|
||||
*/
|
||||
@Nonnull
|
||||
Optional<UUID> getUuid();
|
||||
LOCAL,
|
||||
|
||||
/**
|
||||
* Gets the name of the object
|
||||
*
|
||||
* @return the name
|
||||
* Marks a log entry which originated from an API call on the current server instance
|
||||
*/
|
||||
@Nonnull
|
||||
String getName();
|
||||
LOCAL_API,
|
||||
|
||||
/**
|
||||
* Gets if the object is a console
|
||||
*
|
||||
* @return if the object is a console
|
||||
* Marks a log entry which was sent to this server via the messaging service
|
||||
*/
|
||||
boolean isConsole();
|
||||
|
||||
/**
|
||||
* Gets if the object is a player
|
||||
*
|
||||
* @return if the object is a player
|
||||
*/
|
||||
boolean isPlayer();
|
||||
|
||||
REMOTE
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.api.event.source;
|
||||
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Represents an {@link Entity} which was the {@link Source} of something.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface EntitySource extends Source {
|
||||
|
||||
/**
|
||||
* Gets the entity.
|
||||
*
|
||||
* @return the entity
|
||||
*/
|
||||
@Nonnull
|
||||
Entity getEntity();
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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.api.event.source;
|
||||
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Represents the source of an event.
|
||||
*
|
||||
* <p>Could also be described as the "thing" that caused an event to occur.</p>
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface Source {
|
||||
|
||||
/**
|
||||
* Gets the source type
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
@Nonnull
|
||||
Type getType();
|
||||
|
||||
/**
|
||||
* Represents a type of source
|
||||
*/
|
||||
enum Type {
|
||||
|
||||
/**
|
||||
* Represents an {@link Entity} source
|
||||
*
|
||||
* @see EntitySource
|
||||
*/
|
||||
ENTITY,
|
||||
|
||||
/**
|
||||
* Represents an unknown source
|
||||
*/
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
}
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.api.event.user.track;
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Sourced;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -36,7 +37,7 @@ import javax.annotation.Nonnull;
|
||||
/**
|
||||
* Called when a user interacts with a track through a promotion or demotion
|
||||
*/
|
||||
public interface UserTrackEvent extends LuckPermsEvent {
|
||||
public interface UserTrackEvent extends LuckPermsEvent, Sourced {
|
||||
|
||||
/**
|
||||
* Gets the track involved in the event
|
||||
|
@ -26,6 +26,7 @@
|
||||
package me.lucko.luckperms.common.actionlog;
|
||||
|
||||
import me.lucko.luckperms.api.event.log.LogBroadcastEvent;
|
||||
import me.lucko.luckperms.api.event.log.LogNotifyEvent;
|
||||
import me.lucko.luckperms.common.commands.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.impl.log.LogNotify;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
@ -43,7 +44,7 @@ public class LogDispatcher {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private void broadcast(ExtendedLogEntry entry, LogBroadcastEvent.Origin origin, Sender sender) {
|
||||
private void broadcast(ExtendedLogEntry entry, LogNotifyEvent.Origin origin, Sender sender) {
|
||||
this.plugin.getOnlineSenders()
|
||||
.filter(CommandPermission.LOG_NOTIFY::isAuthorized)
|
||||
.filter(s -> {
|
||||
@ -76,7 +77,7 @@ public class LogDispatcher {
|
||||
|
||||
boolean shouldCancel = !this.plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY);
|
||||
if (!this.plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL)) {
|
||||
broadcast(entry, LogBroadcastEvent.Origin.LOCAL, sender);
|
||||
broadcast(entry, LogNotifyEvent.Origin.LOCAL, sender);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,14 +98,14 @@ public class LogDispatcher {
|
||||
|
||||
boolean shouldCancel = !this.plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY);
|
||||
if (!this.plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.LOCAL_API)) {
|
||||
broadcast(entry, LogBroadcastEvent.Origin.LOCAL_API, null);
|
||||
broadcast(entry, LogNotifyEvent.Origin.LOCAL_API, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void dispatchFromRemote(ExtendedLogEntry entry) {
|
||||
boolean shouldCancel = !this.plugin.getConfiguration().get(ConfigKeys.BROADCAST_RECEIVED_LOG_ENTRIES) || !this.plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY);
|
||||
if (!this.plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.REMOTE)) {
|
||||
broadcast(entry, LogBroadcastEvent.Origin.LOCAL_API, null);
|
||||
broadcast(entry, LogNotifyEvent.Origin.LOCAL_API, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public class UserDemote extends SubCommand<User> {
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(user, sender, plugin);
|
||||
plugin.getEventFactory().handleUserDemote(user, track, old, null);
|
||||
plugin.getEventFactory().handleUserDemote(user, track, old, null, sender);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ public class UserDemote extends SubCommand<User> {
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(user, sender, plugin);
|
||||
plugin.getEventFactory().handleUserDemote(user, track, old, previousGroup.getName());
|
||||
plugin.getEventFactory().handleUserDemote(user, track, old, previousGroup.getName(), sender);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class UserPromote extends SubCommand<User> {
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(user, sender, plugin);
|
||||
plugin.getEventFactory().handleUserPromote(user, track, null, first);
|
||||
plugin.getEventFactory().handleUserPromote(user, track, null, first, sender);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ public class UserPromote extends SubCommand<User> {
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
save(user, sender, plugin);
|
||||
plugin.getEventFactory().handleUserPromote(user, track, old, nextGroup.getName());
|
||||
plugin.getEventFactory().handleUserPromote(user, track, old, nextGroup.getName(), sender);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.api.event.cause.DeletionCause;
|
||||
import me.lucko.luckperms.api.event.log.LogBroadcastEvent;
|
||||
import me.lucko.luckperms.api.event.log.LogNotifyEvent;
|
||||
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||
import me.lucko.luckperms.common.api.delegates.model.ApiPermissionHolder;
|
||||
import me.lucko.luckperms.common.api.delegates.model.ApiUser;
|
||||
@ -72,6 +73,8 @@ import me.lucko.luckperms.common.event.impl.EventUserFirstLogin;
|
||||
import me.lucko.luckperms.common.event.impl.EventUserLoad;
|
||||
import me.lucko.luckperms.common.event.impl.EventUserLoginProcess;
|
||||
import me.lucko.luckperms.common.event.impl.EventUserPromote;
|
||||
import me.lucko.luckperms.common.event.model.EntitySender;
|
||||
import me.lucko.luckperms.common.event.model.SourceEntity;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.Track;
|
||||
@ -153,7 +156,7 @@ public final class EventFactory {
|
||||
return cancel.get();
|
||||
}
|
||||
|
||||
public boolean handleLogNotify(boolean initialState, LogEntry entry, LogBroadcastEvent.Origin origin, Sender sender) {
|
||||
public boolean handleLogNotify(boolean initialState, LogEntry entry, LogNotifyEvent.Origin origin, Sender sender) {
|
||||
AtomicBoolean cancel = new AtomicBoolean(initialState);
|
||||
EventLogNotify event = new EventLogNotify(cancel, entry, origin, sender);
|
||||
fireEvent(event);
|
||||
@ -264,13 +267,13 @@ public final class EventFactory {
|
||||
fireEvent(event);
|
||||
}
|
||||
|
||||
public void handleUserDemote(User user, Track track, String from, String to) {
|
||||
EventUserDemote event = new EventUserDemote(track.getApiDelegate(), new ApiUser(user), from, to);
|
||||
public void handleUserDemote(User user, Track track, String from, String to, Sender source) {
|
||||
EventUserDemote event = new EventUserDemote(track.getApiDelegate(), new ApiUser(user), from, to, new SourceEntity(new EntitySender(source)));
|
||||
fireEventAsync(event);
|
||||
}
|
||||
|
||||
public void handleUserPromote(User user, Track track, String from, String to) {
|
||||
EventUserPromote event = new EventUserPromote(track.getApiDelegate(), new ApiUser(user), from, to);
|
||||
public void handleUserPromote(User user, Track track, String from, String to, Sender source) {
|
||||
EventUserPromote event = new EventUserPromote(track.getApiDelegate(), new ApiUser(user), from, to, new SourceEntity(new EntitySender(source)));
|
||||
fireEventAsync(event);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,6 @@ public class EventConfigReload extends AbstractEvent implements ConfigReloadEven
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventConfigReload()";
|
||||
return "ConfigReloadEvent()";
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,6 @@ public class EventGroupCacheLoad extends AbstractEvent implements GroupCacheLoad
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventGroupCacheLoad(group=" + this.getGroup() + ", loadedData=" + this.getLoadedData() + ")";
|
||||
return "GroupCacheLoadEvent(group=" + this.getGroup() + ", loadedData=" + this.getLoadedData() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,6 @@ public class EventGroupCreate extends AbstractEvent implements GroupCreateEvent
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventGroupCreate(group=" + this.getGroup() + ", cause=" + this.getCause() + ")";
|
||||
return "GroupCreateEvent(group=" + this.getGroup() + ", cause=" + this.getCause() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,6 @@ public class EventGroupDataRecalculate extends AbstractEvent implements GroupDat
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventGroupDataRecalculate(group=" + this.getGroup() + ", data=" + this.getData() + ")";
|
||||
return "GroupDataRecalculateEvent(group=" + this.getGroup() + ", data=" + this.getData() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,9 @@ public class EventGroupDelete extends AbstractEvent implements GroupDeleteEvent
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventGroupDelete(groupName=" + this.getGroupName() + ", existingData=" + this.getExistingData() + ", cause=" + this.getCause() + ")";
|
||||
return "GroupDeleteEvent(" +
|
||||
"groupName=" + this.getGroupName() + ", " +
|
||||
"existingData=" + this.getExistingData() + ", " +
|
||||
"cause=" + this.getCause() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,6 @@ public class EventGroupLoad extends AbstractEvent implements GroupLoadEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventGroupLoad(group=" + this.getGroup() + ")";
|
||||
return "GroupLoadEvent(group=" + this.getGroup() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,6 @@ public class EventGroupLoadAll extends AbstractEvent implements GroupLoadAllEven
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventGroupLoadAll()";
|
||||
return "GroupLoadAllEvent()";
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,9 @@ public class EventLogBroadcast extends AbstractEvent implements LogBroadcastEven
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventLogBroadcast(cancellationState=" + this.getCancellationState() + ", entry=" + this.getEntry() + ", origin=" + this.getOrigin() + ")";
|
||||
return "LogBroadcastEvent(" +
|
||||
"cancellationState=" + this.getCancellationState() + ", " +
|
||||
"entry=" + this.getEntry() + ", " +
|
||||
"origin=" + this.getOrigin() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,9 @@ public class EventLogNetworkPublish extends AbstractEvent implements LogNetworkP
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventLogNetworkPublish(cancellationState=" + this.getCancellationState() + ", logId=" + this.getLogId() + ", entry=" + this.getEntry() + ")";
|
||||
return "LogNetworkPublishEvent(" +
|
||||
"cancellationState=" + this.getCancellationState() + ", " +
|
||||
"logId=" + this.getLogId() + ", " +
|
||||
"entry=" + this.getEntry() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -25,14 +25,13 @@
|
||||
|
||||
package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.api.event.log.LogBroadcastEvent;
|
||||
import me.lucko.luckperms.api.event.log.LogNotifyEvent;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
import me.lucko.luckperms.common.event.model.EntitySender;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -41,12 +40,12 @@ public class EventLogNotify extends AbstractEvent implements LogNotifyEvent {
|
||||
|
||||
private final AtomicBoolean cancellationState;
|
||||
private final LogEntry entry;
|
||||
private final LogBroadcastEvent.Origin origin;
|
||||
private final Origin origin;
|
||||
private final Sender sender;
|
||||
|
||||
private Notifiable notifiable;
|
||||
private Entity notifiable;
|
||||
|
||||
public EventLogNotify(AtomicBoolean cancellationState, LogEntry entry, LogBroadcastEvent.Origin origin, Sender sender) {
|
||||
public EventLogNotify(AtomicBoolean cancellationState, LogEntry entry, Origin origin, Sender sender) {
|
||||
this.cancellationState = cancellationState;
|
||||
this.entry = entry;
|
||||
this.origin = origin;
|
||||
@ -55,9 +54,9 @@ public class EventLogNotify extends AbstractEvent implements LogNotifyEvent {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public synchronized Notifiable getNotifiable() {
|
||||
public synchronized Entity getNotifiable() {
|
||||
if (this.notifiable == null) {
|
||||
this.notifiable = new SenderNotifiable(this.sender);
|
||||
this.notifiable = new EntitySender(this.sender);
|
||||
}
|
||||
return this.notifiable;
|
||||
}
|
||||
@ -76,50 +75,17 @@ public class EventLogNotify extends AbstractEvent implements LogNotifyEvent {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public LogBroadcastEvent.Origin getOrigin() {
|
||||
public Origin getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
public Sender getSender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventLogNotify(cancellationState=" + this.getCancellationState() + ", entry=" + this.getEntry() + ", origin=" + this.getOrigin() + ", sender=" + this.getSender() + ", notifiable=" + this.getNotifiable() + ")";
|
||||
}
|
||||
|
||||
private static final class SenderNotifiable implements Notifiable {
|
||||
private final Sender sender;
|
||||
|
||||
public SenderNotifiable(Sender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<UUID> getUuid() {
|
||||
if (this.sender.isConsole()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(this.sender.getUuid());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return this.sender.isConsole();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return !this.sender.isConsole();
|
||||
}
|
||||
return "LogNotifyEvent(" +
|
||||
"cancellationState=" + this.getCancellationState() + ", " +
|
||||
"entry=" + this.getEntry() + ", " +
|
||||
"origin=" + this.getOrigin() + ", " +
|
||||
"notifiable=" + this.getNotifiable() + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -57,6 +57,6 @@ public class EventLogPublish extends AbstractEvent implements LogPublishEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventLogPublish(cancellationState=" + this.getCancellationState() + ", entry=" + this.getEntry() + ")";
|
||||
return "LogPublishEvent(cancellationState=" + this.getCancellationState() + ", entry=" + this.getEntry() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,6 @@ public class EventLogReceive extends AbstractEvent implements LogReceiveEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventLogReceive(logId=" + this.getLogId() + ", entry=" + this.getEntry() + ")";
|
||||
return "LogReceiveEvent(logId=" + this.getLogId() + ", entry=" + this.getEntry() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,10 @@ public class EventNodeAdd extends AbstractEvent implements NodeAddEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventNodeAdd(node=" + this.getNode() + ", target=" + this.getTarget() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")";
|
||||
return "NodeAddEvent(" +
|
||||
"node=" + this.getNode() + ", " +
|
||||
"target=" + this.getTarget() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,9 @@ public class EventNodeClear extends AbstractEvent implements NodeClearEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventNodeClear(target=" + this.getTarget() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")";
|
||||
return "NodeClearEvent(" +
|
||||
"target=" + this.getTarget() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,10 @@ public class EventNodeRemove extends AbstractEvent implements NodeRemoveEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventNodeRemove(node=" + this.getNode() + ", target=" + this.getTarget() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")";
|
||||
return "NodeRemoveEvent(" +
|
||||
"node=" + this.getNode() + ", " +
|
||||
"target=" + this.getTarget() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,6 @@ public class EventPostSync extends AbstractEvent implements PostSyncEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventPostSync()";
|
||||
return "PostSyncEvent()";
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ public class EventPreNetworkSync extends AbstractEvent implements PreNetworkSync
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventPreNetworkSync(cancellationState=" + this.getCancellationState() + ", syncId=" + this.getSyncId() + ")";
|
||||
return "PreNetworkSyncEvent(" +
|
||||
"cancellationState=" + this.getCancellationState() + ", " +
|
||||
"syncId=" + this.getSyncId() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,6 @@ public class EventPreSync extends AbstractEvent implements PreSyncEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventPreSync(cancellationState=" + this.getCancellationState() + ")";
|
||||
return "PreSyncEvent(cancellationState=" + this.getCancellationState() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,10 @@ public class EventTrackAddGroup extends AbstractEvent implements TrackAddGroupEv
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventTrackAddGroup(group=" + this.getGroup() + ", track=" + this.getTrack() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")";
|
||||
return "TrackAddGroupEvent(" +
|
||||
"group=" + this.getGroup() + ", " +
|
||||
"track=" + this.getTrack() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,9 @@ public class EventTrackClear extends AbstractEvent implements TrackClearEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventTrackClear(track=" + this.getTrack() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")";
|
||||
return "TrackClearEvent(" +
|
||||
"track=" + this.getTrack() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,6 @@ public class EventTrackCreate extends AbstractEvent implements TrackCreateEvent
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventTrackCreate(track=" + this.getTrack() + ", cause=" + this.getCause() + ")";
|
||||
return "TrackCreateEvent(track=" + this.getTrack() + ", cause=" + this.getCause() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,9 @@ public class EventTrackDelete extends AbstractEvent implements TrackDeleteEvent
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventTrackDelete(trackName=" + this.getTrackName() + ", existingData=" + this.getExistingData() + ", cause=" + this.getCause() + ")";
|
||||
return "TrackDeleteEvent(" +
|
||||
"trackName=" + this.getTrackName() + ", " +
|
||||
"existingData=" + this.getExistingData() + ", " +
|
||||
"cause=" + this.getCause() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,6 @@ public class EventTrackLoad extends AbstractEvent implements TrackLoadEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventTrackLoad(track=" + this.getTrack() + ")";
|
||||
return "TrackLoadEvent(track=" + this.getTrack() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,6 @@ public class EventTrackLoadAll extends AbstractEvent implements TrackLoadAllEven
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventTrackLoadAll()";
|
||||
return "TrackLoadAllEvent()";
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,10 @@ public class EventTrackRemoveGroup extends AbstractEvent implements TrackRemoveG
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventTrackRemoveGroup(group=" + this.getGroup() + ", track=" + this.getTrack() + ", dataBefore=" + this.getDataBefore() + ", dataAfter=" + this.getDataAfter() + ")";
|
||||
return "TrackRemoveGroupEvent(" +
|
||||
"group=" + this.getGroup() + ", " +
|
||||
"track=" + this.getTrack() + ", " +
|
||||
"dataBefore=" + this.getDataBefore() + ", " +
|
||||
"dataAfter=" + this.getDataAfter() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,6 @@ public class EventUserCacheLoad extends AbstractEvent implements UserCacheLoadEv
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventUserCacheLoad(user=" + this.getUser() + ", loadedData=" + this.getLoadedData() + ")";
|
||||
return "UserCacheLoadEvent(user=" + this.getUser() + ", loadedData=" + this.getLoadedData() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,6 @@ public class EventUserDataRecalculate extends AbstractEvent implements UserDataR
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventUserDataRecalculate(user=" + this.getUser() + ", data=" + this.getData() + ")";
|
||||
return "UserDataRecalculateEvent(user=" + this.getUser() + ", data=" + this.getData() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.source.Source;
|
||||
import me.lucko.luckperms.api.event.user.track.TrackAction;
|
||||
import me.lucko.luckperms.api.event.user.track.UserDemoteEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
@ -43,11 +44,14 @@ public class EventUserDemote extends AbstractEvent implements UserDemoteEvent {
|
||||
private final String groupFrom;
|
||||
private final String groupTo;
|
||||
|
||||
public EventUserDemote(Track track, User user, String groupFrom, String groupTo) {
|
||||
private final Source source;
|
||||
|
||||
public EventUserDemote(Track track, User user, String groupFrom, String groupTo, Source source) {
|
||||
this.track = track;
|
||||
this.user = user;
|
||||
this.groupFrom = groupFrom;
|
||||
this.groupTo = groupTo;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -80,9 +84,20 @@ public class EventUserDemote extends AbstractEvent implements UserDemoteEvent {
|
||||
return Optional.ofNullable(this.groupTo);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Source getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventUserDemote(track=" + this.track + ", user=" + this.user + ", groupFrom=" + this.getGroupFrom() + ", groupTo=" + this.getGroupTo() + ")";
|
||||
return "UserDemoteEvent(" +
|
||||
"track=" + this.track + ", " +
|
||||
"user=" + this.user + ", " +
|
||||
"groupFrom=" + this.getGroupFrom() + ", " +
|
||||
"groupTo=" + this.getGroupTo() + ", " +
|
||||
"source=" + this.getSource() + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,6 +56,6 @@ public class EventUserFirstLogin extends AbstractEvent implements UserFirstLogin
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventUserFirstLogin(uuid=" + this.getUuid() + ", username=" + this.getUsername() + ")";
|
||||
return "UserFirstLoginEvent(uuid=" + this.getUuid() + ", username=" + this.getUsername() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,6 @@ public class EventUserLoad extends AbstractEvent implements UserLoadEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventUserLoad(user=" + this.getUser() + ")";
|
||||
return "UserLoadEvent(user=" + this.getUser() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,6 @@ public class EventUserLoginProcess extends AbstractEvent implements UserLoginPro
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventUserLoginProcess(uuid=" + this.getUuid() + ", username=" + this.getUsername() + ", user=" + this.getUser() + ")";
|
||||
return "UserLoginProcessEvent(uuid=" + this.getUuid() + ", username=" + this.getUsername() + ", user=" + this.getUser() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.common.event.impl;
|
||||
|
||||
import me.lucko.luckperms.api.Track;
|
||||
import me.lucko.luckperms.api.User;
|
||||
import me.lucko.luckperms.api.event.source.Source;
|
||||
import me.lucko.luckperms.api.event.user.track.TrackAction;
|
||||
import me.lucko.luckperms.api.event.user.track.UserPromoteEvent;
|
||||
import me.lucko.luckperms.common.event.AbstractEvent;
|
||||
@ -43,11 +44,14 @@ public class EventUserPromote extends AbstractEvent implements UserPromoteEvent
|
||||
private final String groupFrom;
|
||||
private final String groupTo;
|
||||
|
||||
public EventUserPromote(Track track, User user, String groupFrom, String groupTo) {
|
||||
private final Source source;
|
||||
|
||||
public EventUserPromote(Track track, User user, String groupFrom, String groupTo, Source source) {
|
||||
this.track = track;
|
||||
this.user = user;
|
||||
this.groupFrom = groupFrom;
|
||||
this.groupTo = groupTo;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -80,9 +84,20 @@ public class EventUserPromote extends AbstractEvent implements UserPromoteEvent
|
||||
return Optional.ofNullable(this.groupTo);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Source getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventUserPromote(track=" + this.track + ", user=" + this.user + ", groupFrom=" + this.getGroupFrom() + ", groupTo=" + this.getGroupTo() + ")";
|
||||
return "UserPromoteEvent(" +
|
||||
"track=" + this.track + ", " +
|
||||
"user=" + this.user + ", " +
|
||||
"groupFrom=" + this.getGroupFrom() + ", " +
|
||||
"groupTo=" + this.getGroupTo() + ", " +
|
||||
"source=" + this.getSource() + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.model;
|
||||
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class EntitySender implements Entity {
|
||||
private final Sender sender;
|
||||
|
||||
public EntitySender(Sender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
if (this.sender.isConsole()) {
|
||||
return null;
|
||||
}
|
||||
return this.sender.getUuid();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.sender.getName();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Type getType() {
|
||||
if (this.sender.isConsole()) {
|
||||
return Type.CONSOLE;
|
||||
} else {
|
||||
return Type.PLAYER;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Sender(type=" + getType() + ", sender=" + this.sender + ")";
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.model;
|
||||
|
||||
import me.lucko.luckperms.api.Entity;
|
||||
import me.lucko.luckperms.api.event.source.EntitySource;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class SourceEntity implements EntitySource {
|
||||
private final Entity entity;
|
||||
|
||||
public SourceEntity(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Type.ENTITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Sender(type=ENTITY, entity=" + this.entity + ")";
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.model;
|
||||
|
||||
import me.lucko.luckperms.api.event.source.Source;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class SourceUnknown implements Source {
|
||||
private static final Source INSTANCE = new SourceUnknown();
|
||||
|
||||
private SourceUnknown() {
|
||||
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Type.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Source(type=UNKNOWN)";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user