mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-27 13:15:44 +01:00
Context & action log changes
This commit is contained in:
parent
5b97d01363
commit
bafada4f17
24
.gitignore
vendored
24
.gitignore
vendored
@ -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
|
||||
|
@ -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<Action> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* <p>This is the players uuid in most cases.</p>
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* <p>Will only return a value for {@link Type#USER} entries.</p>
|
||||
*
|
||||
* @return the uuid of acted object
|
||||
*/
|
||||
@NonNull Optional<UUID> 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<Action> {
|
||||
*
|
||||
* @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<UUID> 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<Action> {
|
||||
* @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.
|
||||
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.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();
|
||||
|
||||
}
|
@ -92,6 +92,6 @@ public interface ContextCalculator<T> {
|
||||
* @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);
|
||||
|
||||
}
|
||||
|
@ -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<String, String> entry : contextSet) {
|
||||
accept(entry.getKey(), entry.getValue());
|
||||
for (Context entry : contextSet) {
|
||||
accept(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.</p>
|
||||
*/
|
||||
public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
||||
public interface ContextSet extends Iterable<Context> {
|
||||
|
||||
/**
|
||||
* Gets if this {@link ContextSet} is immutable.
|
||||
@ -89,7 +89,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
||||
@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}.
|
||||
*
|
||||
* <p>The returned set is immutable, and is a copy of the current set.
|
||||
@ -97,7 +97,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
||||
*
|
||||
* @return an immutable set
|
||||
*/
|
||||
@NonNull Set<Map.Entry<String, String>> toSet();
|
||||
@NonNull Set<Context> toSet();
|
||||
|
||||
/**
|
||||
* Returns a {@link Map} representing the current state of this
|
||||
@ -137,7 +137,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
||||
* @return an iterator
|
||||
*/
|
||||
@Override
|
||||
@NonNull Iterator<Map.Entry<String, String>> iterator();
|
||||
@NonNull Iterator<Context> iterator();
|
||||
|
||||
/**
|
||||
* Returns if the {@link ContextSet} contains at least one value for the
|
||||
@ -191,7 +191,7 @@ public interface ContextSet extends Iterable<Map.Entry<String, String>> {
|
||||
* @return true if the set contains the context pair
|
||||
* @throws NullPointerException if the key or value is null
|
||||
*/
|
||||
default boolean contains(Map.@NonNull Entry<String, String> 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<Map.Entry<String, String>> {
|
||||
* @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<String, String> context : toSet()) {
|
||||
if (!other.contains(context)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
boolean isSatisfiedBy(@NonNull ContextSet other);
|
||||
|
||||
/**
|
||||
* Returns if the {@link ContextSet} is empty.
|
||||
|
@ -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();
|
||||
|
@ -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<? extends Map.Entry<String, String>> iterable) {
|
||||
Objects.requireNonNull(iterable, "iterable");
|
||||
Builder builder = builder();
|
||||
for (Map.Entry<String, String> entry : iterable) {
|
||||
builder.add(entry);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an new {@link ImmutableContextSet} from an existing {@link Set}.
|
||||
*
|
||||
* <p>Only really useful for converting between mutable and immutable types.</p>
|
||||
*
|
||||
* @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<String, String> 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<? extends Map.Entry<String, String>> iterable) {
|
||||
for (Map.Entry<String, String> e : Objects.requireNonNull(iterable, "iterable")) {
|
||||
default @NonNull Builder addAll(@NonNull Iterable<Context> iterable) {
|
||||
for (Context e : Objects.requireNonNull(iterable, "iterable")) {
|
||||
add(e);
|
||||
}
|
||||
return this;
|
||||
|
@ -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<? extends Map.Entry<String, String>> iterable) {
|
||||
Objects.requireNonNull(iterable, "iterable");
|
||||
MutableContextSet set = create();
|
||||
set.addAll(iterable);
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link MutableContextSet} from an existing {@link Set}.
|
||||
*
|
||||
* <p>Only really useful for converting between mutable and immutable types.</p>
|
||||
*
|
||||
* @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<String, String> 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<? extends Map.Entry<String, String>> iterable) {
|
||||
for (Map.Entry<String, String> e : Objects.requireNonNull(iterable, "iterable")) {
|
||||
default void addAll(@NonNull Iterable<Context> iterable) {
|
||||
for (Context e : Objects.requireNonNull(iterable, "iterable")) {
|
||||
add(e);
|
||||
}
|
||||
}
|
||||
|
@ -66,10 +66,10 @@ public interface StaticContextCalculator extends ContextCalculator<Object> {
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class WorldCalculator implements ContextCalculator<Player> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveApplicableContext(@NonNull Player subject, @NonNull ContextConsumer consumer) {
|
||||
public void calculate(@NonNull Player subject, @NonNull ContextConsumer consumer) {
|
||||
Set<String> seen = new HashSet<>();
|
||||
String world = subject.getWorld().getName().toLowerCase();
|
||||
while (seen.add(world)) {
|
||||
|
@ -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;
|
||||
|
@ -51,7 +51,7 @@ public class BackendServerCalculator implements ContextCalculator<ProxiedPlayer>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveApplicableContext(@NonNull ProxiedPlayer subject, @NonNull ContextConsumer consumer) {
|
||||
public void calculate(@NonNull ProxiedPlayer subject, @NonNull ContextConsumer consumer) {
|
||||
Set<String> seen = new HashSet<>();
|
||||
String server = getServer(subject);
|
||||
while (server != null && seen.add(server)) {
|
||||
|
@ -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());
|
||||
|
@ -1,330 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.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<Action> 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<UUID> 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<String> 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<String, String> 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 + ")";
|
||||
}
|
||||
}
|
||||
}
|
@ -50,53 +50,53 @@ public class Log {
|
||||
return empty;
|
||||
}
|
||||
|
||||
private final SortedSet<ExtendedLogEntry> content;
|
||||
private final SortedSet<LoggedAction> content;
|
||||
|
||||
public Log(SortedSet<ExtendedLogEntry> content) {
|
||||
public Log(SortedSet<LoggedAction> content) {
|
||||
this.content = ImmutableSortedSet.copyOfSorted(content);
|
||||
}
|
||||
|
||||
public SortedSet<ExtendedLogEntry> getContent() {
|
||||
public SortedSet<LoggedAction> getContent() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
public SortedSet<ExtendedLogEntry> getContent(UUID actor) {
|
||||
public SortedSet<LoggedAction> 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<ExtendedLogEntry> getUserHistory(UUID uuid) {
|
||||
public SortedSet<LoggedAction> 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<ExtendedLogEntry> getGroupHistory(String name) {
|
||||
public SortedSet<LoggedAction> 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<ExtendedLogEntry> getTrackHistory(String name) {
|
||||
public SortedSet<LoggedAction> 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<ExtendedLogEntry> getSearch(String query) {
|
||||
public SortedSet<LoggedAction> getSearch(String query) {
|
||||
return this.content.stream()
|
||||
.filter(e -> e.matchesSearch(query))
|
||||
.collect(ImmutableCollectors.toSortedSet(Comparator.naturalOrder()));
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final SortedSet<ExtendedLogEntry> content = new TreeSet<>();
|
||||
private final SortedSet<LoggedAction> content = new TreeSet<>();
|
||||
|
||||
public Builder add(ExtendedLogEntry e) {
|
||||
public Builder add(LoggedAction e) {
|
||||
this.content.add(e);
|
||||
return this;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -0,0 +1,413 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.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<Action> COMPARATOR = Comparator
|
||||
.<Action>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<UUID> 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<String> 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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<Void> 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<Void> 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());
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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<String, String> 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) {
|
||||
|
@ -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<String, String> 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<String, String> 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));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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<T extends PermissionHolder> extends SubCommand<T> {
|
||||
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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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<Group> {
|
||||
|
||||
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);
|
||||
|
@ -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<Group> {
|
||||
|
||||
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);
|
||||
|
@ -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<Group> {
|
||||
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<Group> {
|
||||
|
||||
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);
|
||||
|
@ -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<Group> {
|
||||
|
||||
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);
|
||||
|
@ -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<Log> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Paginated<ExtendedLogEntry> content = new Paginated<>(log.getGroupHistory(group));
|
||||
Paginated<LoggedAction> 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<Log> {
|
||||
}
|
||||
}
|
||||
|
||||
private static CommandResult showLog(int page, Sender sender, Paginated<ExtendedLogEntry> log) {
|
||||
private static CommandResult showLog(int page, Sender sender, Paginated<LoggedAction> 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<Log> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
SortedMap<Integer, ExtendedLogEntry> entries = log.getPage(page, ENTRIES_PER_PAGE);
|
||||
String name = entries.values().stream().findAny().get().getActedName();
|
||||
SortedMap<Integer, LoggedAction> 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<Integer, ExtendedLogEntry> e : entries.entrySet()) {
|
||||
long time = e.getValue().getTimestamp();
|
||||
for (Map.Entry<Integer, LoggedAction> 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()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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<Log> {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Log log, List<String> args, String label) {
|
||||
if (args.isEmpty()) {
|
||||
// No page or user
|
||||
Paginated<ExtendedLogEntry> content = new Paginated<>(log.getContent());
|
||||
Paginated<LoggedAction> 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<ExtendedLogEntry> content = new Paginated<>(log.getContent());
|
||||
Paginated<LoggedAction> content = new Paginated<>(log.getContent());
|
||||
return showLog(page, false, sender, content);
|
||||
}
|
||||
|
||||
@ -72,7 +73,7 @@ public class LogRecent extends SubCommand<Log> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Paginated<ExtendedLogEntry> content = new Paginated<>(log.getContent(uuid));
|
||||
Paginated<LoggedAction> 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<Log> {
|
||||
}
|
||||
}
|
||||
|
||||
private static CommandResult showLog(int page, boolean specificUser, Sender sender, Paginated<ExtendedLogEntry> log) {
|
||||
private static CommandResult showLog(int page, boolean specificUser, Sender sender, Paginated<LoggedAction> 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<Log> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
SortedMap<Integer, ExtendedLogEntry> entries = log.getPage(page, ENTRIES_PER_PAGE);
|
||||
SortedMap<Integer, LoggedAction> 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<Log> {
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis() / 1000L;
|
||||
for (Map.Entry<Integer, ExtendedLogEntry> e : entries.entrySet()) {
|
||||
long time = e.getValue().getTimestamp();
|
||||
for (Map.Entry<Integer, LoggedAction> 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;
|
||||
|
@ -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<Log> {
|
||||
}
|
||||
|
||||
final String query = String.join(" ", args);
|
||||
Paginated<ExtendedLogEntry> content = new Paginated<>(log.getSearch(query));
|
||||
Paginated<LoggedAction> 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<Log> {
|
||||
}
|
||||
}
|
||||
|
||||
private static CommandResult showLog(int page, String query, Sender sender, Paginated<ExtendedLogEntry> log) {
|
||||
private static CommandResult showLog(int page, String query, Sender sender, Paginated<LoggedAction> 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<Log> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
SortedMap<Integer, ExtendedLogEntry> entries = log.getPage(page, ENTRIES_PER_PAGE);
|
||||
SortedMap<Integer, LoggedAction> entries = log.getPage(page, ENTRIES_PER_PAGE);
|
||||
Message.LOG_SEARCH_HEADER.send(sender, query, page, maxPage);
|
||||
|
||||
long now = System.currentTimeMillis() / 1000L;
|
||||
for (Map.Entry<Integer, ExtendedLogEntry> e : entries.entrySet()) {
|
||||
long time = e.getValue().getTimestamp();
|
||||
for (Map.Entry<Integer, LoggedAction> 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()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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<Log> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Paginated<ExtendedLogEntry> content = new Paginated<>(log.getTrackHistory(track));
|
||||
Paginated<LoggedAction> 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<Log> {
|
||||
}
|
||||
}
|
||||
|
||||
private static CommandResult showLog(int page, Sender sender, Paginated<ExtendedLogEntry> log) {
|
||||
private static CommandResult showLog(int page, Sender sender, Paginated<LoggedAction> 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<Log> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
SortedMap<Integer, ExtendedLogEntry> entries = log.getPage(page, ENTRIES_PER_PAGE);
|
||||
String name = entries.values().stream().findAny().get().getActedName();
|
||||
SortedMap<Integer, LoggedAction> 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<Integer, ExtendedLogEntry> e : entries.entrySet()) {
|
||||
long time = e.getValue().getTimestamp();
|
||||
for (Map.Entry<Integer, LoggedAction> 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()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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<Log> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Paginated<ExtendedLogEntry> content = new Paginated<>(log.getUserHistory(uuid));
|
||||
Paginated<LoggedAction> 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<Log> {
|
||||
}
|
||||
}
|
||||
|
||||
private static CommandResult showLog(int page, Sender sender, Paginated<ExtendedLogEntry> log) {
|
||||
private static CommandResult showLog(int page, Sender sender, Paginated<LoggedAction> 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<Log> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
SortedMap<Integer, ExtendedLogEntry> entries = log.getPage(page, ENTRIES_PER_PAGE);
|
||||
String name = entries.values().stream().findAny().get().getActedName();
|
||||
SortedMap<Integer, LoggedAction> 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<Integer, ExtendedLogEntry> e : entries.entrySet()) {
|
||||
long time = e.getValue().getTimestamp();
|
||||
for (Map.Entry<Integer, LoggedAction> 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()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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<Track> {
|
||||
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);
|
||||
|
@ -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> {
|
||||
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);
|
||||
|
@ -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<Track> {
|
||||
|
||||
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);
|
||||
|
@ -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<Track> {
|
||||
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);
|
||||
|
@ -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<Track> {
|
||||
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);
|
||||
|
@ -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<Track> {
|
||||
|
||||
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);
|
||||
|
@ -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<User> {
|
||||
|
||||
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);
|
||||
|
@ -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<User> {
|
||||
|
||||
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<User> {
|
||||
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);
|
||||
|
@ -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<User> {
|
||||
|
||||
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<User> {
|
||||
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);
|
||||
|
@ -122,7 +122,7 @@ public abstract class ContextManager<T> {
|
||||
|
||||
for (ContextCalculator<? super T> 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<T> {
|
||||
|
||||
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();
|
||||
|
@ -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<ImmutableContextSet> {
|
||||
|
||||
@ -73,18 +73,18 @@ public class ContextSetComparator implements Comparator<ImmutableContextSet> {
|
||||
|
||||
// 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<Map.Entry<String, String>> o1Entries = new ArrayList<>(o1.toSet());
|
||||
List<Map.Entry<String, String>> o2Entries = new ArrayList<>(o2.toSet());
|
||||
List<Context> o1Entries = new ArrayList<>(o1.toSet());
|
||||
List<Context> o2Entries = new ArrayList<>(o2.toSet());
|
||||
o1Entries.sort(STRING_ENTRY_COMPARATOR);
|
||||
o2Entries.sort(STRING_ENTRY_COMPARATOR);
|
||||
|
||||
// size is definitely the same
|
||||
Iterator<Map.Entry<String, String>> it1 = o1Entries.iterator();
|
||||
Iterator<Map.Entry<String, String>> it2 = o2Entries.iterator();
|
||||
Iterator<Context> it1 = o1Entries.iterator();
|
||||
Iterator<Context> it2 = o2Entries.iterator();
|
||||
|
||||
while (it1.hasNext()) {
|
||||
Map.Entry<String, String> ent1 = it1.next();
|
||||
Map.Entry<String, String> 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<ImmutableContextSet> {
|
||||
@SuppressWarnings("StringEquality")
|
||||
private static final Comparator<String> FAST_STRING_COMPARATOR = (o1, o2) -> o1 == o2 ? 0 : o1.compareTo(o2);
|
||||
|
||||
private static final Comparator<Map.Entry<String, String>> STRING_ENTRY_COMPARATOR = (o1, o2) -> {
|
||||
private static final Comparator<Context> STRING_ENTRY_COMPARATOR = (o1, o2) -> {
|
||||
if (o1 == o2) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.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();
|
||||
}
|
||||
}
|
@ -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<String, String> map;
|
||||
private final int hashCode;
|
||||
|
||||
@ -94,8 +88,13 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Set<Map.Entry<String, String>> toSet() {
|
||||
return this.map.entries();
|
||||
public @NonNull Set<Context> toSet() {
|
||||
ImmutableSet.Builder<Context> builder = ImmutableSet.builder();
|
||||
Set<Map.Entry<String, String>> entries = this.map.entries();
|
||||
for (Map.Entry<String, String> 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<Map.Entry<String, String>> iterator() {
|
||||
return this.map.entries().iterator();
|
||||
private ImmutableList<Context> toList() {
|
||||
Set<Map.Entry<String, String>> entries = this.map.entries();
|
||||
Context[] array = new Context[entries.size()];
|
||||
int i = 0;
|
||||
for (Map.Entry<String, String> e : entries) {
|
||||
array[i++] = new ContextImpl(e.getKey(), e.getValue());
|
||||
}
|
||||
return ImmutableList.copyOf(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spliterator<Map.Entry<String, String>> spliterator() {
|
||||
return this.map.entries().spliterator();
|
||||
public @NonNull Iterator<Context> iterator() {
|
||||
return toList().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spliterator<Context> 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<Map.Entry<String, String>> entries = this.map.entries();
|
||||
for (Map.Entry<String, String> 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<String, Set<String>> thatMap = that.toMap();
|
||||
ImmutableSetMultimap.Builder<String, String> thatBuilder = ImmutableSetMultimap.builder();
|
||||
for (Map.Entry<String, Set<String>> e : thatMap.entrySet()) {
|
||||
thatBuilder.putAll(e.getKey(), e.getValue());
|
||||
}
|
||||
thatBacking = thatBuilder.build();
|
||||
}
|
||||
|
||||
return backing().equals(thatBacking);
|
||||
|
@ -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<Map.Entry<String, String>> toSet() {
|
||||
// map.entries() returns immutable Map.Entry instances, so we can just call copyOf
|
||||
return ImmutableSet.copyOf(this.map.entries());
|
||||
public @NonNull ImmutableSet<Context> toSet() {
|
||||
ImmutableSet.Builder<Context> builder = ImmutableSet.builder();
|
||||
Set<Map.Entry<String, String>> entries = this.map.entries();
|
||||
synchronized (this.map) {
|
||||
for (Map.Entry<String, String> 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<Map.Entry<String, String>> iterator() {
|
||||
return toSet().iterator();
|
||||
private ImmutableList<Context> toList() {
|
||||
Set<Map.Entry<String, String>> entries = this.map.entries();
|
||||
Context[] array;
|
||||
synchronized (this.map) {
|
||||
array = new Context[entries.size()];
|
||||
int i = 0;
|
||||
for (Map.Entry<String, String> e : entries) {
|
||||
array[i++] = new ContextImpl(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
return ImmutableList.copyOf(array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spliterator<Map.Entry<String, String>> spliterator() {
|
||||
return toSet().spliterator();
|
||||
public @NonNull Iterator<Context> iterator() {
|
||||
return toList().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spliterator<Context> 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<Map.Entry<String, String>> entries = this.map.entries();
|
||||
synchronized (this.map) {
|
||||
for (Map.Entry<String, String> 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<String, Set<String>> thatMap = that.toMap();
|
||||
ImmutableSetMultimap.Builder<String, String> thatBuilder = ImmutableSetMultimap.builder();
|
||||
for (Map.Entry<String, Set<String>> e : thatMap.entrySet()) {
|
||||
thatBuilder.putAll(e.getKey(), e.getValue());
|
||||
}
|
||||
thatBacking = thatBuilder.build();
|
||||
}
|
||||
|
||||
return backing().equals(thatBacking);
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ public abstract class AbstractNode<N extends ScopedNode<N, B>, 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<N extends ScopedNode<N, B>, 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<N extends ScopedNode<N, B>, 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<N extends ScopedNode<N, B>, 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<N extends ScopedNode<N, B>, 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());
|
||||
}
|
||||
};
|
||||
|
@ -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<String, String> context : contexts) {
|
||||
for (Context context : node.getContexts()) {
|
||||
sb.append(" ").append(context.getKey()).append("=").append(context.getValue());
|
||||
}
|
||||
|
||||
|
@ -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<Document> 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<Document> contextSetToDocs(ContextSet contextSet) {
|
||||
List<Document> contexts = new ArrayList<>();
|
||||
for (Map.Entry<String, String> e : contextSet.toSet()) {
|
||||
List<Document> contexts = new ArrayList<>(contextSet.size());
|
||||
for (Context e : contextSet) {
|
||||
contexts.add(new Document().append("key", e.getKey()).append("value", e.getValue()));
|
||||
}
|
||||
return contexts;
|
||||
|
@ -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);
|
||||
|
@ -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<String, String> 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()));
|
||||
}
|
||||
})
|
||||
|
@ -46,7 +46,7 @@ public class WorldCalculator implements ContextCalculator<Player> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveApplicableContext(@NonNull Player subject, @NonNull ContextConsumer consumer) {
|
||||
public void calculate(@NonNull Player subject, @NonNull ContextConsumer consumer) {
|
||||
Set<String> seen = new HashSet<>();
|
||||
String world = subject.getLevel().getName().toLowerCase();
|
||||
while (seen.add(world)) {
|
||||
|
@ -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<String, String> entry : contexts) {
|
||||
builder.add(new ContextImpl(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static Set<Context> convertContexts(ContextSet contexts) {
|
||||
|
@ -46,7 +46,7 @@ abstract class AbstractDelegatingContextSet extends AbstractSet<Context> 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;
|
||||
}
|
||||
|
@ -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<Context> {
|
||||
private final Iterator<Map.Entry<String, String>> it = DelegatingImmutableContextSet.this.delegate.iterator();
|
||||
private final Iterator<me.lucko.luckperms.api.context.Context> it = DelegatingImmutableContextSet.this.delegate.iterator();
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
@ -84,7 +83,7 @@ public class DelegatingImmutableContextSet extends AbstractDelegatingContextSet
|
||||
|
||||
@Override
|
||||
public Context next() {
|
||||
Map.Entry<String, String> next = this.it.next();
|
||||
me.lucko.luckperms.api.context.Context next = this.it.next();
|
||||
return new Context(next.getKey(), next.getValue());
|
||||
}
|
||||
|
||||
|
@ -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<Context> {
|
||||
private final Iterator<Map.Entry<String, String>> it = DelegatingMutableContextSet.this.delegate.iterator();
|
||||
private final Iterator<me.lucko.luckperms.api.context.Context> it = DelegatingMutableContextSet.this.delegate.iterator();
|
||||
private Context current;
|
||||
|
||||
@Override
|
||||
@ -104,7 +104,7 @@ public class DelegatingMutableContextSet extends AbstractDelegatingContextSet {
|
||||
|
||||
@Override
|
||||
public Context next() {
|
||||
Map.Entry<String, String> 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());
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class WorldCalculator implements ContextCalculator<Subject> {
|
||||
}
|
||||
|
||||
@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;
|
||||
|
@ -51,7 +51,7 @@ public class BackendServerCalculator implements ContextCalculator<Player> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveApplicableContext(@NonNull Player subject, @NonNull ContextConsumer consumer) {
|
||||
public void calculate(@NonNull Player subject, @NonNull ContextConsumer consumer) {
|
||||
Set<String> seen = new HashSet<>();
|
||||
String server = getServer(subject);
|
||||
while (server != null && seen.add(server)) {
|
||||
|
Loading…
Reference in New Issue
Block a user