mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-27 21:29:47 +01:00
Fix broken usage of LogEntry#getActed
This commit is contained in:
parent
14005563a3
commit
22fba0c172
@ -33,6 +33,8 @@ import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a logged action.
|
||||
*
|
||||
* @see LuckPermsApi#newLogEntryBuilder() for creating an instance
|
||||
*/
|
||||
public interface LogEntry extends Comparable<LogEntry> {
|
||||
|
||||
@ -50,6 +52,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
||||
*
|
||||
* @return the actor id
|
||||
*/
|
||||
@Nonnull
|
||||
UUID getActor();
|
||||
|
||||
/**
|
||||
@ -57,6 +60,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
||||
*
|
||||
* @return the name of the actor
|
||||
*/
|
||||
@Nonnull
|
||||
String getActorName();
|
||||
|
||||
/**
|
||||
@ -64,6 +68,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
||||
*
|
||||
* @return the action type
|
||||
*/
|
||||
@Nonnull
|
||||
Type getType();
|
||||
|
||||
/**
|
||||
@ -73,6 +78,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
||||
*
|
||||
* @return the uuid of acted object
|
||||
*/
|
||||
@Nonnull
|
||||
Optional<UUID> getActed();
|
||||
|
||||
/**
|
||||
@ -80,6 +86,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
||||
*
|
||||
* @return the name of the acted object
|
||||
*/
|
||||
@Nonnull
|
||||
String getActedName();
|
||||
|
||||
/**
|
||||
@ -90,6 +97,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
||||
*
|
||||
* @return the action
|
||||
*/
|
||||
@Nonnull
|
||||
String getAction();
|
||||
|
||||
/**
|
||||
@ -112,6 +120,7 @@ public interface LogEntry extends Comparable<LogEntry> {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static Type valueOf(char code) {
|
||||
switch (code) {
|
||||
case 'U':
|
||||
|
@ -349,6 +349,7 @@ public interface LuckPermsApi {
|
||||
* @return a new builder
|
||||
* @since 4.0
|
||||
*/
|
||||
@Nonnull
|
||||
LogEntry.Builder newLogEntryBuilder();
|
||||
|
||||
/**
|
||||
|
@ -45,10 +45,10 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* PermissibleBase for LuckPerms.
|
||||
@ -162,13 +162,14 @@ public class LPPermissible extends PermissibleBase {
|
||||
|
||||
@Override
|
||||
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||
Set<PermissionAttachmentInfo> perms = new HashSet<>();
|
||||
perms.addAll(
|
||||
user.getCachedData().getPermissionData(calculateContexts()).getImmutableBacking().entrySet().stream()
|
||||
.map(e -> new PermissionAttachmentInfo(player, e.getKey(), null, e.getValue()))
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
return perms;
|
||||
Set<Map.Entry<String, Boolean>> permissions = user.getCachedData().getPermissionData(calculateContexts()).getImmutableBacking().entrySet();
|
||||
Set<PermissionAttachmentInfo> ret = new HashSet<>(permissions.size());
|
||||
|
||||
for (Map.Entry<String, Boolean> entry : permissions) {
|
||||
ret.add(new PermissionAttachmentInfo(player, entry.getKey(), null, entry.getValue()));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,10 +72,7 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
.thenComparing(LogEntry::getActor)
|
||||
.thenComparing(LogEntry::getActorName, String.CASE_INSENSITIVE_ORDER)
|
||||
.thenComparing(LogEntry::getType)
|
||||
.thenComparing(e -> {
|
||||
UUID u = e.getActed().orElse(null);
|
||||
return u == null ? "" : u.toString();
|
||||
})
|
||||
.thenComparing(e -> e.getActed().map(UUID::toString).orElse(""))
|
||||
.thenComparing(LogEntry::getActedName, String.CASE_INSENSITIVE_ORDER)
|
||||
.thenComparing(LogEntry::getAction);
|
||||
|
||||
@ -187,7 +184,7 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
this.getActor().equals(other.getActor()) &&
|
||||
this.getActorName().equals(other.getActorName()) &&
|
||||
this.getType() == other.getType() &&
|
||||
(this.getActed() == null ? other.getActed() == null : this.getActed().equals(other.getActed())) &&
|
||||
this.getActed().equals(other.getActed()) &&
|
||||
this.getActedName().equals(other.getActedName()) &&
|
||||
this.getAction().equals(other.getAction());
|
||||
}
|
||||
@ -200,7 +197,7 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
result = result * PRIME + this.getActor().hashCode();
|
||||
result = result * PRIME + this.getActorName().hashCode();
|
||||
result = result * PRIME + this.getType().hashCode();
|
||||
result = result * PRIME + (this.getActed() == null ? 43 : this.getActed().hashCode());
|
||||
result = result * PRIME + this.getActed().hashCode();
|
||||
result = result * PRIME + this.getActedName().hashCode();
|
||||
result = result * PRIME + this.getAction().hashCode();
|
||||
return result;
|
||||
@ -365,8 +362,8 @@ public class ExtendedLogEntry implements LogEntry {
|
||||
data.add("actor", new JsonPrimitive(entry.getActor().toString()));
|
||||
data.add("actorName", new JsonPrimitive(entry.getActorName()));
|
||||
data.add("type", new JsonPrimitive(entry.getType().name()));
|
||||
if (entry.getActed() != null) {
|
||||
data.add("acted", new JsonPrimitive(entry.getActed().toString()));
|
||||
if (entry.getActed().isPresent()) {
|
||||
data.add("acted", new JsonPrimitive(entry.getActed().get().toString()));
|
||||
}
|
||||
data.add("actedName", new JsonPrimitive(entry.getActedName()));
|
||||
data.add("action", new JsonPrimitive(entry.getAction()));
|
||||
|
@ -120,8 +120,8 @@ public class Log {
|
||||
public SortedSet<ExtendedLogEntry> getUserHistory(UUID uuid) {
|
||||
return content.stream()
|
||||
.filter(e -> e.getType() == LogEntry.Type.USER)
|
||||
.filter(e -> e.getActed() != null)
|
||||
.filter(e -> e.getActed().equals(uuid))
|
||||
.filter(e -> e.getActed().isPresent())
|
||||
.filter(e -> e.getActed().get().equals(uuid))
|
||||
.collect(Collectors.toCollection(TreeSet::new));
|
||||
}
|
||||
|
||||
@ -132,8 +132,8 @@ public class Log {
|
||||
public int getUserHistoryMaxPages(UUID uuid) {
|
||||
return getMaxPages(content.stream()
|
||||
.filter(e -> e.getType() == LogEntry.Type.USER)
|
||||
.filter(e -> e.getActed() != null)
|
||||
.filter(e -> e.getActed().equals(uuid))
|
||||
.filter(e -> e.getActed().isPresent())
|
||||
.filter(e -> e.getActed().get().equals(uuid))
|
||||
.count(), PAGE_ENTRIES);
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ public abstract class ConfigurateDao extends AbstractDao {
|
||||
(entry.getActor().equals(Constants.CONSOLE_UUID) ? "" : entry.getActor() + " "),
|
||||
entry.getActorName(),
|
||||
Character.toString(entry.getType().getCode()),
|
||||
(entry.getActed() == null ? "" : entry.getActed().toString() + " "),
|
||||
entry.getActed().map(e -> e.toString() + " ").orElse(""),
|
||||
entry.getActedName(),
|
||||
entry.getAction())
|
||||
);
|
||||
|
@ -170,8 +170,8 @@ public class MongoDao extends AbstractDao {
|
||||
.append("actedName", entry.getActedName())
|
||||
.append("action", entry.getAction());
|
||||
|
||||
if (entry.getActed() != null) {
|
||||
doc.append("acted", entry.getActed());
|
||||
if (entry.getActed().isPresent()) {
|
||||
doc.append("acted", entry.getActed().get());
|
||||
}
|
||||
|
||||
c.insertOne(doc, new InsertOneOptions());
|
||||
|
@ -234,7 +234,7 @@ public class SqlDao extends AbstractDao {
|
||||
ps.setString(2, entry.getActor().toString());
|
||||
ps.setString(3, entry.getActorName());
|
||||
ps.setString(4, Character.toString(entry.getType().getCode()));
|
||||
ps.setString(5, String.valueOf(entry.getActed()));
|
||||
ps.setString(5, entry.getActed().map(UUID::toString).orElse("null"));
|
||||
ps.setString(6, entry.getActedName());
|
||||
ps.setString(7, entry.getAction());
|
||||
ps.execute();
|
||||
|
@ -45,7 +45,7 @@ CREATE TABLE `{prefix}actions` (
|
||||
`id` INT AUTO_INCREMENT NOT NULL,
|
||||
`time` BIGINT NOT NULL,
|
||||
`actor_uuid` VARCHAR(36) NOT NULL,
|
||||
`actor_name` VARCHAR(100) NOT NULL,
|
||||
`actor_name` VARCHAR(100) NOT NULL,
|
||||
`type` CHAR(1) NOT NULL,
|
||||
`acted_uuid` VARCHAR(36) NOT NULL,
|
||||
`acted_name` VARCHAR(36) NOT NULL,
|
||||
|
@ -45,7 +45,7 @@ CREATE TABLE `{prefix}actions` (
|
||||
`id` INT AUTO_INCREMENT NOT NULL,
|
||||
`time` BIGINT NOT NULL,
|
||||
`actor_uuid` VARCHAR(36) NOT NULL,
|
||||
`actor_name` VARCHAR(100) NOT NULL,
|
||||
`actor_name` VARCHAR(100) NOT NULL,
|
||||
`type` CHAR(1) NOT NULL,
|
||||
`acted_uuid` VARCHAR(36) NOT NULL,
|
||||
`acted_name` VARCHAR(36) NOT NULL,
|
||||
|
@ -45,7 +45,7 @@ CREATE TABLE `{prefix}actions` (
|
||||
`id` INT AUTO_INCREMENT NOT NULL,
|
||||
`time` BIGINT NOT NULL,
|
||||
`actor_uuid` VARCHAR(36) NOT NULL,
|
||||
`actor_name` VARCHAR(100) NOT NULL,
|
||||
`actor_name` VARCHAR(100) NOT NULL,
|
||||
`type` CHAR(1) NOT NULL,
|
||||
`acted_uuid` VARCHAR(36) NOT NULL,
|
||||
`acted_name` VARCHAR(36) NOT NULL,
|
||||
|
@ -41,7 +41,7 @@ CREATE TABLE "{prefix}actions" (
|
||||
"id" SERIAL PRIMARY KEY NOT NULL,
|
||||
"time" BIGINT NOT NULL,
|
||||
"actor_uuid" VARCHAR(36) NOT NULL,
|
||||
"actor_name" VARCHAR(100) NOT NULL,
|
||||
"actor_name" VARCHAR(100) NOT NULL,
|
||||
"type" CHAR(1) NOT NULL,
|
||||
"acted_uuid" VARCHAR(36) NOT NULL,
|
||||
"acted_name" VARCHAR(36) NOT NULL,
|
||||
|
@ -43,7 +43,7 @@ CREATE TABLE `{prefix}actions` (
|
||||
`id` INTEGER PRIMARY KEY NOT NULL,
|
||||
`time` BIGINT NOT NULL,
|
||||
`actor_uuid` VARCHAR(36) NOT NULL,
|
||||
`actor_name` VARCHAR(100) NOT NULL,
|
||||
`actor_name` VARCHAR(100) NOT NULL,
|
||||
`type` CHAR(1) NOT NULL,
|
||||
`acted_uuid` VARCHAR(36) NOT NULL,
|
||||
`acted_name` VARCHAR(36) NOT NULL,
|
||||
|
Loading…
Reference in New Issue
Block a user