From bafada4f174f14379c76f317b621790224074294 Mon Sep 17 00:00:00 2001 From: Luck Date: Sun, 11 Aug 2019 22:42:01 +0100 Subject: [PATCH] Context & action log changes --- .gitignore | 24 +- .../lucko/luckperms/api/actionlog/Action.java | 150 +++---- .../lucko/luckperms/api/context/Context.java | 49 +++ .../api/context/ContextCalculator.java | 2 +- .../api/context/ContextConsumer.java | 15 +- .../luckperms/api/context/ContextSet.java | 36 +- .../api/context/ContextSetFactory.java | 2 - .../api/context/ImmutableContextSet.java | 71 +-- .../api/context/MutableContextSet.java | 74 +--- .../api/context/StaticContextCalculator.java | 6 +- build.gradle | 6 +- .../bukkit/context/WorldCalculator.java | 2 +- .../vault/LuckPermsVaultPermission.java | 2 +- .../context/BackendServerCalculator.java | 2 +- .../bungee/context/RedisBungeeCalculator.java | 2 +- .../common/actionlog/ExtendedLogEntry.java | 330 -------------- .../lucko/luckperms/common/actionlog/Log.java | 34 +- .../common/actionlog/LogDispatcher.java | 18 +- .../actionlog/LogEntryJsonSerializer.java | 38 +- .../common/actionlog/LoggedAction.java | 413 ++++++++++++++++++ .../api/implementation/ApiActionLogger.java | 8 +- .../implementation/ApiContextSetFactory.java | 5 - .../command/access/ArgumentPermissions.java | 4 +- .../common/command/utils/MessageUtils.java | 6 +- .../generic/meta/MetaAddChatMeta.java | 6 +- .../generic/meta/MetaAddTempChatMeta.java | 6 +- .../commands/generic/meta/MetaClear.java | 6 +- .../generic/meta/MetaRemoveChatMeta.java | 10 +- .../generic/meta/MetaRemoveTempChatMeta.java | 10 +- .../common/commands/generic/meta/MetaSet.java | 6 +- .../generic/meta/MetaSetChatMeta.java | 6 +- .../commands/generic/meta/MetaSetTemp.java | 6 +- .../generic/meta/MetaSetTempChatMeta.java | 6 +- .../commands/generic/meta/MetaUnset.java | 6 +- .../commands/generic/meta/MetaUnsetTemp.java | 6 +- .../commands/generic/other/HolderClear.java | 6 +- .../commands/generic/parent/ParentAdd.java | 6 +- .../generic/parent/ParentAddTemp.java | 6 +- .../commands/generic/parent/ParentClear.java | 6 +- .../generic/parent/ParentClearTrack.java | 6 +- .../commands/generic/parent/ParentRemove.java | 6 +- .../generic/parent/ParentRemoveTemp.java | 6 +- .../commands/generic/parent/ParentSet.java | 6 +- .../generic/parent/ParentSetTrack.java | 6 +- .../parent/UserSwitchPrimaryGroup.java | 6 +- .../generic/permission/PermissionClear.java | 6 +- .../generic/permission/PermissionSet.java | 6 +- .../generic/permission/PermissionSetTemp.java | 6 +- .../generic/permission/PermissionUnset.java | 6 +- .../permission/PermissionUnsetTemp.java | 6 +- .../common/commands/group/CreateGroup.java | 6 +- .../common/commands/group/DeleteGroup.java | 6 +- .../common/commands/group/GroupClone.java | 6 +- .../common/commands/group/GroupRename.java | 6 +- .../commands/group/GroupSetDisplayName.java | 10 +- .../common/commands/group/GroupSetWeight.java | 6 +- .../common/commands/log/LogGroupHistory.java | 23 +- .../common/commands/log/LogRecent.java | 27 +- .../common/commands/log/LogSearch.java | 21 +- .../common/commands/log/LogTrackHistory.java | 23 +- .../common/commands/log/LogUserHistory.java | 23 +- .../commands/misc/ApplyEditsCommand.java | 10 +- .../common/commands/track/CreateTrack.java | 6 +- .../common/commands/track/DeleteTrack.java | 6 +- .../common/commands/track/TrackAppend.java | 6 +- .../common/commands/track/TrackClear.java | 6 +- .../common/commands/track/TrackClone.java | 6 +- .../common/commands/track/TrackInsert.java | 6 +- .../common/commands/track/TrackRemove.java | 6 +- .../common/commands/track/TrackRename.java | 6 +- .../common/commands/user/UserClone.java | 6 +- .../common/commands/user/UserDemote.java | 10 +- .../common/commands/user/UserPromote.java | 10 +- .../common/context/ContextManager.java | 4 +- .../common/context/ContextSetComparator.java | 16 +- .../context/LPStaticContextsCalculator.java | 2 +- .../context/contextset/ContextImpl.java | 60 +++ .../contextset/ImmutableContextSetImpl.java | 76 +++- .../contextset/MutableContextSetImpl.java | 74 +++- .../messaging/LuckPermsMessagingService.java | 4 +- .../luckperms/common/node/AbstractNode.java | 10 +- .../common/node/factory/NodeFactory.java | 87 +--- .../implementation/mongodb/MongoStorage.java | 40 +- .../implementation/sql/SqlStorage.java | 33 +- .../common/verbose/event/VerboseEvent.java | 4 +- .../nukkit/context/WorldCalculator.java | 2 +- .../sponge/service/CompatibilityUtil.java | 8 +- .../context/AbstractDelegatingContextSet.java | 2 +- .../DelegatingImmutableContextSet.java | 5 +- .../context/DelegatingMutableContextSet.java | 12 +- .../SpongeProxiedContextCalculator.java | 2 +- .../sponge/context/WorldCalculator.java | 2 +- .../context/BackendServerCalculator.java | 2 +- 93 files changed, 1109 insertions(+), 1040 deletions(-) create mode 100644 api/src/main/java/me/lucko/luckperms/api/context/Context.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java create mode 100644 common/src/main/java/me/lucko/luckperms/common/actionlog/LoggedAction.java create mode 100644 common/src/main/java/me/lucko/luckperms/common/context/contextset/ContextImpl.java diff --git a/.gitignore b/.gitignore index 4fb2f30a7..1cb4ee2b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,12 @@ -### Intellij ### -.idea/ -*.iws -/out/ +### Gradle & IntelliJ ### +.gradle/ +/.idea/ +build/ +out/ +run/ *.iml .idea_modules/ -atlassian-ide-plugin.xml + ### Eclipse ### .metadata @@ -26,6 +28,7 @@ local.properties .project .classpath + ### Linux ### *~ .fuse_hidden* @@ -33,6 +36,7 @@ local.properties .Trash-* .nfs* + ### macOS ### .DS_Store .AppleDouble @@ -52,6 +56,7 @@ Network Trash Folder Temporary Items .apdisk + ### NetBeans ### nbproject/private/ build/ @@ -60,6 +65,7 @@ dist/ nbdist/ .nb-gradle/ + ### Windows ### # Windows thumbnail cache files Thumbs.db @@ -69,11 +75,3 @@ ehthumbs_vista.db [Dd]esktop.ini $RECYCLE.BIN/ *.lnk - -### Gradle ### -.gradle -/build/ -/out/ -gradle-app.setting -!gradle-wrapper.jar -.gradletasknamecache diff --git a/api/src/main/java/me/lucko/luckperms/api/actionlog/Action.java b/api/src/main/java/me/lucko/luckperms/api/actionlog/Action.java index 2631da02c..4da0d15a4 100644 --- a/api/src/main/java/me/lucko/luckperms/api/actionlog/Action.java +++ b/api/src/main/java/me/lucko/luckperms/api/actionlog/Action.java @@ -30,6 +30,7 @@ import me.lucko.luckperms.api.LuckPermsProvider; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; +import java.time.Instant; import java.util.Optional; import java.util.UUID; @@ -48,50 +49,25 @@ public interface Action extends Comparable { } /** - * Gets the time in unix seconds when the action occurred. + * Gets the time when the action occurred. * * @return the timestamp */ - long getTimestamp(); + @NonNull Instant getTimestamp(); /** - * Gets the id of the object which performed the action. + * Gets the source of the action. * - *

This is the players uuid in most cases.

- * - * @return the actor id + * @return the source */ - @NonNull UUID getActor(); + @NonNull Source getSource(); /** - * Gets the name describing the actor. + * Gets the target of the action. * - * @return the name of the actor + * @return the target */ - @NonNull String getActorName(); - - /** - * Gets the type of action. - * - * @return the action type - */ - @NonNull Type getType(); - - /** - * Gets the uuid of the object which was acted upon. - * - *

Will only return a value for {@link Type#USER} entries.

- * - * @return the uuid of acted object - */ - @NonNull Optional getActed(); - - /** - * Gets the name describing the object which was acted upon - * - * @return the name of the acted object - */ - @NonNull String getActedName(); + @NonNull Target getTarget(); /** * Returns a string describing the action which took place. @@ -101,71 +77,65 @@ public interface Action extends Comparable { * * @return the action */ - @NonNull String getAction(); + @NonNull String getDescription(); /** - * Represents the type of a {@link Action}. + * Represents the source of an action. */ - enum Type { - USER('U'), GROUP('G'), TRACK('T'); + interface Source { /** - * Parses a {@link Type} from a string. + * Gets the source unique id. * - * @param type the string - * @return a type - * @throws IllegalArgumentException if a type could not be parsed + * @return the source unique id */ - public static @NonNull Type parse(String type) { - try { - return valueOf(type); - } catch (IllegalArgumentException e) { - // ignore - } - try { - return valueOf(type.charAt(0)); - } catch (IllegalArgumentException e) { - // ignore - } - throw new IllegalArgumentException("Unknown type: " + type); - } + @NonNull UUID getUniqueId(); /** - * Returns a {@link Type} by its code. + * Gets the source name. * - * @param code the code - see {@link Type#getCode()}. - * @return a type - * @throws IllegalArgumentException if a type could not be resolved + * @return the source name */ - public static @NonNull Type valueOf(char code) { - switch (code) { - case 'U': - case 'u': - return USER; - case 'G': - case 'g': - return GROUP; - case 'T': - case 't': - return TRACK; - default: - throw new IllegalArgumentException("Unknown code: " + code); - } - } + @NonNull String getName(); - private final char code; + } - Type(char code) { - this.code = code; - } + /** + * Represents the target of an action. + */ + interface Target { - public char getCode() { - return this.code; + /** + * Gets the target unique id. + * + * @return the target unique id + */ + @NonNull Optional getUniqueId(); + + /** + * Gets the target name. + * + * @return the target name + */ + @NonNull String getName(); + + /** + * Gets the target type. + * + * @return the target type + */ + @NonNull Type getType(); + + /** + * Represents the type of a {@link Target}. + */ + enum Type { + USER, GROUP, TRACK } } /** - * Builds a LogEntry instance + * Builds an {@link Action} instance */ interface Builder { @@ -176,61 +146,55 @@ public interface Action extends Comparable { * @return the builder * @see Action#getTimestamp() */ - @NonNull Builder timestamp(long timestamp); + @NonNull Builder timestamp(@NonNull Instant timestamp); /** * Sets the actor of the entry. * * @param actor the actor * @return the builder - * @see Action#getActor() */ - @NonNull Builder actor(@NonNull UUID actor); + @NonNull Builder source(@NonNull UUID actor); /** * Sets the actor name of the entry. * * @param actorName the actor name * @return the builder - * @see Action#getActorName() */ - @NonNull Builder actorName(@NonNull String actorName); + @NonNull Builder sourceName(@NonNull String actorName); /** * Sets the type of the entry. * * @param type the type * @return the builder - * @see Action#getType() */ - @NonNull Builder type(@NonNull Type type); + @NonNull Builder targetType(Action.Target.Type type); /** * Sets the acted object for the entry. * * @param acted the acted object * @return the builder - * @see Action#getActed() */ - @NonNull Builder acted(@Nullable UUID acted); + @NonNull Builder target(@Nullable UUID acted); /** * Sets the acted name for the entry. * * @param actedName the acted name * @return the builder - * @see Action#getActedName() */ - @NonNull Builder actedName(@NonNull String actedName); + @NonNull Builder targetName(@NonNull String actedName); /** * Sets the action of the entry. * * @param action the action * @return the builder - * @see Action#getAction() */ - @NonNull Builder action(@NonNull String action); + @NonNull Builder description(@NonNull String action); /** * Creates a {@link Action} instance from the builder. diff --git a/api/src/main/java/me/lucko/luckperms/api/context/Context.java b/api/src/main/java/me/lucko/luckperms/api/context/Context.java new file mode 100644 index 000000000..db062d92f --- /dev/null +++ b/api/src/main/java/me/lucko/luckperms/api/context/Context.java @@ -0,0 +1,49 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.luckperms.api.context; + +import org.checkerframework.checker.nullness.qual.NonNull; + +/** + * Represents an individual context pair. + */ +public interface Context { + + /** + * Gets the context key. + * + * @return the key + */ + @NonNull String getKey(); + + /** + * Gets the context value + * + * @return the value + */ + @NonNull String getValue(); + +} diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java b/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java index 86761cb58..dd9a020d4 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/ContextCalculator.java @@ -92,6 +92,6 @@ public interface ContextCalculator { * @param target the target contextual subject for this operation * @param consumer the {@link ContextConsumer} to submit contexts to */ - void giveApplicableContext(@NonNull T target, @NonNull ContextConsumer consumer); + void calculate(@NonNull T target, @NonNull ContextConsumer consumer); } diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ContextConsumer.java b/api/src/main/java/me/lucko/luckperms/api/context/ContextConsumer.java index 83ce5c9fb..51cd717d4 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/ContextConsumer.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/ContextConsumer.java @@ -27,8 +27,6 @@ package me.lucko.luckperms.api.context; import org.checkerframework.checker.nullness.qual.NonNull; -import java.util.Map; - /** * Functional interface that accepts context key value pairs. */ @@ -43,14 +41,23 @@ public interface ContextConsumer { */ void accept(@NonNull String key, @NonNull String value); + /** + * Accepts a context pair. + * + * @param context the context + */ + default void accept(@NonNull Context context) { + accept(context.getKey(), context.getValue()); + } + /** * Accepts a context set. * * @param contextSet the context set */ default void accept(@NonNull ContextSet contextSet) { - for (Map.Entry entry : contextSet) { - accept(entry.getKey(), entry.getValue()); + for (Context entry : contextSet) { + accept(entry); } } diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java b/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java index 03d69b55b..02307c5c0 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/ContextSet.java @@ -57,7 +57,7 @@ import java.util.Set; * {@link MutableContextSet} allows the addition and removal of context keys * after construction, and {@link ImmutableContextSet} does not.

*/ -public interface ContextSet extends Iterable> { +public interface ContextSet extends Iterable { /** * Gets if this {@link ContextSet} is immutable. @@ -89,7 +89,7 @@ public interface ContextSet extends Iterable> { @NonNull MutableContextSet mutableCopy(); /** - * Returns a {@link Set} of {@link Map.Entry}s representing the current + * Returns a {@link Set} of {@link Context}s representing the current * state of this {@link ContextSet}. * *

The returned set is immutable, and is a copy of the current set. @@ -97,7 +97,7 @@ public interface ContextSet extends Iterable> { * * @return an immutable set */ - @NonNull Set> toSet(); + @NonNull Set toSet(); /** * Returns a {@link Map} representing the current state of this @@ -137,7 +137,7 @@ public interface ContextSet extends Iterable> { * @return an iterator */ @Override - @NonNull Iterator> iterator(); + @NonNull Iterator iterator(); /** * Returns if the {@link ContextSet} contains at least one value for the @@ -191,7 +191,7 @@ public interface ContextSet extends Iterable> { * @return true if the set contains the context pair * @throws NullPointerException if the key or value is null */ - default boolean contains(Map.@NonNull Entry entry) { + default boolean contains(@NonNull Context entry) { Objects.requireNonNull(entry, "entry"); return contains(entry.getKey(), entry.getValue()); } @@ -207,31 +207,7 @@ public interface ContextSet extends Iterable> { * @param other the other set to check * @return true if all entries in this set are also in the other set */ - default boolean isSatisfiedBy(@NonNull ContextSet other) { - if (this == other) { - return true; - } - - Objects.requireNonNull(other, "other"); - if (this.isEmpty()) { - // this is empty, so is therefore always satisfied. - return true; - } else if (other.isEmpty()) { - // this set isn't empty, but the other one is - return false; - } else if (this.size() > other.size()) { - // this set has more unique entries than the other set, so there's no way this can be satisfied. - return false; - } else { - // neither are empty, we need to compare the individual entries - for (Map.Entry context : toSet()) { - if (!other.contains(context)) { - return false; - } - } - return true; - } - } + boolean isSatisfiedBy(@NonNull ContextSet other); /** * Returns if the {@link ContextSet} is empty. diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ContextSetFactory.java b/api/src/main/java/me/lucko/luckperms/api/context/ContextSetFactory.java index b30a5cf91..88b40dc5b 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/ContextSetFactory.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/ContextSetFactory.java @@ -36,8 +36,6 @@ public interface ContextSetFactory { @NonNull ImmutableContextSet immutableOf(@NonNull String key, @NonNull String value); - @NonNull ImmutableContextSet immutableOf(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2); - @NonNull ImmutableContextSet immutableEmpty(); @NonNull MutableContextSet mutable(); diff --git a/api/src/main/java/me/lucko/luckperms/api/context/ImmutableContextSet.java b/api/src/main/java/me/lucko/luckperms/api/context/ImmutableContextSet.java index 35d8306a4..8ce282a5b 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/ImmutableContextSet.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/ImmutableContextSet.java @@ -29,9 +29,7 @@ import me.lucko.luckperms.api.LuckPermsProvider; import org.checkerframework.checker.nullness.qual.NonNull; -import java.util.Map; import java.util.Objects; -import java.util.Set; /** * An immutable implementation of {@link ContextSet}. @@ -47,6 +45,15 @@ public interface ImmutableContextSet extends ContextSet { return LuckPermsProvider.get().getContextManager().getContextSetFactory().immutableBuilder(); } + /** + * Returns an empty {@link ImmutableContextSet}. + * + * @return an empty ImmutableContextSet + */ + static @NonNull ImmutableContextSet empty() { + return LuckPermsProvider.get().getContextManager().getContextSetFactory().immutableEmpty(); + } + /** * Creates an {@link ImmutableContextSet} from a context pair. * @@ -59,58 +66,6 @@ public interface ImmutableContextSet extends ContextSet { return LuckPermsProvider.get().getContextManager().getContextSetFactory().immutableOf(key, value); } - /** - * Creates an {@link ImmutableContextSet} from two context pairs. - * - * @param key1 the first key - * @param value1 the first value - * @param key2 the second key - * @param value2 the second value - * @return a new ImmutableContextSet containing the two pairs - * @throws NullPointerException if any of the keys or values are null - */ - static @NonNull ImmutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) { - return LuckPermsProvider.get().getContextManager().getContextSetFactory().immutableOf(key1, value1, key2, value2); - } - - /** - * Creates an {@link ImmutableContextSet} from an existing {@link Iterable} of {@link Map.Entry}s. - * - * @param iterable the iterable to copy from - * @return a new ImmutableContextSet representing the pairs in the iterable - * @throws NullPointerException if the iterable is null - */ - static @NonNull ImmutableContextSet fromEntries(@NonNull Iterable> iterable) { - Objects.requireNonNull(iterable, "iterable"); - Builder builder = builder(); - for (Map.Entry entry : iterable) { - builder.add(entry); - } - return builder.build(); - } - - /** - * Creates an new {@link ImmutableContextSet} from an existing {@link Set}. - * - *

Only really useful for converting between mutable and immutable types.

- * - * @param contextSet the context set to copy from - * @return a new ImmutableContextSet with the same content and the one provided - * @throws NullPointerException if contextSet is null - */ - static @NonNull ImmutableContextSet fromSet(@NonNull ContextSet contextSet) { - return Objects.requireNonNull(contextSet, "contextSet").immutableCopy(); - } - - /** - * Returns an empty {@link ImmutableContextSet}. - * - * @return an empty ImmutableContextSet - */ - static @NonNull ImmutableContextSet empty() { - return LuckPermsProvider.get().getContextManager().getContextSetFactory().immutableEmpty(); - } - /** * @deprecated Already immutable! */ @@ -140,9 +95,9 @@ public interface ImmutableContextSet extends ContextSet { * @param entry the entry to add * @return the builder * @throws NullPointerException if the entry is null - * @see MutableContextSet#add(Map.Entry) + * @see MutableContextSet#add(Context) */ - default @NonNull Builder add(Map.@NonNull Entry entry) { + default @NonNull Builder add(@NonNull Context entry) { Objects.requireNonNull(entry, "entry"); add(entry.getKey(), entry.getValue()); return this; @@ -156,8 +111,8 @@ public interface ImmutableContextSet extends ContextSet { * @throws NullPointerException if iterable is null * @see MutableContextSet#addAll(Iterable) */ - default @NonNull Builder addAll(@NonNull Iterable> iterable) { - for (Map.Entry e : Objects.requireNonNull(iterable, "iterable")) { + default @NonNull Builder addAll(@NonNull Iterable iterable) { + for (Context e : Objects.requireNonNull(iterable, "iterable")) { add(e); } return this; diff --git a/api/src/main/java/me/lucko/luckperms/api/context/MutableContextSet.java b/api/src/main/java/me/lucko/luckperms/api/context/MutableContextSet.java index 851ee4b1d..b7caf90ad 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/MutableContextSet.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/MutableContextSet.java @@ -29,15 +29,22 @@ import me.lucko.luckperms.api.LuckPermsProvider; import org.checkerframework.checker.nullness.qual.NonNull; -import java.util.Map; import java.util.Objects; -import java.util.Set; /** * A mutable implementation of {@link ContextSet}. */ public interface MutableContextSet extends ContextSet { + /** + * Creates a new empty MutableContextSet. + * + * @return a new MutableContextSet + */ + static @NonNull MutableContextSet create() { + return LuckPermsProvider.get().getContextManager().getContextSetFactory().mutable(); + } + /** * Creates a {@link MutableContextSet} from a context pair. * @@ -54,63 +61,6 @@ public interface MutableContextSet extends ContextSet { return set; } - /** - * Creates a {@link MutableContextSet} from two context pairs. - * - * @param key1 the first key - * @param value1 the first value - * @param key2 the second key - * @param value2 the second value - * @return a new MutableContextSet containing the two pairs - * @throws NullPointerException if any of the keys or values are null - */ - static @NonNull MutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) { - Objects.requireNonNull(key1, "key1"); - Objects.requireNonNull(value1, "value1"); - Objects.requireNonNull(key2, "key2"); - Objects.requireNonNull(value2, "value2"); - MutableContextSet set = create(); - set.add(key1, value1); - set.add(key2, value2); - return set; - } - - /** - * Creates a {@link MutableContextSet} from an existing {@link Iterable} of {@link Map.Entry}s. - * - * @param iterable the iterable to copy from - * @return a new MutableContextSet representing the pairs in the iterable - * @throws NullPointerException if the iterable is null - */ - static @NonNull MutableContextSet fromEntries(@NonNull Iterable> iterable) { - Objects.requireNonNull(iterable, "iterable"); - MutableContextSet set = create(); - set.addAll(iterable); - return set; - } - - /** - * Creates a new {@link MutableContextSet} from an existing {@link Set}. - * - *

Only really useful for converting between mutable and immutable types.

- * - * @param contextSet the context set to copy from - * @return a new MutableContextSet with the same content and the one provided - * @throws NullPointerException if contextSet is null - */ - static @NonNull MutableContextSet fromSet(@NonNull ContextSet contextSet) { - return contextSet.mutableCopy(); - } - - /** - * Creates a new empty MutableContextSet. - * - * @return a new MutableContextSet - */ - static @NonNull MutableContextSet create() { - return LuckPermsProvider.get().getContextManager().getContextSetFactory().mutable(); - } - /** * Adds a context to this set. * @@ -126,7 +76,7 @@ public interface MutableContextSet extends ContextSet { * @param entry the entry to add * @throws NullPointerException if the entry is null */ - default void add(Map.@NonNull Entry entry) { + default void add(@NonNull Context entry) { Objects.requireNonNull(entry, "entry"); add(entry.getKey(), entry.getValue()); } @@ -137,8 +87,8 @@ public interface MutableContextSet extends ContextSet { * @param iterable an iterable of key value context pairs * @throws NullPointerException if iterable is null */ - default void addAll(@NonNull Iterable> iterable) { - for (Map.Entry e : Objects.requireNonNull(iterable, "iterable")) { + default void addAll(@NonNull Iterable iterable) { + for (Context e : Objects.requireNonNull(iterable, "iterable")) { add(e); } } diff --git a/api/src/main/java/me/lucko/luckperms/api/context/StaticContextCalculator.java b/api/src/main/java/me/lucko/luckperms/api/context/StaticContextCalculator.java index 53afa5246..418c76a27 100644 --- a/api/src/main/java/me/lucko/luckperms/api/context/StaticContextCalculator.java +++ b/api/src/main/java/me/lucko/luckperms/api/context/StaticContextCalculator.java @@ -66,10 +66,10 @@ public interface StaticContextCalculator extends ContextCalculator { * * @param consumer the {@link ContextConsumer} to submit contexts to */ - void giveApplicableContext(@NonNull ContextConsumer consumer); + void calculate(@NonNull ContextConsumer consumer); @Override - default void giveApplicableContext(@NonNull Object target, @NonNull ContextConsumer consumer) { - giveApplicableContext(consumer); + default void calculate(@NonNull Object target, @NonNull ContextConsumer consumer) { + calculate(consumer); } } diff --git a/build.gradle b/build.gradle index b09eba260..3797fa07f 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ subprojects { apply plugin: 'net.minecrell.licenser' group = 'me.lucko.luckperms' - version = '4.4-SNAPSHOT' + version = '5.0-SNAPSHOT' sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -44,8 +44,8 @@ subprojects { return tagInfo.split("-")[1] } - project.ext.majorVersion = '4' - project.ext.minorVersion = '4' + project.ext.majorVersion = '5' + project.ext.minorVersion = '0' project.ext.patchVersion = determinePatchVersion() project.ext.fullVersion = project.ext.majorVersion + '.' + project.ext.minorVersion + '.' + project.ext.patchVersion diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/WorldCalculator.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/WorldCalculator.java index 27e5e1bce..9cab956dc 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/WorldCalculator.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/WorldCalculator.java @@ -45,7 +45,7 @@ public class WorldCalculator implements ContextCalculator { } @Override - public void giveApplicableContext(@NonNull Player subject, @NonNull ContextConsumer consumer) { + public void calculate(@NonNull Player subject, @NonNull ContextConsumer consumer) { Set seen = new HashSet<>(); String world = subject.getWorld().getName().toLowerCase(); while (seen.add(world)) { diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java index 1e97ed716..2aa12486b 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java @@ -453,7 +453,7 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission { logMsg("#holderRemovePermission: %s - %s - %s", holder.getPlainDisplayName(), permission, world); } - if (((Result) holder.unsetPermission(DataType.NORMAL, NodeFactory.make(permission, getVaultServer(), world))).wasSuccessful()) { + if (holder.unsetPermission(DataType.NORMAL, NodeFactory.builder(permission).withContext(DefaultContextKeys.SERVER_KEY, getVaultServer()).withContext(DefaultContextKeys.WORLD_KEY, world).build()).wasSuccessful()) { return holderSave(holder); } return false; diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/context/BackendServerCalculator.java b/bungee/src/main/java/me/lucko/luckperms/bungee/context/BackendServerCalculator.java index b6b48b93a..32fc63903 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/context/BackendServerCalculator.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/context/BackendServerCalculator.java @@ -51,7 +51,7 @@ public class BackendServerCalculator implements ContextCalculator } @Override - public void giveApplicableContext(@NonNull ProxiedPlayer subject, @NonNull ContextConsumer consumer) { + public void calculate(@NonNull ProxiedPlayer subject, @NonNull ContextConsumer consumer) { Set seen = new HashSet<>(); String server = getServer(subject); while (server != null && seen.add(server)) { diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/context/RedisBungeeCalculator.java b/bungee/src/main/java/me/lucko/luckperms/bungee/context/RedisBungeeCalculator.java index f61130695..b5f6710b2 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/context/RedisBungeeCalculator.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/context/RedisBungeeCalculator.java @@ -37,7 +37,7 @@ public class RedisBungeeCalculator implements StaticContextCalculator { private static final String PROXY_KEY = "proxy"; @Override - public void giveApplicableContext(@NonNull ContextConsumer consumer) { + public void calculate(@NonNull ContextConsumer consumer) { RedisBungeeAPI redisBungee = RedisBungee.getApi(); if (redisBungee != null) { consumer.accept(PROXY_KEY, redisBungee.getServerId()); diff --git a/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java deleted file mode 100644 index 65fd73955..000000000 --- a/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java +++ /dev/null @@ -1,330 +0,0 @@ -/* - * This file is part of LuckPerms, licensed under the MIT License. - * - * Copyright (c) lucko (Luck) - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.actionlog; - -import com.google.common.base.Strings; - -import me.lucko.luckperms.api.actionlog.Action; -import me.lucko.luckperms.api.context.ContextSet; -import me.lucko.luckperms.api.context.DefaultContextKeys; -import me.lucko.luckperms.common.model.Group; -import me.lucko.luckperms.common.model.HolderType; -import me.lucko.luckperms.common.model.PermissionHolder; -import me.lucko.luckperms.common.model.Track; -import me.lucko.luckperms.common.model.User; -import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import me.lucko.luckperms.common.sender.Sender; - -import org.checkerframework.checker.nullness.qual.NonNull; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; - -/** - * An implementation of {@link Action} and {@link Action.Builder}, - * with helper methods for populating and using the entry using internal - * LuckPerms classes. - */ -public class ExtendedLogEntry implements Action { - - private static final Comparator COMPARATOR = Comparator - .comparingLong(Action::getTimestamp) - .thenComparing(Action::getActor) - .thenComparing(Action::getActorName, String.CASE_INSENSITIVE_ORDER) - .thenComparing(Action::getType) - .thenComparing(e -> e.getActed().map(UUID::toString).orElse("")) - .thenComparing(Action::getActedName, String.CASE_INSENSITIVE_ORDER) - .thenComparing(Action::getAction); - - /** - * Creates a new log entry builder - * - * @return a new builder - */ - public static Builder build() { - return new Builder(); - } - - private final long timestamp; - private final UUID actor; - private final String actorName; - private final Type type; - private final UUID acted; - private final String actedName; - private final String action; - - private ExtendedLogEntry(long timestamp, UUID actor, String actorName, Type type, UUID acted, String actedName, String action) { - this.timestamp = timestamp; - this.actor = actor; - this.actorName = actorName; - this.type = type; - this.acted = acted; - this.actedName = actedName; - this.action = action; - } - - @Override - public long getTimestamp() { - return this.timestamp; - } - - @Override - public @NonNull UUID getActor() { - return this.actor; - } - - @Override - public @NonNull String getActorName() { - return this.actorName; - } - - public String getActorFriendlyString() { - if (Strings.isNullOrEmpty(this.actorName) || this.actorName.equals("null")) { - return this.actor.toString(); - } - return this.actorName; - } - - @Override - public @NonNull Type getType() { - return this.type; - } - - @Override - public @NonNull Optional getActed() { - return Optional.ofNullable(this.acted); - } - - @Override - public @NonNull String getActedName() { - return this.actedName; - } - - public String getActedFriendlyString() { - if (Strings.isNullOrEmpty(this.actedName) || this.actedName.equals("null")) { - if (this.acted != null) { - return this.acted.toString(); - } - } - return String.valueOf(this.actedName); - } - - @Override - public @NonNull String getAction() { - return this.action; - } - - @Override - public int compareTo(@NonNull Action other) { - Objects.requireNonNull(other, "other"); - return COMPARATOR.compare(this, other); - } - - public boolean matchesSearch(String query) { - query = Objects.requireNonNull(query, "query").toLowerCase(); - return this.actorName.toLowerCase().contains(query) || - this.actedName.toLowerCase().contains(query) || - this.action.toLowerCase().contains(query); - } - - public void submit(LuckPermsPlugin plugin, Sender sender) { - plugin.getLogDispatcher().dispatch(this, sender); - } - - @Override - public String toString() { - return "LogEntry(" + - "timestamp=" + this.getTimestamp() + ", " + - "actor=" + this.getActor() + ", " + - "actorName=" + this.getActorName() + ", " + - "type=" + this.getType() + ", " + - "acted=" + this.getActed() + ", " + - "actedName=" + this.getActedName() + ", " + - "action=" + this.getAction() + ")"; - } - - @Override - public boolean equals(Object o) { - if (o == this) return true; - if (!(o instanceof Action)) return false; - final Action that = (Action) o; - - return this.getTimestamp() == that.getTimestamp() && - this.getActor().equals(that.getActor()) && - this.getActorName().equals(that.getActorName()) && - this.getType() == that.getType() && - this.getActed().equals(that.getActed()) && - this.getActedName().equals(that.getActedName()) && - this.getAction().equals(that.getAction()); - } - - @Override - public int hashCode() { - final int PRIME = 59; - int result = 1; - result = result * PRIME + (int) (this.getTimestamp() >>> 32 ^ this.getTimestamp()); - result = result * PRIME + this.getActor().hashCode(); - result = result * PRIME + this.getActorName().hashCode(); - result = result * PRIME + this.getType().hashCode(); - result = result * PRIME + this.getActed().hashCode(); - result = result * PRIME + this.getActedName().hashCode(); - result = result * PRIME + this.getAction().hashCode(); - return result; - } - - public static class Builder implements Action.Builder { - - private long timestamp = 0L; - private UUID actor = null; - private String actorName = null; - private Type type = null; - private UUID acted = null; - private String actedName = null; - private String action = null; - - public @NonNull Builder timestamp(long timestamp) { - this.timestamp = timestamp; - return this; - } - - public @NonNull Builder actor(@NonNull UUID actor) { - this.actor = Objects.requireNonNull(actor, "actor"); - return this; - } - - public @NonNull Builder actorName(@NonNull String actorName) { - this.actorName = Objects.requireNonNull(actorName, "actorName"); - return this; - } - - public @NonNull Builder type(@NonNull Type type) { - this.type = Objects.requireNonNull(type, "type"); - return this; - } - - public @NonNull Builder acted(UUID acted) { - this.acted = acted; // nullable - return this; - } - - public @NonNull Builder actedName(@NonNull String actedName) { - this.actedName = Objects.requireNonNull(actedName, "actedName"); - return this; - } - - public @NonNull Builder action(@NonNull String action) { - this.action = Objects.requireNonNull(action, "action"); - return this; - } - - public Builder actor(Sender actor) { - actorName(actor.getNameWithLocation()); - actor(actor.getUuid()); - return this; - } - - public Builder acted(PermissionHolder acted) { - if (acted.getType() == HolderType.USER) { - actedName(((User) acted).getName().orElse("null")); - acted(((User) acted).getUuid()); - type(Type.USER); - } else if (acted.getType() == HolderType.GROUP) { - actedName(((Group) acted).getName()); - type(Type.GROUP); - } - return this; - } - - public Builder acted(Track track) { - actedName(track.getName()); - type(Type.TRACK); - return this; - } - - public Builder action(Object... args) { - List parts = new ArrayList<>(); - - for (Object o : args) { - - // special formatting for ContextSets instead of just #toString - if (o instanceof ContextSet) { - ContextSet set = (ContextSet) o; - - for (String value : set.getValues(DefaultContextKeys.SERVER_KEY)) { - parts.add("server=" + value); - } - for (String value : set.getValues(DefaultContextKeys.WORLD_KEY)) { - parts.add("world=" + value); - } - - for (Map.Entry context : set.toSet()) { - if (context.getKey().equals(DefaultContextKeys.SERVER_KEY) || context.getKey().equals(DefaultContextKeys.WORLD_KEY)) { - continue; - } - parts.add(context.getKey() + "=" + context.getValue()); - } - } else { - parts.add(String.valueOf(o)); - } - } - - action(String.join(" ", parts)); - return this; - } - - @Override - public @NonNull ExtendedLogEntry build() { - if (this.timestamp == 0L) { - timestamp(System.currentTimeMillis() / 1000L); - } - - Objects.requireNonNull(this.actor, "actor"); - Objects.requireNonNull(this.actorName, "actorName"); - Objects.requireNonNull(this.type, "type"); - Objects.requireNonNull(this.actedName, "actedName"); - Objects.requireNonNull(this.action, "action"); - - return new ExtendedLogEntry(this.timestamp, this.actor, this.actorName, this.type, this.acted, this.actedName, this.action); - } - - @Override - public String toString() { - return "ExtendedLogEntry.Builder(" + - "timestamp=" + this.timestamp + ", " + - "actor=" + this.actor + ", " + - "actorName=" + this.actorName + ", " + - "type=" + this.type + ", " + - "acted=" + this.acted + ", " + - "actedName=" + this.actedName + ", " + - "action=" + this.action + ")"; - } - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/actionlog/Log.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/Log.java index da7244655..e3952d040 100644 --- a/common/src/main/java/me/lucko/luckperms/common/actionlog/Log.java +++ b/common/src/main/java/me/lucko/luckperms/common/actionlog/Log.java @@ -50,53 +50,53 @@ public class Log { return empty; } - private final SortedSet content; + private final SortedSet content; - public Log(SortedSet content) { + public Log(SortedSet content) { this.content = ImmutableSortedSet.copyOfSorted(content); } - public SortedSet getContent() { + public SortedSet getContent() { return this.content; } - public SortedSet getContent(UUID actor) { + public SortedSet getContent(UUID actor) { return this.content.stream() - .filter(e -> e.getActor().equals(actor)) + .filter(e -> e.getSource().getUniqueId().equals(actor)) .collect(Collectors.toCollection(TreeSet::new)); } - public SortedSet getUserHistory(UUID uuid) { + public SortedSet getUserHistory(UUID uuid) { return this.content.stream() - .filter(e -> e.getType() == Action.Type.USER) - .filter(e -> e.getActed().isPresent() && e.getActed().get().equals(uuid)) + .filter(e -> e.getTarget().getType() == Action.Target.Type.USER) + .filter(e -> e.getTarget().getUniqueId().isPresent() && e.getTarget().getUniqueId().get().equals(uuid)) .collect(ImmutableCollectors.toSortedSet(Comparator.naturalOrder())); } - public SortedSet getGroupHistory(String name) { + public SortedSet getGroupHistory(String name) { return this.content.stream() - .filter(e -> e.getType() == Action.Type.GROUP) - .filter(e -> e.getActedName().equals(name)) + .filter(e -> e.getTarget().getType() == Action.Target.Type.GROUP) + .filter(e -> e.getTarget().getName().equals(name)) .collect(ImmutableCollectors.toSortedSet(Comparator.naturalOrder())); } - public SortedSet getTrackHistory(String name) { + public SortedSet getTrackHistory(String name) { return this.content.stream() - .filter(e -> e.getType() == Action.Type.TRACK) - .filter(e -> e.getActedName().equals(name)) + .filter(e -> e.getTarget().getType() == Action.Target.Type.TRACK) + .filter(e -> e.getTarget().getName().equals(name)) .collect(ImmutableCollectors.toSortedSet(Comparator.naturalOrder())); } - public SortedSet getSearch(String query) { + public SortedSet getSearch(String query) { return this.content.stream() .filter(e -> e.matchesSearch(query)) .collect(ImmutableCollectors.toSortedSet(Comparator.naturalOrder())); } public static class Builder { - private final SortedSet content = new TreeSet<>(); + private final SortedSet content = new TreeSet<>(); - public Builder add(ExtendedLogEntry e) { + public Builder add(LoggedAction e) { this.content.add(e); return this; } diff --git a/common/src/main/java/me/lucko/luckperms/common/actionlog/LogDispatcher.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/LogDispatcher.java index 105f91c56..979fffd3e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/actionlog/LogDispatcher.java +++ b/common/src/main/java/me/lucko/luckperms/common/actionlog/LogDispatcher.java @@ -44,7 +44,7 @@ public class LogDispatcher { this.plugin = plugin; } - private void broadcast(ExtendedLogEntry entry, LogNotifyEvent.Origin origin, Sender sender) { + private void broadcast(LoggedAction entry, LogNotifyEvent.Origin origin, Sender sender) { this.plugin.getOnlineSenders() .filter(CommandPermission.LOG_NOTIFY::isAuthorized) .filter(s -> { @@ -52,14 +52,14 @@ public class LogDispatcher { return !this.plugin.getEventFactory().handleLogNotify(shouldCancel, entry, origin, s); }) .forEach(s -> Message.LOG.send(s, - entry.getActorFriendlyString(), - Character.toString(entry.getType().getCode()), - entry.getActedFriendlyString(), - entry.getAction() + entry.getSourceFriendlyString(), + Character.toString(LoggedAction.getTypeCharacter(entry.getTarget().getType())), + entry.getTargetFriendlyString(), + entry.getDescription() )); } - public void dispatch(ExtendedLogEntry entry, Sender sender) { + public void dispatch(LoggedAction entry, Sender sender) { // set the event to cancelled if the sender is import if (!this.plugin.getEventFactory().handleLogPublish(sender.isImport(), entry)) { this.plugin.getStorage().logAction(entry); @@ -81,7 +81,7 @@ public class LogDispatcher { } } - public void dispatchFromApi(ExtendedLogEntry entry) { + public void dispatchFromApi(LoggedAction entry) { if (!this.plugin.getEventFactory().handleLogPublish(false, entry)) { try { this.plugin.getStorage().logAction(entry).get(); @@ -93,7 +93,7 @@ public class LogDispatcher { broadcastFromApi(entry); } - public void broadcastFromApi(ExtendedLogEntry entry) { + public void broadcastFromApi(LoggedAction entry) { this.plugin.getMessagingService().ifPresent(extendedMessagingService -> extendedMessagingService.pushLog(entry)); boolean shouldCancel = !this.plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY); @@ -102,7 +102,7 @@ public class LogDispatcher { } } - public void dispatchFromRemote(ExtendedLogEntry entry) { + public void dispatchFromRemote(LoggedAction entry) { boolean shouldCancel = !this.plugin.getConfiguration().get(ConfigKeys.BROADCAST_RECEIVED_LOG_ENTRIES) || !this.plugin.getConfiguration().get(ConfigKeys.LOG_NOTIFY); if (!this.plugin.getEventFactory().handleLogBroadcast(shouldCancel, entry, LogBroadcastEvent.Origin.REMOTE)) { broadcast(entry, LogNotifyEvent.Origin.REMOTE, null); diff --git a/common/src/main/java/me/lucko/luckperms/common/actionlog/LogEntryJsonSerializer.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/LogEntryJsonSerializer.java index 36a02267b..b376fec01 100644 --- a/common/src/main/java/me/lucko/luckperms/common/actionlog/LogEntryJsonSerializer.java +++ b/common/src/main/java/me/lucko/luckperms/common/actionlog/LogEntryJsonSerializer.java @@ -32,6 +32,7 @@ import com.google.gson.JsonPrimitive; import me.lucko.luckperms.api.actionlog.Action; +import java.time.Instant; import java.util.UUID; public final class LogEntryJsonSerializer { @@ -39,32 +40,37 @@ public final class LogEntryJsonSerializer { public static JsonObject serialize(Action logEntry) { JsonObject data = new JsonObject(); - data.add("actor", new JsonPrimitive(logEntry.getActor().toString())); - data.add("actorName", new JsonPrimitive(logEntry.getActorName())); - data.add("type", new JsonPrimitive(logEntry.getType().name())); - if (logEntry.getActed().isPresent()) { - data.add("acted", new JsonPrimitive(logEntry.getActed().get().toString())); + data.add("timestamp", new JsonPrimitive(logEntry.getTimestamp().getEpochSecond())); + data.add("actor", new JsonPrimitive(logEntry.getSource().getUniqueId().toString())); + data.add("actorName", new JsonPrimitive(logEntry.getSource().getName())); + data.add("type", new JsonPrimitive(logEntry.getTarget().getType().name())); + if (logEntry.getTarget().getUniqueId().isPresent()) { + data.add("acted", new JsonPrimitive(logEntry.getTarget().getUniqueId().get().toString())); } - data.add("actedName", new JsonPrimitive(logEntry.getActedName())); - data.add("action", new JsonPrimitive(logEntry.getAction())); + data.add("actedName", new JsonPrimitive(logEntry.getTarget().getName())); + data.add("action", new JsonPrimitive(logEntry.getDescription())); return data; } - public static ExtendedLogEntry deserialize(JsonElement element) { + public static LoggedAction deserialize(JsonElement element) { Preconditions.checkArgument(element.isJsonObject()); JsonObject data = element.getAsJsonObject(); - ExtendedLogEntry.Builder builder = ExtendedLogEntry.build(); + LoggedAction.Builder builder = LoggedAction.build(); - builder.actor(UUID.fromString(data.get("actor").getAsString())); - builder.actorName(data.get("actorName").getAsString()); - builder.type(Action.Type.parse(data.get("type").getAsString())); - if (data.has("acted")) { - builder.actor(UUID.fromString(data.get("acted").getAsString())); + if (data.has("timestamp")) { // sigh - this wasn't included in the first implementations + builder.timestamp(Instant.ofEpochSecond(data.get("timestamp").getAsLong())); } - builder.actedName(data.get("actedName").getAsString()); - builder.action(data.get("action").getAsString()); + + builder.source(UUID.fromString(data.get("actor").getAsString())); + builder.sourceName(data.get("actorName").getAsString()); + builder.targetType(LoggedAction.parseType(data.get("type").getAsString())); + if (data.has("acted")) { + builder.source(UUID.fromString(data.get("acted").getAsString())); + } + builder.targetName(data.get("actedName").getAsString()); + builder.description(data.get("action").getAsString()); return builder.build(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/actionlog/LoggedAction.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/LoggedAction.java new file mode 100644 index 000000000..5bb5fcc8b --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/actionlog/LoggedAction.java @@ -0,0 +1,413 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.luckperms.common.actionlog; + +import com.google.common.base.Strings; + +import me.lucko.luckperms.api.actionlog.Action; +import me.lucko.luckperms.api.context.Context; +import me.lucko.luckperms.api.context.ContextSet; +import me.lucko.luckperms.api.context.DefaultContextKeys; +import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; +import me.lucko.luckperms.common.model.PermissionHolder; +import me.lucko.luckperms.common.model.Track; +import me.lucko.luckperms.common.model.User; +import me.lucko.luckperms.common.plugin.LuckPermsPlugin; +import me.lucko.luckperms.common.sender.Sender; + +import org.checkerframework.checker.nullness.qual.NonNull; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * An implementation of {@link Action} and {@link Action.Builder}, + * with helper methods for populating and using the entry using internal + * LuckPerms classes. + */ +public class LoggedAction implements Action { + + private static final Comparator COMPARATOR = Comparator + .comparingLong(a -> a.getTimestamp().getEpochSecond()) + .thenComparing(a -> a.getSource().getUniqueId()) + .thenComparing(a -> a.getSource().getName(), String.CASE_INSENSITIVE_ORDER) + .thenComparing(a -> a.getTarget().getType()) + .thenComparing(e -> e.getTarget().getUniqueId().map(UUID::toString).orElse("")) + .thenComparing(a -> a.getTarget().getName(), String.CASE_INSENSITIVE_ORDER) + .thenComparing(Action::getDescription); + + /** + * Creates a new log entry builder + * + * @return a new builder + */ + public static Builder build() { + return new Builder(); + } + + private final long timestamp; + private final SourceImpl source; + private final TargetImpl target; + private final String action; + + private LoggedAction(long timestamp, UUID sourceUniqueId, String sourceName, Target.Type targetType, UUID targetUniqueId, String targetName, String description) { + this.timestamp = timestamp; + this.source = new SourceImpl(sourceUniqueId, sourceName); + this.target = new TargetImpl(targetUniqueId, targetName, targetType); + this.action = description; + } + + @NonNull + @Override + public Instant getTimestamp() { + return Instant.ofEpochSecond(this.timestamp); + } + + @NonNull + @Override + public Source getSource() { + return this.source; + } + + @NonNull + @Override + public Target getTarget() { + return this.target; + } + + public String getSourceFriendlyString() { + if (Strings.isNullOrEmpty(this.source.name) || this.source.name.equals("null")) { + return this.source.uniqueId.toString(); + } + return this.source.name; + } + + public String getTargetFriendlyString() { + if (Strings.isNullOrEmpty(this.target.name) || this.target.name.equals("null")) { + if (this.target.uniqueId != null) { + return this.target.uniqueId.toString(); + } + } + return String.valueOf(this.target.name); + } + + @Override + public @NonNull String getDescription() { + return this.action; + } + + @Override + public int compareTo(@NonNull Action other) { + Objects.requireNonNull(other, "other"); + return COMPARATOR.compare(this, other); + } + + public boolean matchesSearch(String query) { + query = Objects.requireNonNull(query, "query").toLowerCase(); + return this.source.name.toLowerCase().contains(query) || + this.target.name.toLowerCase().contains(query) || + this.action.toLowerCase().contains(query); + } + + public void submit(LuckPermsPlugin plugin, Sender sender) { + plugin.getLogDispatcher().dispatch(this, sender); + } + + @Override + public String toString() { + return "LoggedAction(" + + "timestamp=" + this.getTimestamp() + ", " + + "source=" + getSource().getUniqueId() + ", " + + "sourceName=" + getSource().getName() + ", " + + "target=" + getTarget().getUniqueId() + ", " + + "targetName=" + getTarget().getName() + ", " + + "targetType=" + getTarget().getType() + ", " + + "description=" + this.getDescription() + ")"; + } + + @Override + public boolean equals(Object o) { + if (o == this) return true; + if (!(o instanceof Action)) return false; + final Action that = (Action) o; + + return getTimestamp() == that.getTimestamp() && + getSource().equals(that.getSource()) && + getTarget().equals(that.getTarget()) && + getDescription().equals(that.getDescription()); + } + + @Override + public int hashCode() { + final int PRIME = 59; + int result = 1; + result = result * PRIME + getTimestamp().hashCode(); + result = result * PRIME + getSource().hashCode(); + result = result * PRIME + getTarget().hashCode(); + result = result * PRIME + getDescription().hashCode(); + return result; + } + + private static final class SourceImpl implements Source { + private final UUID uniqueId; + private final String name; + + private SourceImpl(UUID uniqueId, String name) { + this.uniqueId = uniqueId; + this.name = name; + } + + @Override + public @NonNull UUID getUniqueId() { + return this.uniqueId; + } + + @Override + public @NonNull String getName() { + return this.name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SourceImpl source = (SourceImpl) o; + return this.uniqueId.equals(source.uniqueId) && + this.name.equals(source.name); + } + + @Override + public int hashCode() { + return Objects.hash(this.uniqueId, this.name); + } + } + + private static final class TargetImpl implements Target { + private final UUID uniqueId; + private final String name; + private final Type type; + + private TargetImpl(UUID uniqueId, String name, Type type) { + this.uniqueId = uniqueId; + this.name = name; + this.type = type; + } + + @Override + public @NonNull Optional getUniqueId() { + return Optional.ofNullable(this.uniqueId); + } + + @Override + public @NonNull String getName() { + return this.name; + } + + @Override + public @NonNull Type getType() { + return this.type; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TargetImpl target = (TargetImpl) o; + return Objects.equals(this.uniqueId, target.uniqueId) && + this.name.equals(target.name) && + this.type == target.type; + } + + @Override + public int hashCode() { + return Objects.hash(this.uniqueId, this.name, this.type); + } + } + + public static class Builder implements Action.Builder { + private long timestamp = 0L; + private UUID sourceUniqueId = null; + private String sourceName = null; + private UUID targetUniqueId = null; + private String targetName = null; + private Target.Type targetType = null; + private String description = null; + + public @NonNull Builder timestamp(@NonNull Instant timestamp) { + this.timestamp = timestamp.getEpochSecond(); + return this; + } + + public @NonNull Builder source(@NonNull UUID source) { + this.sourceUniqueId = Objects.requireNonNull(source, "source"); + return this; + } + + public @NonNull Builder sourceName(@NonNull String sourceName) { + this.sourceName = Objects.requireNonNull(sourceName, "sourceName"); + return this; + } + + public @NonNull Builder targetType(Action.Target.Type type) { + this.targetType = Objects.requireNonNull(type, "type"); + return this; + } + + public @NonNull Builder target(UUID target) { + this.targetUniqueId = target; // nullable + return this; + } + + public @NonNull Builder targetName(@NonNull String targetName) { + this.targetName = Objects.requireNonNull(targetName, "targetName"); + return this; + } + + public @NonNull Builder description(@NonNull String description) { + this.description = Objects.requireNonNull(description, "description"); + return this; + } + + public Builder source(Sender source) { + sourceName(source.getNameWithLocation()); + source(source.getUuid()); + return this; + } + + public Builder target(PermissionHolder target) { + if (target.getType() == HolderType.USER) { + targetName(((User) target).getName().orElse("null")); + target(((User) target).getUuid()); + targetType(Target.Type.USER); + } else if (target.getType() == HolderType.GROUP) { + targetName(((Group) target).getName()); + targetType(Target.Type.GROUP); + } + return this; + } + + public Builder target(Track track) { + targetName(track.getName()); + targetType(Target.Type.TRACK); + return this; + } + + public Builder description(Object... args) { + List parts = new ArrayList<>(); + + for (Object o : args) { + + // special formatting for ContextSets instead of just #toString + if (o instanceof ContextSet) { + ContextSet set = (ContextSet) o; + + for (String value : set.getValues(DefaultContextKeys.SERVER_KEY)) { + parts.add("server=" + value); + } + for (String value : set.getValues(DefaultContextKeys.WORLD_KEY)) { + parts.add("world=" + value); + } + + for (Context context : set) { + if (context.getKey().equals(DefaultContextKeys.SERVER_KEY) || context.getKey().equals(DefaultContextKeys.WORLD_KEY)) { + continue; + } + parts.add(context.getKey() + "=" + context.getValue()); + } + } else { + parts.add(String.valueOf(o)); + } + } + + description(String.join(" ", parts)); + return this; + } + + @Override + public @NonNull LoggedAction build() { + if (this.timestamp == 0L) { + timestamp(Instant.now()); + } + + Objects.requireNonNull(this.sourceUniqueId, "sourceUniqueId"); + Objects.requireNonNull(this.sourceName, "sourceName"); + Objects.requireNonNull(this.targetType, "targetType"); + Objects.requireNonNull(this.targetName, "targetName"); + Objects.requireNonNull(this.description, "description"); + + return new LoggedAction(this.timestamp, this.sourceUniqueId, this.sourceName, this.targetType, this.targetUniqueId, this.targetName, this.description); + } + } + + public static Target.@NonNull Type parseType(String type) { + try { + return Target.Type.valueOf(type); + } catch (IllegalArgumentException e) { + // ignore + } + try { + return parseTypeCharacter(type.charAt(0)); + } catch (IllegalArgumentException e) { + // ignore + } + throw new IllegalArgumentException("Unknown type: " + type); + } + + public static Target.@NonNull Type parseTypeCharacter(char code) { + switch (code) { + case 'U': + case 'u': + return Target.Type.USER; + case 'G': + case 'g': + return Target.Type.GROUP; + case 'T': + case 't': + return Target.Type.TRACK; + default: + throw new IllegalArgumentException("Unknown code: " + code); + } + } + + public static char getTypeCharacter(Target.Type type) { + switch (type) { + case USER: + return 'U'; + case GROUP: + return 'G'; + case TRACK: + return 'T'; + default: + throw new AssertionError(); + } + } +} diff --git a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiActionLogger.java b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiActionLogger.java index 6a0ad1f7c..2072c94c8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiActionLogger.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiActionLogger.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.api.implementation; import me.lucko.luckperms.api.actionlog.Action; import me.lucko.luckperms.api.actionlog.ActionLog; import me.lucko.luckperms.api.actionlog.ActionLogger; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import org.checkerframework.checker.nullness.qual.NonNull; @@ -44,7 +44,7 @@ public class ApiActionLogger implements ActionLogger { @Override public Action.@NonNull Builder actionBuilder() { - return ExtendedLogEntry.build(); + return LoggedAction.build(); } @Override @@ -54,7 +54,7 @@ public class ApiActionLogger implements ActionLogger { @Override public @NonNull CompletableFuture submit(@NonNull Action entry) { - return CompletableFuture.runAsync(() -> this.plugin.getLogDispatcher().dispatchFromApi((ExtendedLogEntry) entry), this.plugin.getBootstrap().getScheduler().async()); + return CompletableFuture.runAsync(() -> this.plugin.getLogDispatcher().dispatchFromApi((LoggedAction) entry), this.plugin.getBootstrap().getScheduler().async()); } @Override @@ -64,6 +64,6 @@ public class ApiActionLogger implements ActionLogger { @Override public @NonNull CompletableFuture broadcastAction(@NonNull Action entry) { - return CompletableFuture.runAsync(() -> this.plugin.getLogDispatcher().broadcastFromApi((ExtendedLogEntry) entry), this.plugin.getBootstrap().getScheduler().async()); + return CompletableFuture.runAsync(() -> this.plugin.getLogDispatcher().broadcastFromApi((LoggedAction) entry), this.plugin.getBootstrap().getScheduler().async()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextSetFactory.java b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextSetFactory.java index 2b76e2996..963567fa4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextSetFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextSetFactory.java @@ -50,11 +50,6 @@ public class ApiContextSetFactory implements ContextSetFactory { return ImmutableContextSetImpl.of(key, value); } - @Override - public @NonNull ImmutableContextSet immutableOf(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2) { - return ImmutableContextSetImpl.of(key1, value1, key2, value2); - } - @Override public @NonNull ImmutableContextSet immutableEmpty() { return ImmutableContextSetImpl.EMPTY; diff --git a/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java b/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java index 36a00578c..72832afa3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java @@ -25,6 +25,7 @@ package me.lucko.luckperms.common.command.access; +import me.lucko.luckperms.api.context.Context; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.node.Tristate; import me.lucko.luckperms.api.query.QueryOptions; @@ -42,7 +43,6 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent; -import java.util.Map; import java.util.function.BiFunction; import java.util.function.Function; @@ -246,7 +246,7 @@ public final class ArgumentPermissions { } } - for (Map.Entry context : contextSet.toSet()) { + for (Context context : contextSet) { Tristate ret = sender.getPermissionValue(base.getPermission() + ".usecontext." + context.getKey() + "." + context.getValue()); if (ret != Tristate.UNDEFINED) { if (ret == Tristate.FALSE) { diff --git a/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java index bf9a3e92e..62dfa0e87 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/MessageUtils.java @@ -25,6 +25,7 @@ package me.lucko.luckperms.common.command.utils; +import me.lucko.luckperms.api.context.Context; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.node.Node; import me.lucko.luckperms.api.node.Tristate; @@ -33,7 +34,6 @@ import me.lucko.luckperms.common.locale.message.Message; import java.util.Collection; import java.util.List; -import java.util.Map; public final class MessageUtils { private MessageUtils() {} @@ -124,7 +124,7 @@ public final class MessageUtils { */ public static String getAppendableNodeContextString(LocaleManager localeManager, Node node) { StringBuilder sb = new StringBuilder(); - for (Map.Entry c : node.getContexts().toSet()) { + for (Context c : node.getContexts()) { sb.append(" ").append(contextToString(localeManager, c.getKey(), c.getValue())); } return sb.toString(); @@ -150,7 +150,7 @@ public final class MessageUtils { StringBuilder sb = new StringBuilder(); - for (Map.Entry e : set.toSet()) { + for (Context e : set) { sb.append(Message.CONTEXT_PAIR_INLINE.asString(localeManager, e.getKey(), e.getValue())); sb.append(Message.CONTEXT_PAIR_SEP.asString(localeManager)); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddChatMeta.java index 4fd33caa3..72f053e16 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddChatMeta.java @@ -29,7 +29,7 @@ import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.model.DataMutateResult; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.ChatMetaType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -94,8 +94,8 @@ public class MetaAddChatMeta extends SharedSubCommand { builder.applyDeep(c -> c.hoverEvent(event)); sender.sendMessage(builder.build()); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta" , "add" + this.type.name().toLowerCase(), priority, meta, context) + LoggedAction.build().source(sender).target(holder) + .description("meta" , "add" + this.type.name().toLowerCase(), priority, meta, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempChatMeta.java index 36dc5cdb2..a9ee9bbec 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempChatMeta.java @@ -31,7 +31,7 @@ import me.lucko.luckperms.api.model.TemporaryDataMutateResult; import me.lucko.luckperms.api.model.TemporaryMergeBehaviour; import me.lucko.luckperms.api.node.ChatMetaType; import me.lucko.luckperms.api.util.Result; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -103,8 +103,8 @@ public class MetaAddTempChatMeta extends SharedSubCommand { builder.applyDeep(c -> c.hoverEvent(event)); sender.sendMessage(builder.build()); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta" , "addtemp" + this.type.name().toLowerCase(), priority, meta, duration, context) + LoggedAction.build().source(sender).target(holder) + .description("meta" , "addtemp" + this.type.name().toLowerCase(), priority, meta, duration, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java index fa89e9612..250dcffcc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.NodeType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -111,8 +111,8 @@ public class MetaClear extends SharedSubCommand { Message.META_CLEAR_SUCCESS.send(sender, holder.getFormattedDisplayName(), type.name().toLowerCase(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); } - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta", "clear", context) + LoggedAction.build().source(sender).target(holder) + .description("meta", "clear", context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java index b2d21ea4b..638c7472b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveChatMeta.java @@ -29,7 +29,7 @@ import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.api.model.DataMutateResult; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.ChatMetaType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -92,8 +92,8 @@ public class MetaRemoveChatMeta extends SharedSubCommand { n.getContexts().equals(context), null); Message.BULK_REMOVE_CHATMETA_SUCCESS.send(sender, holder.getFormattedDisplayName(), this.type.name().toLowerCase(), priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta" , "remove" + this.type.name().toLowerCase(), priority, "*", context) + LoggedAction.build().source(sender).target(holder) + .description("meta" , "remove" + this.type.name().toLowerCase(), priority, "*", context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); @@ -111,8 +111,8 @@ public class MetaRemoveChatMeta extends SharedSubCommand { builder.applyDeep(c -> c.hoverEvent(event)); sender.sendMessage(builder.build()); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta" , "remove" + this.type.name().toLowerCase(), priority, meta, context) + LoggedAction.build().source(sender).target(holder) + .description("meta" , "remove" + this.type.name().toLowerCase(), priority, meta, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java index 064249dad..2d43cad3a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempChatMeta.java @@ -29,7 +29,7 @@ import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.api.model.DataMutateResult; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.ChatMetaType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -92,8 +92,8 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand { n.getContexts().equals(context), null); Message.BULK_REMOVE_TEMP_CHATMETA_SUCCESS.send(sender, holder.getFormattedDisplayName(), this.type.name().toLowerCase(), priority, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta" , "removetemp" + this.type.name().toLowerCase(), priority, "*", context) + LoggedAction.build().source(sender).target(holder) + .description("meta" , "removetemp" + this.type.name().toLowerCase(), priority, "*", context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); @@ -111,8 +111,8 @@ public class MetaRemoveTempChatMeta extends SharedSubCommand { builder.applyDeep(c -> c.hoverEvent(event)); sender.sendMessage(builder.build()); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta" , "removetemp" + this.type.name().toLowerCase(), priority, meta, context) + LoggedAction.build().source(sender).target(holder) + .description("meta" , "removetemp" + this.type.name().toLowerCase(), priority, meta, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java index 573d395f2..d65b4e550 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.Node; import me.lucko.luckperms.api.node.NodeEqualityPredicate; import me.lucko.luckperms.api.node.types.MetaNode; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -95,8 +95,8 @@ public class MetaSet extends SharedSubCommand { builder.applyDeep(c -> c.hoverEvent(event)); sender.sendMessage(builder.build()); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta", "set", key, value, context) + LoggedAction.build().source(sender).target(holder) + .description("meta", "set", key, value, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java index 60cf13961..ed2683c61 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetChatMeta.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.model.DataMutateResult; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.ChatMetaType; import me.lucko.luckperms.api.query.QueryOptions; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.cacheddata.type.MetaAccumulator; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; @@ -130,8 +130,8 @@ public class MetaSetChatMeta extends SharedSubCommand { builder.applyDeep(c -> c.hoverEvent(event)); sender.sendMessage(builder.build()); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta" , "set" + this.type.name().toLowerCase(), priority, meta, context) + LoggedAction.build().source(sender).target(holder) + .description("meta" , "set" + this.type.name().toLowerCase(), priority, meta, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java index d95fdfa22..048424647 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java @@ -31,7 +31,7 @@ import me.lucko.luckperms.api.model.TemporaryMergeBehaviour; import me.lucko.luckperms.api.node.Node; import me.lucko.luckperms.api.node.NodeEqualityPredicate; import me.lucko.luckperms.api.node.types.MetaNode; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -100,8 +100,8 @@ public class MetaSetTemp extends SharedSubCommand { builder.applyDeep(c -> c.hoverEvent(event)); sender.sendMessage(builder.build()); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta", "settemp", key, value, duration, context) + LoggedAction.build().source(sender).target(holder) + .description("meta", "settemp", key, value, duration, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java index 9d6429a40..6f9b3ecc7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTempChatMeta.java @@ -32,7 +32,7 @@ import me.lucko.luckperms.api.model.TemporaryMergeBehaviour; import me.lucko.luckperms.api.node.ChatMetaType; import me.lucko.luckperms.api.query.QueryOptions; import me.lucko.luckperms.api.util.Result; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.cacheddata.type.MetaAccumulator; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; @@ -143,8 +143,8 @@ public class MetaSetTempChatMeta extends SharedSubCommand { builder.applyDeep(c -> c.hoverEvent(event)); sender.sendMessage(builder.build()); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta" , "settemp" + this.type.name().toLowerCase(), priority, meta, duration, context) + LoggedAction.build().source(sender).target(holder) + .description("meta" , "settemp" + this.type.name().toLowerCase(), priority, meta, duration, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java index bfdd5ab32..d2b2e0052 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.types.MetaNode; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -72,8 +72,8 @@ public class MetaUnset extends SharedSubCommand { if (holder.removeIf(DataType.NORMAL, context, n -> n instanceof MetaNode && (n.hasExpiry() == false) && ((MetaNode) n).getMetaKey().equalsIgnoreCase(key), null)) { Message.UNSET_META_SUCCESS.send(sender, key, holder.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta", "unset", key, context) + LoggedAction.build().source(sender).target(holder) + .description("meta", "unset", key, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java index 8a2490bb6..711899886 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.types.MetaNode; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -72,8 +72,8 @@ public class MetaUnsetTemp extends SharedSubCommand { if (holder.removeIf(DataType.NORMAL, context, n -> n instanceof MetaNode && (n.hasExpiry() == true) && ((MetaNode) n).getMetaKey().equalsIgnoreCase(key), null)) { Message.UNSET_META_TEMP_SUCCESS.send(sender, key, holder.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("meta", "unsettemp", key, context) + LoggedAction.build().source(sender).target(holder) + .description("meta", "unsettemp", key, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderClear.java index 0cb39c76a..c6a9e57dc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderClear.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.generic.other; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.model.DataType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SubCommand; @@ -81,8 +81,8 @@ public class HolderClear extends SubCommand { Message.CLEAR_SUCCESS.send(sender, holder.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); } - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("clear", context) + LoggedAction.build().source(sender).target(holder) + .description("clear", context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java index 69c8e423a..d5b0b5cf6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.model.DataMutateResult; import me.lucko.luckperms.api.model.DataType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -84,8 +84,8 @@ public class ParentAdd extends SharedSubCommand { if (result.wasSuccessful()) { Message.SET_INHERIT_SUCCESS.send(sender, holder.getFormattedDisplayName(), group.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("parent", "add", group.getName(), context) + LoggedAction.build().source(sender).target(holder) + .description("parent", "add", group.getName(), context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java index bbdfb562f..7381e7ce7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.model.TemporaryDataMutateResult; import me.lucko.luckperms.api.model.TemporaryMergeBehaviour; import me.lucko.luckperms.api.util.Result; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -96,8 +96,8 @@ public class ParentAddTemp extends SharedSubCommand { duration = ret.getMergedNode().getExpiry().getEpochSecond(); Message.SET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFormattedDisplayName(), group.getFormattedDisplayName(), DurationFormatter.LONG.formatDateDiff(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("parent", "addtemp", group.getName(), duration, context) + LoggedAction.build().source(sender).target(holder) + .description("parent", "addtemp", group.getName(), duration, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java index d1b492192..3ab0a78e8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClear.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -79,8 +79,8 @@ public class ParentClear extends SharedSubCommand { Message.PARENT_CLEAR_SUCCESS.send(sender, holder.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); } - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("parent", "clear", context) + LoggedAction.build().source(sender).target(holder) + .description("parent", "clear", context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java index ff5e23edc..d3cdd658b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.NodeType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -110,8 +110,8 @@ public class ParentClearTrack extends SharedSubCommand { Message.PARENT_CLEAR_TRACK_SUCCESS.send(sender, holder.getFormattedDisplayName(), track.getName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); } - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("parent", "cleartrack", track.getName(), context) + LoggedAction.build().source(sender).target(holder) + .description("parent", "cleartrack", track.getName(), context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java index dd3f3345c..1908e583c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.model.DataMutateResult; import me.lucko.luckperms.api.model.DataType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -94,8 +94,8 @@ public class ParentRemove extends SharedSubCommand { if (result.wasSuccessful()) { Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFormattedDisplayName(), groupName, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("parent", "remove", groupName, context) + LoggedAction.build().source(sender).target(holder) + .description("parent", "remove", groupName, context) .build().submit(plugin, sender); if (holder.getType() == HolderType.USER) { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java index 12f5b2898..a2983c4e0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.model.DataMutateResult; import me.lucko.luckperms.api.model.DataType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -78,8 +78,8 @@ public class ParentRemoveTemp extends SharedSubCommand { if (result.wasSuccessful()) { Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFormattedDisplayName(), groupName, MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("parent", "removetemp", groupName, context) + LoggedAction.build().source(sender).target(holder) + .description("parent", "removetemp", groupName, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java index cd8e67be1..905d24cf5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.model.DataType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -88,8 +88,8 @@ public class ParentSet extends SharedSubCommand { Message.SET_PARENT_SUCCESS.send(sender, holder.getFormattedDisplayName(), group.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("parent", "set", group.getName(), context) + LoggedAction.build().source(sender).target(holder) + .description("parent", "set", group.getName(), context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java index d6012b8b1..54882c378 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.NodeType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -118,8 +118,8 @@ public class ParentSetTrack extends SharedSubCommand { Message.SET_TRACK_PARENT_SUCCESS.send(sender, holder.getFormattedDisplayName(), track.getName(), group.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("parent", "settrack", track.getName(), groupName, context) + LoggedAction.build().source(sender).target(holder) + .description("parent", "settrack", track.getName(), groupName, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java index cbfe2e14f..17ff33175 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java @@ -29,7 +29,7 @@ import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.Node; import me.lucko.luckperms.api.node.NodeEqualityPredicate; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; @@ -101,8 +101,8 @@ public class UserSwitchPrimaryGroup extends SharedSubCommand { user.getPrimaryGroup().setStoredValue(group.getName()); Message.USER_PRIMARYGROUP_SUCCESS.send(sender, user.getFormattedDisplayName(), group.getFormattedDisplayName()); - ExtendedLogEntry.build().actor(sender).acted(user) - .action("parent", "switchprimarygroup", group.getName()) + LoggedAction.build().source(sender).target(user) + .description("parent", "switchprimarygroup", group.getName()) .build().submit(plugin, sender); StorageAssistant.save(user, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java index 5bbfc39ac..1aa67f6ba 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionClear.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.types.PermissionNode; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -82,8 +82,8 @@ public class PermissionClear extends SharedSubCommand { Message.PERMISSION_CLEAR_SUCCESS.send(sender, holder.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context), changed); } - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("permission", "clear", context) + LoggedAction.build().source(sender).target(holder) + .description("permission", "clear", context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java index 1500cd3d5..e1481ff41 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.model.DataMutateResult; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.Node; import me.lucko.luckperms.api.node.types.InheritanceNode; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -89,8 +89,8 @@ public class PermissionSet extends SharedSubCommand { if (result.wasSuccessful()) { Message.SETPERMISSION_SUCCESS.send(sender, node, value, holder.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("permission", "set", node, value, context) + LoggedAction.build().source(sender).target(holder) + .description("permission", "set", node, value, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java index 3a6242545..3f65b7082 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java @@ -32,7 +32,7 @@ import me.lucko.luckperms.api.model.TemporaryMergeBehaviour; import me.lucko.luckperms.api.node.Node; import me.lucko.luckperms.api.node.types.InheritanceNode; import me.lucko.luckperms.api.util.Result; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -96,8 +96,8 @@ public class PermissionSetTemp extends SharedSubCommand { duration = result.getMergedNode().getExpiry().getEpochSecond(); Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, value, holder.getFormattedDisplayName(), DurationFormatter.LONG.formatDateDiff(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("permission", "settemp", node, value, duration, context) + LoggedAction.build().source(sender).target(holder) + .description("permission", "settemp", node, value, duration, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java index aaeeafdcc..094c25ba5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.model.DataMutateResult; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.Node; import me.lucko.luckperms.api.node.types.InheritanceNode; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -88,8 +88,8 @@ public class PermissionUnset extends SharedSubCommand { if (result.wasSuccessful()) { Message.UNSETPERMISSION_SUCCESS.send(sender, node, holder.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("permission", "unset", node, context) + LoggedAction.build().source(sender).target(holder) + .description("permission", "unset", node, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java index 175abc428..33f077b7a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.api.model.DataMutateResult; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.Node; import me.lucko.luckperms.api.node.types.InheritanceNode; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SharedSubCommand; @@ -88,8 +88,8 @@ public class PermissionUnsetTemp extends SharedSubCommand { if (result.wasSuccessful()) { Message.UNSET_TEMP_PERMISSION_SUCCESS.send(sender, node, holder.getFormattedDisplayName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("permission", "unsettemp", node, context) + LoggedAction.build().source(sender).target(holder) + .description("permission", "unsettemp", node, context) .build().submit(plugin, sender); StorageAssistant.save(holder, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/CreateGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/CreateGroup.java index ec4db0565..f099d6373 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/CreateGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/CreateGroup.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.api.actionlog.Action; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -74,8 +74,8 @@ public class CreateGroup extends SingleCommand { Message.CREATE_SUCCESS.send(sender, groupName); - ExtendedLogEntry.build().actor(sender).actedName(groupName).type(Action.Type.GROUP) - .action("create") + LoggedAction.build().source(sender).targetName(groupName).targetType(Action.Target.Type.GROUP) + .description("create") .build().submit(plugin, sender); return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/DeleteGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/DeleteGroup.java index 9be80c985..baddd78e4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/DeleteGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/DeleteGroup.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.api.actionlog.Action; import me.lucko.luckperms.api.event.cause.DeletionCause; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -79,8 +79,8 @@ public class DeleteGroup extends SingleCommand { Message.DELETE_SUCCESS.send(sender, group.getFormattedDisplayName()); - ExtendedLogEntry.build().actor(sender).actedName(groupName).type(Action.Type.GROUP) - .action("delete") + LoggedAction.build().source(sender).targetName(groupName).targetType(Action.Target.Type.GROUP) + .description("delete") .build().submit(plugin, sender); plugin.getSyncTaskBuffer().request(); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupClone.java index fcbe5e226..9f6d05488 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupClone.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.api.model.DataType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; @@ -77,8 +77,8 @@ public class GroupClone extends SubCommand { Message.CLONE_SUCCESS.send(sender, group.getName(), newGroup.getName()); - ExtendedLogEntry.build().actor(sender).acted(newGroup) - .action("clone", group.getName()) + LoggedAction.build().source(sender).target(newGroup) + .description("clone", group.getName()) .build().submit(plugin, sender); StorageAssistant.save(newGroup, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupRename.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupRename.java index d335e322b..3b778711e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupRename.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupRename.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.api.event.cause.DeletionCause; import me.lucko.luckperms.api.model.DataType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -83,8 +83,8 @@ public class GroupRename extends SubCommand { Message.RENAME_SUCCESS.send(sender, group.getName(), newGroup.getName()); - ExtendedLogEntry.build().actor(sender).acted(group) - .action("rename", newGroup.getName()) + LoggedAction.build().source(sender).target(group) + .description("rename", newGroup.getName()) .build().submit(plugin, sender); StorageAssistant.save(newGroup, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java index d160fc1e7..06850e1ab 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetDisplayName.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.types.DisplayNameNode; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SubCommand; @@ -86,8 +86,8 @@ public class GroupSetDisplayName extends SubCommand { if (name.equals(group.getName())) { Message.GROUP_SET_DISPLAY_NAME_REMOVED.send(sender, group.getName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(group) - .action("setdisplayname", name, context) + LoggedAction.build().source(sender).target(group) + .description("setdisplayname", name, context) .build().submit(plugin, sender); StorageAssistant.save(group, sender, plugin); @@ -98,8 +98,8 @@ public class GroupSetDisplayName extends SubCommand { Message.GROUP_SET_DISPLAY_NAME.send(sender, name, group.getName(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(group) - .action("setdisplayname", name, context) + LoggedAction.build().source(sender).target(group) + .description("setdisplayname", name, context) .build().submit(plugin, sender); StorageAssistant.save(group, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java index 9e5ae0377..7e1e9089d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupSetWeight.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.group; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.types.WeightNode; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SubCommand; @@ -65,8 +65,8 @@ public class GroupSetWeight extends SubCommand { Message.GROUP_SET_WEIGHT.send(sender, weight, group.getFormattedDisplayName()); - ExtendedLogEntry.build().actor(sender).acted(group) - .action("setweight", weight) + LoggedAction.build().source(sender).target(group) + .description("setweight", weight) .build().submit(plugin, sender); StorageAssistant.save(group, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogGroupHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogGroupHistory.java index 0c0ea8830..6892fb4f2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogGroupHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogGroupHistory.java @@ -25,8 +25,9 @@ package me.lucko.luckperms.common.commands.log; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.api.actionlog.Action; import me.lucko.luckperms.common.actionlog.Log; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -62,7 +63,7 @@ public class LogGroupHistory extends SubCommand { return CommandResult.INVALID_ARGS; } - Paginated content = new Paginated<>(log.getGroupHistory(group)); + Paginated content = new Paginated<>(log.getGroupHistory(group)); int page = ArgumentParser.parseIntOrElse(1, args, Integer.MIN_VALUE); if (page != Integer.MIN_VALUE) { @@ -72,7 +73,7 @@ public class LogGroupHistory extends SubCommand { } } - private static CommandResult showLog(int page, Sender sender, Paginated log) { + private static CommandResult showLog(int page, Sender sender, Paginated log) { int maxPage = log.getMaxPages(ENTRIES_PER_PAGE); if (maxPage == 0) { Message.LOG_NO_ENTRIES.send(sender); @@ -88,20 +89,20 @@ public class LogGroupHistory extends SubCommand { return CommandResult.INVALID_ARGS; } - SortedMap entries = log.getPage(page, ENTRIES_PER_PAGE); - String name = entries.values().stream().findAny().get().getActedName(); + SortedMap entries = log.getPage(page, ENTRIES_PER_PAGE); + String name = ((Action) entries.values().stream().findAny().get()).getTarget().getName(); Message.LOG_HISTORY_GROUP_HEADER.send(sender, name, page, maxPage); long now = System.currentTimeMillis() / 1000L; - for (Map.Entry e : entries.entrySet()) { - long time = e.getValue().getTimestamp(); + for (Map.Entry e : entries.entrySet()) { + long time = e.getValue().getTimestamp().getEpochSecond(); Message.LOG_ENTRY.send(sender, e.getKey(), DurationFormatter.CONCISE_LOW_ACCURACY.format(now - time), - e.getValue().getActorFriendlyString(), - Character.toString(e.getValue().getType().getCode()), - e.getValue().getActedFriendlyString(), - e.getValue().getAction() + e.getValue().getSourceFriendlyString(), + Character.toString(LoggedAction.getTypeCharacter(((Action) e.getValue()).getTarget().getType())), + e.getValue().getTargetFriendlyString(), + e.getValue().getDescription() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogRecent.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogRecent.java index 2482b0686..c27e7ee61 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogRecent.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogRecent.java @@ -25,8 +25,9 @@ package me.lucko.luckperms.common.commands.log; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.api.actionlog.Action; import me.lucko.luckperms.common.actionlog.Log; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -56,13 +57,13 @@ public class LogRecent extends SubCommand { public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List args, String label) { if (args.isEmpty()) { // No page or user - Paginated content = new Paginated<>(log.getContent()); + Paginated content = new Paginated<>(log.getContent()); return showLog(content.getMaxPages(ENTRIES_PER_PAGE), false, sender, content); } int page = ArgumentParser.parseIntOrElse(0, args, Integer.MIN_VALUE); if (page != Integer.MIN_VALUE) { - Paginated content = new Paginated<>(log.getContent()); + Paginated content = new Paginated<>(log.getContent()); return showLog(page, false, sender, content); } @@ -72,7 +73,7 @@ public class LogRecent extends SubCommand { return CommandResult.INVALID_ARGS; } - Paginated content = new Paginated<>(log.getContent(uuid)); + Paginated content = new Paginated<>(log.getContent(uuid)); page = ArgumentParser.parseIntOrElse(1, args, Integer.MIN_VALUE); if (page != Integer.MIN_VALUE) { return showLog(page, true, sender, content); @@ -81,7 +82,7 @@ public class LogRecent extends SubCommand { } } - private static CommandResult showLog(int page, boolean specificUser, Sender sender, Paginated log) { + private static CommandResult showLog(int page, boolean specificUser, Sender sender, Paginated log) { int maxPage = log.getMaxPages(ENTRIES_PER_PAGE); if (maxPage == 0) { Message.LOG_NO_ENTRIES.send(sender); @@ -93,9 +94,9 @@ public class LogRecent extends SubCommand { return CommandResult.INVALID_ARGS; } - SortedMap entries = log.getPage(page, ENTRIES_PER_PAGE); + SortedMap entries = log.getPage(page, ENTRIES_PER_PAGE); if (specificUser) { - String name = entries.values().stream().findAny().get().getActorName(); + String name = ((Action) entries.values().stream().findAny().get()).getSource().getName(); if (name.contains("@")) { name = name.split("@")[0]; } @@ -105,15 +106,15 @@ public class LogRecent extends SubCommand { } long now = System.currentTimeMillis() / 1000L; - for (Map.Entry e : entries.entrySet()) { - long time = e.getValue().getTimestamp(); + for (Map.Entry e : entries.entrySet()) { + long time = e.getValue().getTimestamp().getEpochSecond(); Message.LOG_ENTRY.send(sender, e.getKey(), DurationFormatter.CONCISE_LOW_ACCURACY.format(now - time), - e.getValue().getActorFriendlyString(), - Character.toString(e.getValue().getType().getCode()), - e.getValue().getActedFriendlyString(), - e.getValue().getAction() + e.getValue().getSourceFriendlyString(), + Character.toString(LoggedAction.getTypeCharacter(((Action) e.getValue()).getTarget().getType())), + e.getValue().getTargetFriendlyString(), + e.getValue().getDescription() ); } return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogSearch.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogSearch.java index 2c47393d9..321f2d403 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogSearch.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogSearch.java @@ -25,8 +25,9 @@ package me.lucko.luckperms.common.commands.log; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.api.actionlog.Action; import me.lucko.luckperms.common.actionlog.Log; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -63,7 +64,7 @@ public class LogSearch extends SubCommand { } final String query = String.join(" ", args); - Paginated content = new Paginated<>(log.getSearch(query)); + Paginated content = new Paginated<>(log.getSearch(query)); if (page != Integer.MIN_VALUE) { return showLog(page, query, sender, content); @@ -72,7 +73,7 @@ public class LogSearch extends SubCommand { } } - private static CommandResult showLog(int page, String query, Sender sender, Paginated log) { + private static CommandResult showLog(int page, String query, Sender sender, Paginated log) { int maxPage = log.getMaxPages(ENTRIES_PER_PAGE); if (maxPage == 0) { Message.LOG_NO_ENTRIES.send(sender); @@ -88,19 +89,19 @@ public class LogSearch extends SubCommand { return CommandResult.INVALID_ARGS; } - SortedMap entries = log.getPage(page, ENTRIES_PER_PAGE); + SortedMap entries = log.getPage(page, ENTRIES_PER_PAGE); Message.LOG_SEARCH_HEADER.send(sender, query, page, maxPage); long now = System.currentTimeMillis() / 1000L; - for (Map.Entry e : entries.entrySet()) { - long time = e.getValue().getTimestamp(); + for (Map.Entry e : entries.entrySet()) { + long time = e.getValue().getTimestamp().getEpochSecond(); Message.LOG_ENTRY.send(sender, e.getKey(), DurationFormatter.CONCISE_LOW_ACCURACY.format(now - time), - e.getValue().getActorFriendlyString(), - Character.toString(e.getValue().getType().getCode()), - e.getValue().getActedFriendlyString(), - e.getValue().getAction() + e.getValue().getSourceFriendlyString(), + Character.toString(LoggedAction.getTypeCharacter(((Action) e.getValue()).getTarget().getType())), + e.getValue().getTargetFriendlyString(), + e.getValue().getDescription() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogTrackHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogTrackHistory.java index 8978b0e18..894bc0aa5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogTrackHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogTrackHistory.java @@ -25,8 +25,9 @@ package me.lucko.luckperms.common.commands.log; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.api.actionlog.Action; import me.lucko.luckperms.common.actionlog.Log; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -62,7 +63,7 @@ public class LogTrackHistory extends SubCommand { return CommandResult.INVALID_ARGS; } - Paginated content = new Paginated<>(log.getTrackHistory(track)); + Paginated content = new Paginated<>(log.getTrackHistory(track)); int page = ArgumentParser.parseIntOrElse(1, args, Integer.MIN_VALUE); if (page != Integer.MIN_VALUE) { @@ -72,7 +73,7 @@ public class LogTrackHistory extends SubCommand { } } - private static CommandResult showLog(int page, Sender sender, Paginated log) { + private static CommandResult showLog(int page, Sender sender, Paginated log) { int maxPage = log.getMaxPages(ENTRIES_PER_PAGE); if (maxPage == 0) { Message.LOG_NO_ENTRIES.send(sender); @@ -88,20 +89,20 @@ public class LogTrackHistory extends SubCommand { return CommandResult.INVALID_ARGS; } - SortedMap entries = log.getPage(page, ENTRIES_PER_PAGE); - String name = entries.values().stream().findAny().get().getActedName(); + SortedMap entries = log.getPage(page, ENTRIES_PER_PAGE); + String name = ((Action) entries.values().stream().findAny().get()).getTarget().getName(); Message.LOG_HISTORY_TRACK_HEADER.send(sender, name, page, maxPage); long now = System.currentTimeMillis() / 1000L; - for (Map.Entry e : entries.entrySet()) { - long time = e.getValue().getTimestamp(); + for (Map.Entry e : entries.entrySet()) { + long time = e.getValue().getTimestamp().getEpochSecond(); Message.LOG_ENTRY.send(sender, e.getKey(), DurationFormatter.CONCISE_LOW_ACCURACY.format(now - time), - e.getValue().getActorFriendlyString(), - Character.toString(e.getValue().getType().getCode()), - e.getValue().getActedFriendlyString(), - e.getValue().getAction() + e.getValue().getSourceFriendlyString(), + Character.toString(LoggedAction.getTypeCharacter(((Action) e.getValue()).getTarget().getType())), + e.getValue().getTargetFriendlyString(), + e.getValue().getDescription() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogUserHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogUserHistory.java index 46152c275..f300e98e4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogUserHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogUserHistory.java @@ -25,8 +25,9 @@ package me.lucko.luckperms.common.commands.log; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.api.actionlog.Action; import me.lucko.luckperms.common.actionlog.Log; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -59,7 +60,7 @@ public class LogUserHistory extends SubCommand { return CommandResult.INVALID_ARGS; } - Paginated content = new Paginated<>(log.getUserHistory(uuid)); + Paginated content = new Paginated<>(log.getUserHistory(uuid)); int page = ArgumentParser.parseIntOrElse(1, args, Integer.MIN_VALUE); if (page != Integer.MIN_VALUE) { @@ -69,7 +70,7 @@ public class LogUserHistory extends SubCommand { } } - private static CommandResult showLog(int page, Sender sender, Paginated log) { + private static CommandResult showLog(int page, Sender sender, Paginated log) { int maxPage = log.getMaxPages(ENTRIES_PER_PAGE); if (maxPage == 0) { Message.LOG_NO_ENTRIES.send(sender); @@ -81,20 +82,20 @@ public class LogUserHistory extends SubCommand { return CommandResult.INVALID_ARGS; } - SortedMap entries = log.getPage(page, ENTRIES_PER_PAGE); - String name = entries.values().stream().findAny().get().getActedName(); + SortedMap entries = log.getPage(page, ENTRIES_PER_PAGE); + String name = ((Action) entries.values().stream().findAny().get()).getTarget().getName(); Message.LOG_HISTORY_USER_HEADER.send(sender, name, page, maxPage); long now = System.currentTimeMillis() / 1000L; - for (Map.Entry e : entries.entrySet()) { - long time = e.getValue().getTimestamp(); + for (Map.Entry e : entries.entrySet()) { + long time = e.getValue().getTimestamp().getEpochSecond(); Message.LOG_ENTRY.send(sender, e.getKey(), DurationFormatter.CONCISE_LOW_ACCURACY.format(now - time), - e.getValue().getActorFriendlyString(), - Character.toString(e.getValue().getType().getCode()), - e.getValue().getActedFriendlyString(), - e.getValue().getAction() + e.getValue().getSourceFriendlyString(), + Character.toString(LoggedAction.getTypeCharacter(((Action) e.getValue()).getTarget().getType())), + e.getValue().getTargetFriendlyString(), + e.getValue().getDescription() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ApplyEditsCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ApplyEditsCommand.java index 218405a81..a76b70f78 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/ApplyEditsCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/ApplyEditsCommand.java @@ -32,7 +32,7 @@ import com.google.gson.JsonObject; import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.node.Node; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; @@ -133,13 +133,13 @@ public class ApplyEditsCommand extends SingleCommand { holder.setNodes(DataType.NORMAL, after); for (Node n : diffAdded) { - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("webeditor", "add", n.getKey(), n.getValue(), n.getContexts()) + LoggedAction.build().source(sender).target(holder) + .description("webeditor", "add", n.getKey(), n.getValue(), n.getContexts()) .build().submit(plugin, sender); } for (Node n : diffRemoved) { - ExtendedLogEntry.build().actor(sender).acted(holder) - .action("webeditor", "remove", n.getKey(), n.getValue(), n.getContexts()) + LoggedAction.build().source(sender).target(holder) + .description("webeditor", "remove", n.getKey(), n.getValue(), n.getContexts()) .build().submit(plugin, sender); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/CreateTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/CreateTrack.java index 1a0a83307..01fc3cb31 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/CreateTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/CreateTrack.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.actionlog.Action; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -74,8 +74,8 @@ public class CreateTrack extends SingleCommand { Message.CREATE_SUCCESS.send(sender, trackName); - ExtendedLogEntry.build().actor(sender).actedName(trackName).type(Action.Type.TRACK) - .action("create").build() + LoggedAction.build().source(sender).targetName(trackName).targetType(Action.Target.Type.TRACK) + .description("create").build() .submit(plugin, sender); return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/DeleteTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/DeleteTrack.java index d43d60efa..41bf71a17 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/DeleteTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/DeleteTrack.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.actionlog.Action; import me.lucko.luckperms.api.event.cause.DeletionCause; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SingleCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -72,8 +72,8 @@ public class DeleteTrack extends SingleCommand { Message.DELETE_SUCCESS.send(sender, trackName); - ExtendedLogEntry.build().actor(sender).actedName(trackName).type(Action.Type.TRACK) - .action("delete") + LoggedAction.build().source(sender).targetName(trackName).targetType(Action.Target.Type.TRACK) + .description("delete") .build().submit(plugin, sender); return CommandResult.SUCCESS; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackAppend.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackAppend.java index dbbb41bfa..b076f8d56 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackAppend.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackAppend.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.model.DataMutateResult; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -72,8 +72,8 @@ public class TrackAppend extends SubCommand { Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups(), group.getName())); } - ExtendedLogEntry.build().actor(sender).acted(track) - .action("append", group.getName()) + LoggedAction.build().source(sender).target(track) + .description("append", group.getName()) .build().submit(plugin, sender); StorageAssistant.save(track, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClear.java index edadd7eb7..6a66eeb59 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClear.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.common.commands.track; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -50,8 +50,8 @@ public class TrackClear extends SubCommand { track.clearGroups(); Message.TRACK_CLEAR.send(sender, track.getName()); - ExtendedLogEntry.build().actor(sender).acted(track) - .action("clear") + LoggedAction.build().source(sender).target(track) + .description("clear") .build().submit(plugin, sender); StorageAssistant.save(track, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClone.java index d611dab2e..ab3dff52b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackClone.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.event.cause.CreationCause; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -65,8 +65,8 @@ public class TrackClone extends SubCommand { Message.CLONE_SUCCESS.send(sender, track.getName(), newTrack.getName()); - ExtendedLogEntry.build().actor(sender).acted(track) - .action("clone", newTrack.getName()) + LoggedAction.build().source(sender).target(track) + .description("clone", newTrack.getName()) .build().submit(plugin, sender); StorageAssistant.save(newTrack, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInsert.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInsert.java index ef1f050aa..b7d968dcb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInsert.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackInsert.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.model.DataMutateResult; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -81,8 +81,8 @@ public class TrackInsert extends SubCommand { Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups(), group.getName())); } - ExtendedLogEntry.build().actor(sender).acted(track) - .action("insert", group.getName(), pos) + LoggedAction.build().source(sender).target(track) + .description("insert", group.getName(), pos) .build().submit(plugin, sender); StorageAssistant.save(track, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRemove.java index 216e5731b..d45483133 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRemove.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.model.DataMutateResult; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -66,8 +66,8 @@ public class TrackRemove extends SubCommand { Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups())); } - ExtendedLogEntry.build().actor(sender).acted(track) - .action("remove", groupName) + LoggedAction.build().source(sender).target(track) + .description("remove", groupName) .build().submit(plugin, sender); StorageAssistant.save(track, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRename.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRename.java index d08cf3362..db0065581 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRename.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackRename.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.track; import me.lucko.luckperms.api.event.cause.CreationCause; import me.lucko.luckperms.api.event.cause.DeletionCause; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; @@ -82,8 +82,8 @@ public class TrackRename extends SubCommand { Message.RENAME_SUCCESS.send(sender, track.getName(), newTrack.getName()); - ExtendedLogEntry.build().actor(sender).acted(track) - .action("rename", newTrack.getName()) + LoggedAction.build().source(sender).target(track) + .description("rename", newTrack.getName()) .build().submit(plugin, sender); StorageAssistant.save(newTrack, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserClone.java index 20e5860e0..2bacd3a57 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserClone.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.common.commands.user; import me.lucko.luckperms.api.model.DataType; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; @@ -76,8 +76,8 @@ public class UserClone extends SubCommand { Message.CLONE_SUCCESS.send(sender, user.getFormattedDisplayName(), otherUser.getFormattedDisplayName()); - ExtendedLogEntry.build().actor(sender).acted(otherUser) - .action("clone", user.getName()) + LoggedAction.build().source(sender).target(otherUser) + .description("clone", user.getName()) .build().submit(plugin, sender); StorageAssistant.save(otherUser, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserDemote.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserDemote.java index 9bf5f5228..b429f4875 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserDemote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserDemote.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.user; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.track.DemotionResult; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SubCommand; @@ -116,8 +116,8 @@ public class UserDemote extends SubCommand { Message.USER_DEMOTE_ENDOFTRACK.send(sender, track.getName(), user.getFormattedDisplayName(), result.getGroupFrom().get()); - ExtendedLogEntry.build().actor(sender).acted(user) - .action("demote", track.getName(), context) + LoggedAction.build().source(sender).target(user) + .description("demote", track.getName(), context) .build().submit(plugin, sender); StorageAssistant.save(user, sender, plugin); @@ -133,8 +133,8 @@ public class UserDemote extends SubCommand { Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups(), groupTo, groupFrom, true)); } - ExtendedLogEntry.build().actor(sender).acted(user) - .action("demote", track.getName(), context) + LoggedAction.build().source(sender).target(user) + .description("demote", track.getName(), context) .build().submit(plugin, sender); StorageAssistant.save(user, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserPromote.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserPromote.java index 9654469c2..9327b524e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserPromote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserPromote.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.common.commands.user; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.track.PromotionResult; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.command.abstraction.SubCommand; @@ -116,8 +116,8 @@ public class UserPromote extends SubCommand { Message.USER_TRACK_ADDED_TO_FIRST.send(sender, user.getFormattedDisplayName(), result.getGroupTo().get(), MessageUtils.contextSetToString(plugin.getLocaleManager(), context)); - ExtendedLogEntry.build().actor(sender).acted(user) - .action("promote", track.getName(), context) + LoggedAction.build().source(sender).target(user) + .description("promote", track.getName(), context) .build().submit(plugin, sender); StorageAssistant.save(user, sender, plugin); @@ -133,8 +133,8 @@ public class UserPromote extends SubCommand { Message.BLANK.send(sender, MessageUtils.listToArrowSep(track.getGroups(), groupFrom, groupTo, false)); } - ExtendedLogEntry.build().actor(sender).acted(user) - .action("promote", track.getName(), context) + LoggedAction.build().source(sender).target(user) + .description("promote", track.getName(), context) .build().submit(plugin, sender); StorageAssistant.save(user, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextManager.java b/common/src/main/java/me/lucko/luckperms/common/context/ContextManager.java index 779456b03..34cb97cfb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/ContextManager.java @@ -122,7 +122,7 @@ public abstract class ContextManager { for (ContextCalculator calculator : this.calculators) { try { - calculator.giveApplicableContext(subject, accumulator::add); + calculator.calculate(subject, accumulator::add); } catch (Throwable e) { ContextManager.this.plugin.getLogger().warn("An exception was thrown by " + getCalculatorClass(calculator) + " whilst calculating the context of subject " + subject); e.printStackTrace(); @@ -137,7 +137,7 @@ public abstract class ContextManager { for (StaticContextCalculator calculator : this.staticCalculators) { try { - calculator.giveApplicableContext(accumulator::add); + calculator.calculate(accumulator::add); } catch (Throwable e) { this.plugin.getLogger().warn("An exception was thrown by " + getCalculatorClass(calculator) + " whilst calculating static contexts"); e.printStackTrace(); diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetComparator.java b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetComparator.java index 14f0b9249..9be945464 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetComparator.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetComparator.java @@ -25,6 +25,7 @@ package me.lucko.luckperms.common.context; +import me.lucko.luckperms.api.context.Context; import me.lucko.luckperms.api.context.DefaultContextKeys; import me.lucko.luckperms.api.context.ImmutableContextSet; @@ -32,7 +33,6 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; import java.util.List; -import java.util.Map; public class ContextSetComparator implements Comparator { @@ -73,18 +73,18 @@ public class ContextSetComparator implements Comparator { // in order to have consistent ordering, we have to compare the content of the context sets by ordering the // elements and then comparing which set is greater. - List> o1Entries = new ArrayList<>(o1.toSet()); - List> o2Entries = new ArrayList<>(o2.toSet()); + List o1Entries = new ArrayList<>(o1.toSet()); + List o2Entries = new ArrayList<>(o2.toSet()); o1Entries.sort(STRING_ENTRY_COMPARATOR); o2Entries.sort(STRING_ENTRY_COMPARATOR); // size is definitely the same - Iterator> it1 = o1Entries.iterator(); - Iterator> it2 = o2Entries.iterator(); + Iterator it1 = o1Entries.iterator(); + Iterator it2 = o2Entries.iterator(); while (it1.hasNext()) { - Map.Entry ent1 = it1.next(); - Map.Entry ent2 = it2.next(); + Context ent1 = it1.next(); + Context ent2 = it2.next(); int ret = STRING_ENTRY_COMPARATOR.compare(ent1, ent2); if (ret != 0) { @@ -98,7 +98,7 @@ public class ContextSetComparator implements Comparator { @SuppressWarnings("StringEquality") private static final Comparator FAST_STRING_COMPARATOR = (o1, o2) -> o1 == o2 ? 0 : o1.compareTo(o2); - private static final Comparator> STRING_ENTRY_COMPARATOR = (o1, o2) -> { + private static final Comparator STRING_ENTRY_COMPARATOR = (o1, o2) -> { if (o1 == o2) { return 0; } diff --git a/common/src/main/java/me/lucko/luckperms/common/context/LPStaticContextsCalculator.java b/common/src/main/java/me/lucko/luckperms/common/context/LPStaticContextsCalculator.java index 0ba25bf23..3a154d561 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/LPStaticContextsCalculator.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/LPStaticContextsCalculator.java @@ -41,7 +41,7 @@ public class LPStaticContextsCalculator implements StaticContextCalculator { } @Override - public void giveApplicableContext(@NonNull ContextConsumer consumer) { + public void calculate(@NonNull ContextConsumer consumer) { String server = this.config.get(ConfigKeys.SERVER); if (!server.equals("global")) { consumer.accept(DefaultContextKeys.SERVER_KEY, server); diff --git a/common/src/main/java/me/lucko/luckperms/common/context/contextset/ContextImpl.java b/common/src/main/java/me/lucko/luckperms/common/context/contextset/ContextImpl.java new file mode 100644 index 000000000..91975957c --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/context/contextset/ContextImpl.java @@ -0,0 +1,60 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.luckperms.common.context.contextset; + +import me.lucko.luckperms.api.context.Context; + +public final class ContextImpl implements Context { + private final String key; + private final String value; + + public ContextImpl(String key, String value) { + this.key = key; + this.value = value; + } + + @Override + public String getKey() { + return this.key; + } + + @Override + public String getValue() { + return this.value; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Context)) return false; + Context that = (Context) obj; + return this.key.equals(that.getKey()) && this.value.equals(that.getValue()); + } + + @Override + public int hashCode() { + return this.key.hashCode() ^ this.value.hashCode(); + } +} diff --git a/common/src/main/java/me/lucko/luckperms/common/context/contextset/ImmutableContextSetImpl.java b/common/src/main/java/me/lucko/luckperms/common/context/contextset/ImmutableContextSetImpl.java index 9d1d25102..123ccc6d6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/contextset/ImmutableContextSetImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/contextset/ImmutableContextSetImpl.java @@ -25,12 +25,15 @@ package me.lucko.luckperms.common.context.contextset; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.common.collect.SetMultimap; +import me.lucko.luckperms.api.context.Context; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.api.context.MutableContextSet; @@ -50,15 +53,6 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements return new ImmutableContextSetImpl(ImmutableSetMultimap.of(sanitizeKey(key), sanitizeValue(value))); } - public static ImmutableContextSet of(String key1, String value1, String key2, String value2) { - return new ImmutableContextSetImpl(ImmutableSetMultimap.of( - sanitizeKey(key1), - sanitizeValue(value1), - sanitizeKey(key2), - sanitizeValue(value2) - )); - } - private final ImmutableSetMultimap map; private final int hashCode; @@ -94,8 +88,13 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements } @Override - public @NonNull Set> toSet() { - return this.map.entries(); + public @NonNull Set toSet() { + ImmutableSet.Builder builder = ImmutableSet.builder(); + Set> entries = this.map.entries(); + for (Map.Entry e : entries) { + builder.add(new ContextImpl(e.getKey(), e.getValue())); + } + return builder.build(); } @Override @@ -113,14 +112,52 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements return m.build(); } - @Override - public @NonNull Iterator> iterator() { - return this.map.entries().iterator(); + private ImmutableList toList() { + Set> entries = this.map.entries(); + Context[] array = new Context[entries.size()]; + int i = 0; + for (Map.Entry e : entries) { + array[i++] = new ContextImpl(e.getKey(), e.getValue()); + } + return ImmutableList.copyOf(array); } @Override - public Spliterator> spliterator() { - return this.map.entries().spliterator(); + public @NonNull Iterator iterator() { + return toList().iterator(); + } + + @Override + public Spliterator spliterator() { + return toList().spliterator(); + } + + @Override + public boolean isSatisfiedBy(@NonNull ContextSet other) { + if (this == other) { + return true; + } + + Objects.requireNonNull(other, "other"); + if (this.isEmpty()) { + // this is empty, so is therefore always satisfied. + return true; + } else if (other.isEmpty()) { + // this set isn't empty, but the other one is + return false; + } else if (this.size() > other.size()) { + // this set has more unique entries than the other set, so there's no way this can be satisfied. + return false; + } else { + // neither are empty, we need to compare the individual entries + Set> entries = this.map.entries(); + for (Map.Entry e : entries) { + if (!other.contains(e.getKey(), e.getValue())) { + return false; + } + } + return true; + } } @Override @@ -139,7 +176,12 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements if (that instanceof AbstractContextSet) { thatBacking = ((AbstractContextSet) that).backing(); } else { - thatBacking = ImmutableSetMultimap.copyOf(that.toSet()); + Map> thatMap = that.toMap(); + ImmutableSetMultimap.Builder thatBuilder = ImmutableSetMultimap.builder(); + for (Map.Entry> e : thatMap.entrySet()) { + thatBuilder.putAll(e.getKey(), e.getValue()); + } + thatBacking = thatBuilder.build(); } return backing().equals(thatBacking); diff --git a/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java b/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java index 8dd7a5f78..880efb644 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java @@ -26,6 +26,7 @@ package me.lucko.luckperms.common.context.contextset; import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; @@ -33,6 +34,7 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.common.collect.SetMultimap; +import me.lucko.luckperms.api.context.Context; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.api.context.MutableContextSet; @@ -93,9 +95,15 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M } @Override - public @NonNull Set> toSet() { - // map.entries() returns immutable Map.Entry instances, so we can just call copyOf - return ImmutableSet.copyOf(this.map.entries()); + public @NonNull ImmutableSet toSet() { + ImmutableSet.Builder builder = ImmutableSet.builder(); + Set> entries = this.map.entries(); + synchronized (this.map) { + for (Map.Entry e : entries) { + builder.add(new ContextImpl(e.getKey(), e.getValue())); + } + } + return builder.build(); } @Override @@ -123,14 +131,27 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M return builder.build(); } - @Override - public @NonNull Iterator> iterator() { - return toSet().iterator(); + private ImmutableList toList() { + Set> entries = this.map.entries(); + Context[] array; + synchronized (this.map) { + array = new Context[entries.size()]; + int i = 0; + for (Map.Entry e : entries) { + array[i++] = new ContextImpl(e.getKey(), e.getValue()); + } + } + return ImmutableList.copyOf(array); } @Override - public Spliterator> spliterator() { - return toSet().spliterator(); + public @NonNull Iterator iterator() { + return toList().iterator(); + } + + @Override + public Spliterator spliterator() { + return toList().spliterator(); } @Override @@ -164,6 +185,36 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M this.map.clear(); } + @Override + public boolean isSatisfiedBy(@NonNull ContextSet other) { + if (this == other) { + return true; + } + + Objects.requireNonNull(other, "other"); + if (this.isEmpty()) { + // this is empty, so is therefore always satisfied. + return true; + } else if (other.isEmpty()) { + // this set isn't empty, but the other one is + return false; + } else if (this.size() > other.size()) { + // this set has more unique entries than the other set, so there's no way this can be satisfied. + return false; + } else { + // neither are empty, we need to compare the individual entries + Set> entries = this.map.entries(); + synchronized (this.map) { + for (Map.Entry e : entries) { + if (!other.contains(e.getKey(), e.getValue())) { + return false; + } + } + } + return true; + } + } + @Override public boolean equals(Object o) { if (o == this) return true; @@ -174,7 +225,12 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M if (that instanceof AbstractContextSet) { thatBacking = ((AbstractContextSet) that).backing(); } else { - thatBacking = ImmutableSetMultimap.copyOf(that.toSet()); + Map> thatMap = that.toMap(); + ImmutableSetMultimap.Builder thatBuilder = ImmutableSetMultimap.builder(); + for (Map.Entry> e : thatMap.entrySet()) { + thatBuilder.putAll(e.getKey(), e.getValue()); + } + thatBacking = thatBuilder.build(); } return backing().equals(thatBacking); diff --git a/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java b/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java index 536c94d41..6a908c722 100644 --- a/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java +++ b/common/src/main/java/me/lucko/luckperms/common/messaging/LuckPermsMessagingService.java @@ -36,7 +36,7 @@ import me.lucko.luckperms.api.messenger.message.Message; import me.lucko.luckperms.api.messenger.message.type.ActionLogMessage; import me.lucko.luckperms.api.messenger.message.type.UpdateMessage; import me.lucko.luckperms.api.messenger.message.type.UserUpdateMessage; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.cache.BufferedRequest; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.messaging.message.ActionLogMessageImpl; @@ -256,7 +256,7 @@ public class LuckPermsMessagingService implements InternalMessagingService, Inco ActionLogMessage msg = (ActionLogMessage) message; this.plugin.getEventFactory().handleLogReceive(msg.getId(), msg.getAction()); - this.plugin.getLogDispatcher().dispatchFromRemote((ExtendedLogEntry) msg.getAction()); + this.plugin.getLogDispatcher().dispatchFromRemote((LoggedAction) msg.getAction()); } else { throw new IllegalArgumentException("Unknown message type: " + message.getClass().getName()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/node/AbstractNode.java b/common/src/main/java/me/lucko/luckperms/common/node/AbstractNode.java index 284695ac5..b55059cc3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/AbstractNode.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/AbstractNode.java @@ -180,7 +180,7 @@ public abstract class AbstractNode, B extends NodeBui @Override public boolean areEqual(@NonNull AbstractNode o1, @NonNull AbstractNode o2) { return o1 == o2 || - o1.key == o2.key && + o1.key.equals(o2.key) && o1.value == o2.value && o1.expireAt == o2.expireAt && o1.getContexts().equals(o2.getContexts()); @@ -190,7 +190,7 @@ public abstract class AbstractNode, B extends NodeBui @Override public boolean areEqual(@NonNull AbstractNode o1, @NonNull AbstractNode o2) { return o1 == o2 || - o1.key == o2.key && + o1.key.equals(o2.key) && o1.expireAt == o2.expireAt && o1.getContexts().equals(o2.getContexts()); } @@ -199,7 +199,7 @@ public abstract class AbstractNode, B extends NodeBui @Override public boolean areEqual(@NonNull AbstractNode o1, @NonNull AbstractNode o2) { return o1 == o2 || - o1.key == o2.key && + o1.key.equals(o2.key) && o1.value == o2.value && o1.hasExpiry() == o2.hasExpiry() && o1.getContexts().equals(o2.getContexts()); @@ -209,7 +209,7 @@ public abstract class AbstractNode, B extends NodeBui @Override public boolean areEqual(@NonNull AbstractNode o1, @NonNull AbstractNode o2) { return o1 == o2 || - o1.key == o2.key && + o1.key.equals(o2.key) && o1.hasExpiry() == o2.hasExpiry() && o1.getContexts().equals(o2.getContexts()); } @@ -218,7 +218,7 @@ public abstract class AbstractNode, B extends NodeBui @Override public boolean areEqual(@NonNull AbstractNode o1, @NonNull AbstractNode o2) { return o1 == o2 || - o1.key == o2.key && + o1.key.equals(o2.key) && o1.getContexts().equals(o2.getContexts()); } }; diff --git a/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeFactory.java b/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeFactory.java index ee262d13f..eb6b99235 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeFactory.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.common.node.factory; -import me.lucko.luckperms.api.context.ContextSet; +import me.lucko.luckperms.api.context.Context; import me.lucko.luckperms.api.context.DefaultContextKeys; import me.lucko.luckperms.api.node.ChatMetaType; import me.lucko.luckperms.api.node.Node; @@ -36,8 +36,6 @@ import me.lucko.luckperms.api.node.types.MetaNode; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.HolderType; -import java.util.Map; - /** * Utility class to make Node(Builder) instances from strings or existing Nodes */ @@ -118,90 +116,10 @@ public final class NodeFactory { return builder(node).value(value).build(); } - public static Node make(String node, boolean value, String server) { - return builder(node).value(value).withContext(DefaultContextKeys.SERVER_KEY, server).build(); - } - public static Node make(String node, boolean value, String server, String world) { return builder(node).value(value).withContext(DefaultContextKeys.SERVER_KEY, server).withContext(DefaultContextKeys.WORLD_KEY, world).build(); } - public static Node make(String node, String server) { - return builder(node).withContext(DefaultContextKeys.SERVER_KEY, server).build(); - } - - public static Node make(String node, String server, String world) { - return builder(node).withContext(DefaultContextKeys.SERVER_KEY, server).withContext(DefaultContextKeys.WORLD_KEY, world).build(); - } - - public static Node make(String node, boolean value, boolean temporary) { - return builder(node).value(value).expiry(temporary ? 10L : 0L).build(); - } - - public static Node make(String node, boolean value, String server, boolean temporary) { - return builder(node).value(value).withContext(DefaultContextKeys.SERVER_KEY, server).expiry(temporary ? 10L : 0L).build(); - } - - public static Node make(String node, boolean value, String server, String world, boolean temporary) { - return builder(node).value(value).withContext(DefaultContextKeys.SERVER_KEY, server).withContext(DefaultContextKeys.WORLD_KEY, world).expiry(temporary ? 10L : 0L).build(); - } - - public static Node make(String node, String server, boolean temporary) { - return builder(node).withContext(DefaultContextKeys.SERVER_KEY, server).expiry(temporary ? 10L : 0L).build(); - } - - public static Node make(String node, String server, String world, boolean temporary) { - return builder(node).withContext(DefaultContextKeys.SERVER_KEY, server).withContext(DefaultContextKeys.WORLD_KEY, world).expiry(temporary ? 10L : 0L).build(); - } - - public static Node make(String node, boolean value, long expireAt) { - return builder(node).value(value).expiry(expireAt).build(); - } - - public static Node make(String node, boolean value, String server, long expireAt) { - return builder(node).value(value).withContext(DefaultContextKeys.SERVER_KEY, server).expiry(expireAt).build(); - } - - public static Node make(String node, boolean value, String server, String world, long expireAt) { - return builder(node).value(value).withContext(DefaultContextKeys.SERVER_KEY, server).withContext(DefaultContextKeys.WORLD_KEY, world).expiry(expireAt).build(); - } - - public static Node make(Group group, long expireAt) { - return NodeFactory.make(groupNode(group.getName()), true, expireAt); - } - - public static Node make(Group group, String server, long expireAt) { - return NodeFactory.make(groupNode(group.getName()), true, server, expireAt); - } - - public static Node make(Group group, String server, String world, long expireAt) { - return NodeFactory.make(groupNode(group.getName()), true, server, world, expireAt); - } - - public static Node make(Group group) { - return make(groupNode(group.getName())); - } - - public static Node make(Group group, boolean temporary) { - return make(groupNode(group.getName()), temporary); - } - - public static Node make(Group group, String server) { - return make(groupNode(group.getName()), server); - } - - public static Node make(Group group, String server, String world) { - return make(groupNode(group.getName()), server, world); - } - - public static Node make(Group group, String server, boolean temporary) { - return make(groupNode(group.getName()), server, temporary); - } - - public static Node make(Group group, String server, String world, boolean temporary) { - return make(groupNode(group.getName()), server, world, temporary); - } - public static String nodeAsCommand(Node node, String id, HolderType type, boolean set, boolean explicitGlobalContext) { StringBuilder sb = new StringBuilder(32); sb.append(type.toString()).append(" ").append(id).append(" "); @@ -344,8 +262,7 @@ public final class NodeFactory { return sb; } - ContextSet contexts = node.getContexts(); - for (Map.Entry context : contexts) { + for (Context context : node.getContexts()) { sb.append(" ").append(context.getKey()).append("=").append(context.getValue()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java index 6831a006e..b10ee4f95 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java @@ -38,6 +38,7 @@ import com.mongodb.client.model.Filters; import com.mongodb.client.model.ReplaceOptions; import me.lucko.luckperms.api.actionlog.Action; +import me.lucko.luckperms.api.context.Context; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.api.context.MutableContextSet; @@ -45,8 +46,8 @@ import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.model.PlayerSaveResult; import me.lucko.luckperms.api.node.HeldNode; import me.lucko.luckperms.api.node.Node; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; import me.lucko.luckperms.common.actionlog.Log; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.bulkupdate.BulkUpdate; import me.lucko.luckperms.common.bulkupdate.comparison.Constraint; import me.lucko.luckperms.common.model.Group; @@ -65,6 +66,7 @@ import me.lucko.luckperms.common.storage.misc.StorageCredentials; import org.bson.Document; +import java.time.Instant; import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedHashMap; @@ -165,15 +167,15 @@ public class MongoStorage implements StorageImplementation { public void logAction(Action entry) { MongoCollection c = this.database.getCollection(this.prefix + "action"); Document doc = new Document() - .append("timestamp", entry.getTimestamp()) - .append("actor", entry.getActor()) - .append("actorName", entry.getActorName()) - .append("type", Character.toString(entry.getType().getCode())) - .append("actedName", entry.getActedName()) - .append("action", entry.getAction()); + .append("timestamp", entry.getTimestamp().getEpochSecond()) + .append("actor", entry.getSource().getUniqueId()) + .append("actorName", entry.getSource().getName()) + .append("type", Character.toString(LoggedAction.getTypeCharacter(entry.getTarget().getType()))) + .append("actedName", entry.getTarget().getName()) + .append("action", entry.getDescription()); - if (entry.getActed().isPresent()) { - doc.append("acted", entry.getActed().get()); + if (entry.getTarget().getUniqueId().isPresent()) { + doc.append("acted", entry.getTarget().getUniqueId().get()); } c.insertOne(doc); @@ -192,14 +194,14 @@ public class MongoStorage implements StorageImplementation { actedUuid = d.get("acted", UUID.class); } - ExtendedLogEntry e = ExtendedLogEntry.build() - .timestamp(d.getLong("timestamp")) - .actor(d.get("actor", UUID.class)) - .actorName(d.getString("actorName")) - .type(Action.Type.valueOf(d.getString("type").charAt(0))) - .acted(actedUuid) - .actedName(d.getString("actedName")) - .action(d.getString("action")) + LoggedAction e = LoggedAction.build() + .timestamp(Instant.ofEpochSecond(d.getLong("timestamp"))) + .source(d.get("actor", UUID.class)) + .sourceName(d.getString("actorName")) + .targetType(LoggedAction.parseTypeCharacter(d.getString("type").charAt(0))) + .target(actedUuid) + .targetName(d.getString("actedName")) + .description(d.getString("action")) .build(); log.add(e); @@ -725,8 +727,8 @@ public class MongoStorage implements StorageImplementation { } private static List contextSetToDocs(ContextSet contextSet) { - List contexts = new ArrayList<>(); - for (Map.Entry e : contextSet.toSet()) { + List contexts = new ArrayList<>(contextSet.size()); + for (Context e : contextSet) { contexts.add(new Document().append("key", e.getKey()).append("value", e.getValue())); } return contexts; diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java index 8f5ba44e4..4082fb7c7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java @@ -33,8 +33,8 @@ import me.lucko.luckperms.api.model.DataType; import me.lucko.luckperms.api.model.PlayerSaveResult; import me.lucko.luckperms.api.node.HeldNode; import me.lucko.luckperms.api.node.Node; -import me.lucko.luckperms.common.actionlog.ExtendedLogEntry; import me.lucko.luckperms.common.actionlog.Log; +import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.bulkupdate.BulkUpdate; import me.lucko.luckperms.common.bulkupdate.PreparedStatementBuilder; import me.lucko.luckperms.common.bulkupdate.comparison.Constraint; @@ -67,6 +67,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.time.Instant; import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedList; @@ -266,13 +267,13 @@ public class SqlStorage implements StorageImplementation { public void logAction(Action entry) throws SQLException { try (Connection c = this.connectionFactory.getConnection()) { try (PreparedStatement ps = c.prepareStatement(this.statementProcessor.apply(ACTION_INSERT))) { - ps.setLong(1, entry.getTimestamp()); - ps.setString(2, entry.getActor().toString()); - ps.setString(3, entry.getActorName()); - ps.setString(4, Character.toString(entry.getType().getCode())); - ps.setString(5, entry.getActed().map(UUID::toString).orElse("null")); - ps.setString(6, entry.getActedName()); - ps.setString(7, entry.getAction()); + ps.setLong(1, entry.getTimestamp().getEpochSecond()); + ps.setString(2, entry.getSource().getUniqueId().toString()); + ps.setString(3, entry.getSource().getName()); + ps.setString(4, Character.toString(LoggedAction.getTypeCharacter(entry.getTarget().getType()))); + ps.setString(5, entry.getTarget().getUniqueId().map(UUID::toString).orElse("null")); + ps.setString(6, entry.getTarget().getName()); + ps.setString(7, entry.getDescription()); ps.execute(); } } @@ -286,14 +287,14 @@ public class SqlStorage implements StorageImplementation { try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { final String actedUuid = rs.getString("acted_uuid"); - ExtendedLogEntry e = ExtendedLogEntry.build() - .timestamp(rs.getLong("time")) - .actor(UUID.fromString(rs.getString("actor_uuid"))) - .actorName(rs.getString("actor_name")) - .type(Action.Type.valueOf(rs.getString("type").toCharArray()[0])) - .acted(actedUuid.equals("null") ? null : UUID.fromString(actedUuid)) - .actedName(rs.getString("acted_name")) - .action(rs.getString("action")) + LoggedAction e = LoggedAction.build() + .timestamp(Instant.ofEpochSecond(rs.getLong("time"))) + .source(UUID.fromString(rs.getString("actor_uuid"))) + .sourceName(rs.getString("actor_name")) + .targetType(LoggedAction.parseTypeCharacter(rs.getString("type").toCharArray()[0])) + .target(actedUuid.equals("null") ? null : UUID.fromString(actedUuid)) + .targetName(rs.getString("acted_name")) + .description(rs.getString("action")) .build(); log.add(e); diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/event/VerboseEvent.java b/common/src/main/java/me/lucko/luckperms/common/verbose/event/VerboseEvent.java index dd8a56d03..1b92bef66 100644 --- a/common/src/main/java/me/lucko/luckperms/common/verbose/event/VerboseEvent.java +++ b/common/src/main/java/me/lucko/luckperms/common/verbose/event/VerboseEvent.java @@ -27,13 +27,13 @@ package me.lucko.luckperms.common.verbose.event; import com.google.gson.JsonObject; +import me.lucko.luckperms.api.context.Context; import me.lucko.luckperms.api.query.QueryMode; import me.lucko.luckperms.api.query.QueryOptions; import me.lucko.luckperms.common.util.StackTracePrinter; import me.lucko.luckperms.common.util.gson.JArray; import me.lucko.luckperms.common.util.gson.JObject; -import java.util.Map; import java.util.Objects; /** @@ -86,7 +86,7 @@ public abstract class VerboseEvent { if (this.checkQueryOptions.mode() == QueryMode.CONTEXTUAL) { obj.add("context", new JArray() .consume(arr -> { - for (Map.Entry contextPair : Objects.requireNonNull(this.checkQueryOptions.context())) { + for (Context contextPair : Objects.requireNonNull(this.checkQueryOptions.context())) { arr.add(new JObject().add("key", contextPair.getKey()).add("value", contextPair.getValue())); } }) diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/WorldCalculator.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/WorldCalculator.java index 18e29497f..5c7413ed7 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/WorldCalculator.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/WorldCalculator.java @@ -46,7 +46,7 @@ public class WorldCalculator implements ContextCalculator { } @Override - public void giveApplicableContext(@NonNull Player subject, @NonNull ContextConsumer consumer) { + public void calculate(@NonNull Player subject, @NonNull ContextConsumer consumer) { Set seen = new HashSet<>(); String world = subject.getLevel().getName().toLowerCase(); while (seen.add(world)) { diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java index 5dde8f0a7..18bebbd9c 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java @@ -30,11 +30,13 @@ import com.google.common.collect.ImmutableSet; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.api.node.Tristate; +import me.lucko.luckperms.common.context.contextset.ContextImpl; import me.lucko.luckperms.sponge.service.context.DelegatingContextSet; import me.lucko.luckperms.sponge.service.context.DelegatingImmutableContextSet; import org.spongepowered.api.service.context.Context; +import java.util.Map; import java.util.Objects; import java.util.Set; @@ -57,7 +59,11 @@ public final class CompatibilityUtil { return ImmutableContextSet.empty(); } - return ImmutableContextSet.fromEntries(contexts); + ImmutableContextSet.Builder builder = ImmutableContextSet.builder(); + for (Map.Entry entry : contexts) { + builder.add(new ContextImpl(entry.getKey(), entry.getValue())); + } + return builder.build(); } public static Set convertContexts(ContextSet contexts) { diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/AbstractDelegatingContextSet.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/AbstractDelegatingContextSet.java index 6351ded79..1507b0d13 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/AbstractDelegatingContextSet.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/AbstractDelegatingContextSet.java @@ -46,7 +46,7 @@ abstract class AbstractDelegatingContextSet extends AbstractSet impleme public boolean contains(Object o) { if (o instanceof Context) { Context context = (Context) o; - return !context.getKey().isEmpty() && !context.getValue().isEmpty() && getDelegate().contains(context); + return !context.getKey().isEmpty() && !context.getValue().isEmpty() && getDelegate().contains(context.getKey(), context.getValue()); } return false; } diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingImmutableContextSet.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingImmutableContextSet.java index 00b284c56..6f8a06e98 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingImmutableContextSet.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingImmutableContextSet.java @@ -31,7 +31,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.service.context.Context; import java.util.Iterator; -import java.util.Map; import java.util.Set; /** @@ -75,7 +74,7 @@ public class DelegatingImmutableContextSet extends AbstractDelegatingContextSet } private final class ContextSetIterator implements Iterator { - private final Iterator> it = DelegatingImmutableContextSet.this.delegate.iterator(); + private final Iterator it = DelegatingImmutableContextSet.this.delegate.iterator(); @Override public boolean hasNext() { @@ -84,7 +83,7 @@ public class DelegatingImmutableContextSet extends AbstractDelegatingContextSet @Override public Context next() { - Map.Entry next = this.it.next(); + me.lucko.luckperms.api.context.Context next = this.it.next(); return new Context(next.getKey(), next.getValue()); } diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingMutableContextSet.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingMutableContextSet.java index 13154c48b..bce6d5cea 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingMutableContextSet.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/context/DelegatingMutableContextSet.java @@ -26,12 +26,12 @@ package me.lucko.luckperms.sponge.service.context; import me.lucko.luckperms.api.context.MutableContextSet; +import me.lucko.luckperms.common.context.contextset.ContextImpl; import org.checkerframework.checker.nullness.qual.NonNull; import org.spongepowered.api.service.context.Context; import java.util.Iterator; -import java.util.Map; import java.util.Set; /** @@ -63,8 +63,8 @@ public class DelegatingMutableContextSet extends AbstractDelegatingContextSet { return false; } - boolean has = this.delegate.contains(context); - this.delegate.add(context); + boolean has = this.delegate.contains(context.getKey(), context.getValue()); + this.delegate.add(new ContextImpl(context.getKey(), context.getValue())); return !has; } @@ -75,7 +75,7 @@ public class DelegatingMutableContextSet extends AbstractDelegatingContextSet { if (context.getKey().isEmpty() || context.getValue().isEmpty()) { return false; } - boolean had = this.delegate.contains(context); + boolean had = this.delegate.contains(context.getKey(), context.getValue()); this.delegate.remove(context.getKey(), context.getValue()); return had; } @@ -94,7 +94,7 @@ public class DelegatingMutableContextSet extends AbstractDelegatingContextSet { } private final class ContextSetIterator implements Iterator { - private final Iterator> it = DelegatingMutableContextSet.this.delegate.iterator(); + private final Iterator it = DelegatingMutableContextSet.this.delegate.iterator(); private Context current; @Override @@ -104,7 +104,7 @@ public class DelegatingMutableContextSet extends AbstractDelegatingContextSet { @Override public Context next() { - Map.Entry next = this.it.next(); + me.lucko.luckperms.api.context.Context next = this.it.next(); // track the iterators cursor to handle #remove calls this.current = new Context(next.getKey(), next.getValue()); diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongeProxiedContextCalculator.java b/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongeProxiedContextCalculator.java index c752d979d..720325b29 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongeProxiedContextCalculator.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongeProxiedContextCalculator.java @@ -45,7 +45,7 @@ public class SpongeProxiedContextCalculator implements ProxiedContextCalculator< } @Override - public void giveApplicableContext(@NonNull Subject subject, @NonNull ContextConsumer consumer) { + public void calculate(@NonNull Subject subject, @NonNull ContextConsumer consumer) { this.delegate.accumulateContexts(subject, new ProxiedContextSet(consumer)); } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/context/WorldCalculator.java b/sponge/src/main/java/me/lucko/luckperms/sponge/context/WorldCalculator.java index a2ef62dce..6c2cf6f04 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/context/WorldCalculator.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/context/WorldCalculator.java @@ -47,7 +47,7 @@ public class WorldCalculator implements ContextCalculator { } @Override - public void giveApplicableContext(@NonNull Subject subject, @NonNull ContextConsumer consumer) { + public void calculate(@NonNull Subject subject, @NonNull ContextConsumer consumer) { CommandSource source = subject.getCommandSource().orElse(null); if (source == null || !(source instanceof Player)) { return; diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/context/BackendServerCalculator.java b/velocity/src/main/java/me/lucko/luckperms/velocity/context/BackendServerCalculator.java index 6e1efd9b5..a356365b5 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/context/BackendServerCalculator.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/context/BackendServerCalculator.java @@ -51,7 +51,7 @@ public class BackendServerCalculator implements ContextCalculator { } @Override - public void giveApplicableContext(@NonNull Player subject, @NonNull ContextConsumer consumer) { + public void calculate(@NonNull Player subject, @NonNull ContextConsumer consumer) { Set seen = new HashSet<>(); String server = getServer(subject); while (server != null && seen.add(server)) {