mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-27 21:29:47 +01:00
A few more small API changes
This commit is contained in:
parent
213b2fcb44
commit
95d2832884
@ -46,7 +46,6 @@ import net.luckperms.api.track.TrackManager;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@ -207,11 +206,4 @@ public interface LuckPerms {
|
||||
*/
|
||||
void registerMessengerProvider(@NonNull MessengerProvider messengerProvider);
|
||||
|
||||
/**
|
||||
* Gets a {@link Collection} of all known permission strings.
|
||||
*
|
||||
* @return a collection of the known permissions
|
||||
*/
|
||||
@NonNull Collection<String> getKnownPermissions();
|
||||
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ package net.luckperms.api.event.node;
|
||||
|
||||
import net.luckperms.api.event.LuckPermsEvent;
|
||||
import net.luckperms.api.event.Param;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.PermissionHolder;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import net.luckperms.api.node.Node;
|
||||
|
@ -26,26 +26,18 @@
|
||||
package net.luckperms.api.model;
|
||||
|
||||
import net.luckperms.api.cacheddata.CachedDataManager;
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.model.data.NodeMap;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.model.group.GroupManager;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import net.luckperms.api.model.user.UserManager;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
import net.luckperms.api.node.Tristate;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Generic superinterface for an object which holds permissions.
|
||||
@ -156,108 +148,6 @@ public interface PermissionHolder {
|
||||
*/
|
||||
@NonNull NodeMap transientData();
|
||||
|
||||
/**
|
||||
* Encapsulates a store of data ({@link Node}s) within a {@link PermissionHolder}.
|
||||
*
|
||||
* <p>The effect of any mutate operation will not persist in storage unless changes are
|
||||
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||
*
|
||||
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||
*/
|
||||
interface NodeMap {
|
||||
|
||||
/**
|
||||
* Gets a map of the {@link Node}s contained within this instance,
|
||||
* mapped to their defined {@link Node#getContexts() context}.
|
||||
*
|
||||
* @return a map of nodes
|
||||
*/
|
||||
@NonNull Map<ImmutableContextSet, Collection<Node>> toMap();
|
||||
|
||||
/**
|
||||
* Gets a flattened set of {@link Node}s contained within this instance.
|
||||
*
|
||||
* <p>Effectively combines the value collections of the map returned by
|
||||
* {@link #toMap()}.</p>
|
||||
*
|
||||
* @return a flattened set of the holders own nodes
|
||||
*/
|
||||
@NonNull Set<Node> toSet();
|
||||
|
||||
/**
|
||||
* Gets if this instance contains a given {@link Node}.
|
||||
*
|
||||
* <p>Returns {@link Tristate#UNDEFINED} if the instance does not contain the node,
|
||||
* and the {@link Node#getValue() assigned value} of the node as a {@link Tristate}
|
||||
* if it is present.</p>
|
||||
*
|
||||
* @param node the node to check for
|
||||
* @param equalityPredicate how to determine if a node matches
|
||||
* @return a Tristate relating to the assigned state of the node
|
||||
* @throws NullPointerException if the node is null
|
||||
*/
|
||||
@NonNull Tristate contains(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate);
|
||||
|
||||
/**
|
||||
* Adds a node.
|
||||
*
|
||||
* @param node the node to be add
|
||||
* @return the result of the operation
|
||||
*/
|
||||
@NonNull DataMutateResult add(@NonNull Node node);
|
||||
|
||||
/**
|
||||
* Adds a node.
|
||||
*
|
||||
* @param node the node to add
|
||||
* @param temporaryMergeBehaviour the behaviour used to merge temporary permission entries
|
||||
* @return the result of the operation
|
||||
*/
|
||||
@NonNull TemporaryDataMutateResult add(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour);
|
||||
|
||||
/**
|
||||
* Removes a node.
|
||||
*
|
||||
* @param node the node to remove
|
||||
* @return the result of the operation
|
||||
*/
|
||||
@NonNull DataMutateResult remove(@NonNull Node node);
|
||||
|
||||
/**
|
||||
* Clears all nodes.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Clears any nodes which pass the predicate.
|
||||
*
|
||||
* @param test the predicate to test for nodes which should be removed
|
||||
*/
|
||||
void clear(@NonNull Predicate<? super Node> test);
|
||||
|
||||
/**
|
||||
* Clears all nodes in a specific context.
|
||||
*
|
||||
* @param contextSet the contexts to filter by
|
||||
*/
|
||||
void clear(@NonNull ContextSet contextSet);
|
||||
|
||||
/**
|
||||
* Clears all nodes in a specific context which pass the predicate.
|
||||
*
|
||||
* @param contextSet the contexts to filter by
|
||||
* @param test the predicate to test for nodes which should be removed
|
||||
*/
|
||||
void clear(@NonNull ContextSet contextSet, @NonNull Predicate<? super Node> test);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a flattened/squashed view of the holders permissions.
|
||||
*
|
||||
@ -272,7 +162,7 @@ public interface PermissionHolder {
|
||||
*
|
||||
* @return a list of the holders own nodes.
|
||||
*/
|
||||
@NonNull List<Node> getNodes();
|
||||
@NonNull Collection<Node> getNodes();
|
||||
|
||||
/**
|
||||
* Gets a sorted set of all held nodes.
|
||||
@ -301,7 +191,7 @@ public interface PermissionHolder {
|
||||
* @param queryOptions the query options
|
||||
* @return a list of nodes
|
||||
*/
|
||||
@NonNull List<Node> resolveInheritedNodes(@NonNull QueryOptions queryOptions);
|
||||
@NonNull Collection<Node> resolveInheritedNodes(@NonNull QueryOptions queryOptions);
|
||||
|
||||
/**
|
||||
* Gets a mutable sorted set of the nodes that this object has and inherits, filtered by context
|
||||
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.luckperms.api.model;
|
||||
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.util.Result;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Extension of {@link DataMutateResult} for temporary set operations.
|
||||
*/
|
||||
public interface TemporaryDataMutateResult extends Result {
|
||||
|
||||
/**
|
||||
* Gets the underlying result.
|
||||
*
|
||||
* @return the result
|
||||
*/
|
||||
@NonNull DataMutateResult getResult();
|
||||
|
||||
/**
|
||||
* Gets the node that resulted from any {@link TemporaryMergeBehaviour}
|
||||
* processing.
|
||||
*
|
||||
* <p>If no processing took place, the same instance will be returned by
|
||||
* this method.</p>
|
||||
*
|
||||
* @return the resultant node
|
||||
*/
|
||||
@NonNull Node getMergedNode();
|
||||
|
||||
@Override
|
||||
default boolean wasSuccessful() {
|
||||
return getResult().wasSuccessful();
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
* This file is part of luckperms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
@ -23,11 +23,15 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.luckperms.api.model;
|
||||
package net.luckperms.api.model.data;
|
||||
|
||||
import net.luckperms.api.model.PermissionHolder;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.track.Track;
|
||||
import net.luckperms.api.util.Result;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Represents the result of a data mutation call on a LuckPerms object.
|
||||
*
|
||||
@ -40,29 +44,54 @@ public enum DataMutateResult implements Result {
|
||||
*/
|
||||
SUCCESS(true),
|
||||
|
||||
/**
|
||||
* Indicates the mutation failed
|
||||
*/
|
||||
FAIL(false),
|
||||
|
||||
/**
|
||||
* Indicates the mutation failed because the subject of the action already has something
|
||||
*/
|
||||
ALREADY_HAS(false),
|
||||
FAIL_ALREADY_HAS(false),
|
||||
|
||||
/**
|
||||
* Indicates the mutation failed because the subject of the action lacks something
|
||||
*/
|
||||
LACKS(false),
|
||||
FAIL_LACKS(false);
|
||||
|
||||
/**
|
||||
* Indicates the mutation failed
|
||||
*/
|
||||
FAIL(false);
|
||||
private final boolean successful;
|
||||
|
||||
private final boolean success;
|
||||
|
||||
DataMutateResult(boolean success) {
|
||||
this.success = success;
|
||||
DataMutateResult(boolean successful) {
|
||||
this.successful = successful;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wasSuccessful() {
|
||||
return this.success;
|
||||
return this.successful;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension of {@link DataMutateResult} for temporary set operations.
|
||||
*/
|
||||
public interface WithMergedNode {
|
||||
|
||||
/**
|
||||
* Gets the underlying result.
|
||||
*
|
||||
* @return the result
|
||||
*/
|
||||
@NonNull DataMutateResult getResult();
|
||||
|
||||
/**
|
||||
* Gets the node that resulted from any {@link TemporaryNodeMergeStrategy}
|
||||
* processing.
|
||||
*
|
||||
* <p>If no processing took place, the same instance will be returned by
|
||||
* this method.</p>
|
||||
*
|
||||
* @return the resultant node
|
||||
*/
|
||||
@NonNull Node getMergedNode();
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
* This file is part of luckperms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
@ -23,7 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.luckperms.api.model;
|
||||
package net.luckperms.api.model.data;
|
||||
|
||||
/**
|
||||
* Represents a type of data.
|
146
api/src/main/java/net/luckperms/api/model/data/NodeMap.java
Normal file
146
api/src/main/java/net/luckperms/api/model/data/NodeMap.java
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* 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 net.luckperms.api.model.data;
|
||||
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.PermissionHolder;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.model.group.GroupManager;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import net.luckperms.api.model.user.UserManager;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
import net.luckperms.api.node.Tristate;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Encapsulates a store of data ({@link Node}s) within a {@link PermissionHolder}.
|
||||
*
|
||||
* <p>The effect of any mutate operation will not persist in storage unless changes are
|
||||
* explicitly saved. If changes are not saved, the effect will only be observed until the next
|
||||
* time the holders permission data is (re)loaded. Changes to {@link User}s should be saved
|
||||
* using {@link UserManager#saveUser(User)}, and changes to {@link Group}s should be saved
|
||||
* using {@link GroupManager#saveGroup(Group)}.</p>
|
||||
*
|
||||
* <p>Before making changes to a user or group, it may be a good idea to load a fresh copy of
|
||||
* the backing data from the storage if you haven't done so already, to avoid overwriting changes
|
||||
* made already. This can be done via {@link UserManager#loadUser(UUID)} or
|
||||
* {@link GroupManager#loadGroup(String)} respectively.</p>
|
||||
*/
|
||||
public interface NodeMap {
|
||||
|
||||
/**
|
||||
* Gets a map of the {@link Node}s contained within this instance,
|
||||
* mapped to their defined {@link Node#getContexts() context}.
|
||||
*
|
||||
* @return a map of nodes
|
||||
*/
|
||||
@NonNull Map<ImmutableContextSet, Collection<Node>> toMap();
|
||||
|
||||
/**
|
||||
* Gets a flattened view of {@link Node}s contained within this instance.
|
||||
*
|
||||
* <p>Effectively combines the value collections of the map returned by
|
||||
* {@link #toMap()}.</p>
|
||||
*
|
||||
* @return a flattened collection of nodes
|
||||
*/
|
||||
@NonNull Collection<Node> toCollection();
|
||||
|
||||
/**
|
||||
* Gets if this instance contains a given {@link Node}.
|
||||
*
|
||||
* <p>Returns {@link Tristate#UNDEFINED} if the instance does not contain the node,
|
||||
* and the {@link Node#getValue() assigned value} of the node as a {@link Tristate}
|
||||
* if it is present.</p>
|
||||
*
|
||||
* @param node the node to check for
|
||||
* @param equalityPredicate how to determine if a node matches
|
||||
* @return a Tristate relating to the assigned state of the node
|
||||
* @throws NullPointerException if the node is null
|
||||
*/
|
||||
@NonNull Tristate contains(@NonNull Node node, @NonNull NodeEqualityPredicate equalityPredicate);
|
||||
|
||||
/**
|
||||
* Adds a node.
|
||||
*
|
||||
* @param node the node to be add
|
||||
* @return the result of the operation
|
||||
*/
|
||||
@NonNull DataMutateResult add(@NonNull Node node);
|
||||
|
||||
/**
|
||||
* Adds a node.
|
||||
*
|
||||
* @param node the node to add
|
||||
* @param temporaryNodeMergeStrategy the strategy used to merge temporary permission entries
|
||||
* @return the result of the operation
|
||||
*/
|
||||
DataMutateResult.@NonNull WithMergedNode add(@NonNull Node node, @NonNull TemporaryNodeMergeStrategy temporaryNodeMergeStrategy);
|
||||
|
||||
/**
|
||||
* Removes a node.
|
||||
*
|
||||
* @param node the node to remove
|
||||
* @return the result of the operation
|
||||
*/
|
||||
@NonNull DataMutateResult remove(@NonNull Node node);
|
||||
|
||||
/**
|
||||
* Clears all nodes.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Clears any nodes which pass the predicate.
|
||||
*
|
||||
* @param test the predicate to test for nodes which should be removed
|
||||
*/
|
||||
void clear(@NonNull Predicate<? super Node> test);
|
||||
|
||||
/**
|
||||
* Clears all nodes in a specific context.
|
||||
*
|
||||
* @param contextSet the contexts to filter by
|
||||
*/
|
||||
void clear(@NonNull ContextSet contextSet);
|
||||
|
||||
/**
|
||||
* Clears all nodes in a specific context which pass the predicate.
|
||||
*
|
||||
* @param contextSet the contexts to filter by
|
||||
* @param test the predicate to test for nodes which should be removed
|
||||
*/
|
||||
void clear(@NonNull ContextSet contextSet, @NonNull Predicate<? super Node> test);
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
* This file is part of luckperms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
@ -23,9 +23,8 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.luckperms.api.model;
|
||||
package net.luckperms.api.model.data;
|
||||
|
||||
import net.luckperms.api.model.PermissionHolder.NodeMap;
|
||||
import net.luckperms.api.node.Node;
|
||||
|
||||
/**
|
||||
@ -33,13 +32,13 @@ import net.luckperms.api.node.Node;
|
||||
* that would otherwise conflict with existing entries.
|
||||
*
|
||||
* <p>The default behaviour of {@link NodeMap#add(Node)} is
|
||||
* to return a result of {@link DataMutateResult#ALREADY_HAS} when an equivalent
|
||||
* node is found. This can be replicated using {@link #FAIL_WITH_ALREADY_HAS}.</p>
|
||||
* to return a result of {@link DataMutateResult#FAIL_ALREADY_HAS} when an equivalent
|
||||
* node is found. This can be replicated using {@link #NONE}.</p>
|
||||
*
|
||||
* <p>However, the {@link NodeMap#add(Node, TemporaryMergeBehaviour)}
|
||||
* <p>However, the {@link NodeMap#add(Node, TemporaryNodeMergeStrategy)}
|
||||
* method allows this behaviour to be customized for temporary permissions.</p>
|
||||
*/
|
||||
public enum TemporaryMergeBehaviour {
|
||||
public enum TemporaryNodeMergeStrategy {
|
||||
|
||||
/**
|
||||
* Expiry durations will be added to the existing expiry time of a permission.
|
||||
@ -54,6 +53,6 @@ public enum TemporaryMergeBehaviour {
|
||||
/**
|
||||
* The operation will fail if an existing temporary node is present.
|
||||
*/
|
||||
FAIL_WITH_ALREADY_HAS
|
||||
NONE
|
||||
|
||||
}
|
@ -25,8 +25,8 @@
|
||||
|
||||
package net.luckperms.api.model.user;
|
||||
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.PermissionHolder;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
@ -28,6 +28,7 @@ package net.luckperms.api.platform;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -50,6 +51,13 @@ public interface Platform {
|
||||
*/
|
||||
@NonNull Set<UUID> getUniqueConnections();
|
||||
|
||||
/**
|
||||
* Gets a {@link Collection} of all known permission strings.
|
||||
*
|
||||
* @return a collection of the known permissions
|
||||
*/
|
||||
@NonNull Collection<String> getKnownPermissions();
|
||||
|
||||
/**
|
||||
* Gets the time when the plugin first started.
|
||||
*
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
package net.luckperms.api.query.dataorder;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
package net.luckperms.api.query.dataorder;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.PermissionHolder;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.query.OptionKey;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
@ -26,7 +26,7 @@
|
||||
package net.luckperms.api.track;
|
||||
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.model.user.User;
|
||||
|
||||
@ -58,13 +58,6 @@ public interface Track {
|
||||
*/
|
||||
@NonNull List<String> getGroups();
|
||||
|
||||
/**
|
||||
* Gets the number of groups on this track
|
||||
*
|
||||
* @return the number of groups on this track
|
||||
*/
|
||||
int getSize();
|
||||
|
||||
/**
|
||||
* Gets the next group on the track, after the one provided
|
||||
*
|
||||
|
@ -32,7 +32,7 @@ import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.factory.NodeBuilders;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.metadata.NodeMetadataKey;
|
||||
|
||||
|
@ -55,7 +55,7 @@ import me.lucko.luckperms.common.util.ProgressLogger;
|
||||
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
@ -48,7 +48,7 @@ import me.lucko.luckperms.common.util.Uuids;
|
||||
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
|
||||
import org.anjocaido.groupmanager.GlobalGroups;
|
||||
|
@ -46,7 +46,7 @@ import me.lucko.luckperms.common.util.ProgressLogger;
|
||||
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
@ -51,7 +51,7 @@ import me.lucko.luckperms.common.util.ProgressLogger;
|
||||
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
@ -57,7 +57,7 @@ import me.lucko.luckperms.common.util.ProgressLogger;
|
||||
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeBuilder;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -49,7 +49,7 @@ import me.lucko.luckperms.common.util.ProgressLogger;
|
||||
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -42,7 +42,7 @@ import me.lucko.luckperms.common.verbose.event.MetaCheckEvent;
|
||||
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
import net.luckperms.api.node.NodeBuilder;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
@ -48,7 +48,7 @@ import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Tristate;
|
||||
import net.luckperms.api.query.Flag;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
@ -49,7 +49,7 @@ import net.alpenblock.bungeeperms.Server;
|
||||
import net.alpenblock.bungeeperms.World;
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -54,7 +54,6 @@ import net.luckperms.api.track.TrackManager;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@ -147,11 +146,6 @@ public class LuckPermsApiProvider implements LuckPerms {
|
||||
return this.contextManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Collection<String> getKnownPermissions() {
|
||||
return this.plugin.getPermissionRegistry().rootAsList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull NodeBuilderRegistry getNodeBuilderRegistry() {
|
||||
return ApiNodeBuilderRegistry.INSTANCE;
|
||||
|
@ -54,7 +54,6 @@ import net.luckperms.api.track.TrackManager;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -99,7 +98,6 @@ public class MinimalApiProvider implements LuckPerms {
|
||||
@Override public @NonNull MetaStackFactory getMetaStackFactory() { throw exception(); }
|
||||
@Override public @NonNull CompletableFuture<Void> runUpdateTask() { throw exception(); }
|
||||
@Override public void registerMessengerProvider(@NonNull MessengerProvider messengerProvider) { throw exception(); }
|
||||
@Override public @NonNull Collection<String> getKnownPermissions() { throw exception(); }
|
||||
|
||||
private static final class MinimalActionLogger implements ActionLogger {
|
||||
private static final MinimalActionLogger INSTANCE = new MinimalActionLogger();
|
||||
|
@ -30,10 +30,10 @@ import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import net.luckperms.api.cacheddata.CachedDataManager;
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.TemporaryDataMutateResult;
|
||||
import net.luckperms.api.model.TemporaryMergeBehaviour;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.model.data.NodeMap;
|
||||
import net.luckperms.api.model.data.TemporaryNodeMergeStrategy;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
import net.luckperms.api.node.Tristate;
|
||||
@ -140,7 +140,7 @@ public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHo
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Set<Node> toSet() {
|
||||
public @NonNull Set<Node> toCollection() {
|
||||
return ApiPermissionHolder.this.handle.getData(this.dataType).asSet();
|
||||
}
|
||||
|
||||
@ -155,8 +155,8 @@ public class ApiPermissionHolder implements net.luckperms.api.model.PermissionHo
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull TemporaryDataMutateResult add(@NonNull Node node, @NonNull TemporaryMergeBehaviour temporaryMergeBehaviour) {
|
||||
return ApiPermissionHolder.this.handle.setNode(this.dataType, node, temporaryMergeBehaviour);
|
||||
public DataMutateResult.@NonNull WithMergedNode add(@NonNull Node node, @NonNull TemporaryNodeMergeStrategy temporaryNodeMergeStrategy) {
|
||||
return ApiPermissionHolder.this.handle.setNode(this.dataType, node, temporaryNodeMergeStrategy);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,6 +33,7 @@ import net.luckperms.api.platform.PluginMetadata;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -64,6 +65,11 @@ public class ApiPlatform implements Platform, PluginMetadata {
|
||||
return Collections.unmodifiableSet(this.plugin.getConnectionListener().getUniqueConnections());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Collection<String> getKnownPermissions() {
|
||||
return this.plugin.getPermissionRegistry().rootAsList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Instant getStartTime() {
|
||||
return Instant.ofEpochMilli(this.plugin.getBootstrap().getStartupTime());
|
||||
|
@ -31,7 +31,7 @@ import me.lucko.luckperms.common.model.Track;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import net.luckperms.api.track.DemotionResult;
|
||||
|
@ -31,8 +31,8 @@ import me.lucko.luckperms.common.cacheddata.UserCachedDataManager;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.types.Inheritance;
|
||||
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@ -77,7 +77,7 @@ public class ApiUser extends ApiPermissionHolder implements net.luckperms.api.mo
|
||||
public @NonNull DataMutateResult setPrimaryGroup(@NonNull String group) {
|
||||
Objects.requireNonNull(group, "group");
|
||||
if (getPrimaryGroup().equalsIgnoreCase(group)) {
|
||||
return DataMutateResult.ALREADY_HAS;
|
||||
return DataMutateResult.FAIL_ALREADY_HAS;
|
||||
}
|
||||
|
||||
if (!this.handle.hasNode(DataType.NORMAL, Inheritance.builder(group.toLowerCase()).build(), NodeEqualityPredicate.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean()) {
|
||||
|
@ -40,7 +40,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -36,7 +36,7 @@ import me.lucko.luckperms.common.util.DateParser;
|
||||
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.TemporaryMergeBehaviour;
|
||||
import net.luckperms.api.model.data.TemporaryNodeMergeStrategy;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -122,27 +122,28 @@ public class ArgumentParser {
|
||||
return unixTime < (System.currentTimeMillis() / 1000L);
|
||||
}
|
||||
|
||||
public static TemporaryMergeBehaviour parseTemporaryModifier(String s) {
|
||||
public static TemporaryNodeMergeStrategy parseTemporaryModifier(String s) {
|
||||
switch (s.toLowerCase()) {
|
||||
case "accumulate":
|
||||
return TemporaryMergeBehaviour.ADD_NEW_DURATION_TO_EXISTING;
|
||||
return TemporaryNodeMergeStrategy.ADD_NEW_DURATION_TO_EXISTING;
|
||||
case "replace":
|
||||
return TemporaryMergeBehaviour.REPLACE_EXISTING_IF_DURATION_LONGER;
|
||||
return TemporaryNodeMergeStrategy.REPLACE_EXISTING_IF_DURATION_LONGER;
|
||||
case "deny":
|
||||
return TemporaryMergeBehaviour.FAIL_WITH_ALREADY_HAS;
|
||||
case "none":
|
||||
return TemporaryNodeMergeStrategy.NONE;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown value: " + s);
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<TemporaryMergeBehaviour> parseTemporaryModifier(int index, List<String> args) {
|
||||
public static Optional<TemporaryNodeMergeStrategy> parseTemporaryModifier(int index, List<String> args) {
|
||||
if (index < 0 || index >= args.size()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
String s = args.get(index);
|
||||
try {
|
||||
Optional<TemporaryMergeBehaviour> ret = Optional.of(parseTemporaryModifier(s));
|
||||
Optional<TemporaryNodeMergeStrategy> ret = Optional.of(parseTemporaryModifier(s));
|
||||
args.remove(index);
|
||||
return ret;
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -48,8 +48,8 @@ import me.lucko.luckperms.common.util.TextUtils;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.event.HoverEvent;
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -50,9 +50,9 @@ import me.lucko.luckperms.common.util.TextUtils;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.event.HoverEvent;
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.TemporaryDataMutateResult;
|
||||
import net.luckperms.api.model.TemporaryMergeBehaviour;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.model.data.TemporaryNodeMergeStrategy;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
|
||||
import java.util.List;
|
||||
@ -81,7 +81,7 @@ public class MetaAddTempChatMeta extends SharedSubCommand {
|
||||
int priority = ArgumentParser.parsePriority(0, args);
|
||||
String meta = ArgumentParser.parseString(1, args);
|
||||
long duration = ArgumentParser.parseDuration(2, args);
|
||||
TemporaryMergeBehaviour modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
TemporaryNodeMergeStrategy modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentParser.parseContext(3, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context) ||
|
||||
@ -90,7 +90,7 @@ public class MetaAddTempChatMeta extends SharedSubCommand {
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
TemporaryDataMutateResult ret = holder.setNode(DataType.NORMAL, this.type.builder(meta, priority).expiry(duration).withContext(context).build(), modifier);
|
||||
DataMutateResult.WithMergedNode ret = holder.setNode(DataType.NORMAL, this.type.builder(meta, priority).expiry(duration).withContext(context).build(), modifier);
|
||||
|
||||
if (ret.getResult().wasSuccessful()) {
|
||||
duration = ret.getMergedNode().getExpiry().getEpochSecond();
|
||||
|
@ -45,7 +45,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -48,8 +48,8 @@ import me.lucko.luckperms.common.util.TextUtils;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.event.HoverEvent;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -48,8 +48,8 @@ import me.lucko.luckperms.common.util.TextUtils;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.event.HoverEvent;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -49,7 +49,7 @@ import me.lucko.luckperms.common.util.TextUtils;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.event.HoverEvent;
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
@ -50,8 +50,8 @@ import me.lucko.luckperms.common.util.TextUtils;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.event.HoverEvent;
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
|
@ -51,8 +51,8 @@ import me.lucko.luckperms.common.util.TextUtils;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.event.HoverEvent;
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.TemporaryMergeBehaviour;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.model.data.TemporaryNodeMergeStrategy;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
@ -74,7 +74,7 @@ public class MetaSetTemp extends SharedSubCommand {
|
||||
String key = args.get(0);
|
||||
String value = args.get(1);
|
||||
long duration = ArgumentParser.parseDuration(2, args);
|
||||
TemporaryMergeBehaviour modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
TemporaryNodeMergeStrategy modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentParser.parseContext(3, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context) ||
|
||||
|
@ -52,9 +52,9 @@ import me.lucko.luckperms.common.util.TextUtils;
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.kyori.text.event.HoverEvent;
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.TemporaryDataMutateResult;
|
||||
import net.luckperms.api.model.TemporaryMergeBehaviour;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.model.data.TemporaryNodeMergeStrategy;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
@ -85,7 +85,7 @@ public class MetaSetTempChatMeta extends SharedSubCommand {
|
||||
int priority = ArgumentParser.parseIntOrElse(0, args, Integer.MIN_VALUE);
|
||||
String meta;
|
||||
long duration;
|
||||
TemporaryMergeBehaviour modifier;
|
||||
TemporaryNodeMergeStrategy modifier;
|
||||
MutableContextSet context;
|
||||
|
||||
if (priority == Integer.MIN_VALUE) {
|
||||
@ -130,7 +130,7 @@ public class MetaSetTempChatMeta extends SharedSubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
TemporaryDataMutateResult ret = holder.setNode(DataType.NORMAL, this.type.builder(meta, priority).expiry(duration).withContext(context).build(), modifier);
|
||||
DataMutateResult.WithMergedNode ret = holder.setNode(DataType.NORMAL, this.type.builder(meta, priority).expiry(duration).withContext(context).build(), modifier);
|
||||
|
||||
if (ret.getResult().wasSuccessful()) {
|
||||
duration = ret.getMergedNode().getExpiry().getEpochSecond();
|
||||
|
@ -45,7 +45,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -45,7 +45,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -45,7 +45,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -47,8 +47,8 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -49,10 +49,9 @@ import me.lucko.luckperms.common.util.DurationFormatter;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.TemporaryDataMutateResult;
|
||||
import net.luckperms.api.model.TemporaryMergeBehaviour;
|
||||
import net.luckperms.api.util.Result;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.model.data.TemporaryNodeMergeStrategy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -70,7 +69,7 @@ public class ParentAddTemp extends SharedSubCommand {
|
||||
|
||||
String groupName = ArgumentParser.parseName(0, args);
|
||||
long duration = ArgumentParser.parseDuration(1, args);
|
||||
TemporaryMergeBehaviour modifier = ArgumentParser.parseTemporaryModifier(2, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
TemporaryNodeMergeStrategy modifier = ArgumentParser.parseTemporaryModifier(2, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentParser.parseContext(2, args, plugin);
|
||||
|
||||
Group group = StorageAssistant.loadGroup(groupName, sender, plugin, false);
|
||||
@ -91,9 +90,9 @@ public class ParentAddTemp extends SharedSubCommand {
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
TemporaryDataMutateResult ret = holder.setNode(DataType.NORMAL, Inheritance.builder(group.getName()).expiry(duration).withContext(context).build(), modifier);
|
||||
DataMutateResult.WithMergedNode ret = holder.setNode(DataType.NORMAL, Inheritance.builder(group.getName()).expiry(duration).withContext(context).build(), modifier);
|
||||
|
||||
if (((Result) ret.getResult()).wasSuccessful()) {
|
||||
if (ret.getResult().wasSuccessful()) {
|
||||
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));
|
||||
|
||||
|
@ -45,7 +45,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -49,7 +49,7 @@ import me.lucko.luckperms.common.storage.misc.DataConstraints;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -50,8 +50,8 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -46,8 +46,8 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -49,7 +49,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -49,7 +49,7 @@ import me.lucko.luckperms.common.storage.misc.DataConstraints;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -47,7 +47,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
|
||||
|
@ -44,7 +44,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
import net.luckperms.api.node.Tristate;
|
||||
|
||||
|
@ -45,7 +45,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -46,8 +46,8 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.types.InheritanceNode;
|
||||
|
||||
|
@ -48,12 +48,11 @@ import me.lucko.luckperms.common.util.DurationFormatter;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.TemporaryDataMutateResult;
|
||||
import net.luckperms.api.model.TemporaryMergeBehaviour;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.model.data.TemporaryNodeMergeStrategy;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.types.InheritanceNode;
|
||||
import net.luckperms.api.util.Result;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -72,7 +71,7 @@ public class PermissionSetTemp extends SharedSubCommand {
|
||||
String node = ArgumentParser.parseString(0, args);
|
||||
boolean value = ArgumentParser.parseBoolean(1, args);
|
||||
long duration = ArgumentParser.parseDuration(2, args);
|
||||
TemporaryMergeBehaviour modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
TemporaryNodeMergeStrategy modifier = ArgumentParser.parseTemporaryModifier(3, args).orElseGet(() -> plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR));
|
||||
MutableContextSet context = ArgumentParser.parseContext(3, args, plugin);
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context) ||
|
||||
@ -91,9 +90,9 @@ public class PermissionSetTemp extends SharedSubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
TemporaryDataMutateResult result = holder.setNode(DataType.NORMAL, builtNode, modifier);
|
||||
DataMutateResult.WithMergedNode result = holder.setNode(DataType.NORMAL, builtNode, modifier);
|
||||
|
||||
if (((Result) result.getResult()).wasSuccessful()) {
|
||||
if (result.getResult().wasSuccessful()) {
|
||||
duration = result.getMergedNode().getExpiry().getEpochSecond();
|
||||
Message.SETPERMISSION_TEMP_SUCCESS.send(sender, node, value, holder.getFormattedDisplayName(), DurationFormatter.LONG.formatDateDiff(duration), MessageUtils.contextSetToString(plugin.getLocaleManager(), context));
|
||||
|
||||
|
@ -46,8 +46,8 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.types.InheritanceNode;
|
||||
|
||||
|
@ -46,8 +46,8 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.types.InheritanceNode;
|
||||
|
||||
|
@ -41,7 +41,7 @@ import me.lucko.luckperms.common.storage.misc.DataConstraints;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -41,7 +41,7 @@ import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.event.cause.DeletionCause;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -46,7 +46,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
import net.luckperms.api.node.types.DisplayNameNode;
|
||||
|
||||
|
@ -42,7 +42,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -39,7 +39,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -29,7 +29,7 @@ import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.node.factory.NodeBuilders;
|
||||
import me.lucko.luckperms.common.node.types.Weight;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.NodeBuilder;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
|
@ -55,7 +55,7 @@ import me.lucko.luckperms.common.web.WebEditor;
|
||||
import net.luckperms.api.actionlog.Action;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.event.cause.DeletionCause;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -43,7 +43,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.storage.misc.DataConstraints;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -43,7 +43,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.storage.misc.DataConstraints;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -42,7 +42,7 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.storage.misc.DataConstraints;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -40,7 +40,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -41,7 +41,7 @@ import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||
|
||||
import net.luckperms.api.metastacking.DuplicateRemovalFunction;
|
||||
import net.luckperms.api.metastacking.MetaStackDefinition;
|
||||
import net.luckperms.api.model.TemporaryMergeBehaviour;
|
||||
import net.luckperms.api.model.data.TemporaryNodeMergeStrategy;
|
||||
import net.luckperms.api.query.Flag;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
@ -131,7 +131,7 @@ public final class ConfigKeys {
|
||||
/**
|
||||
* Controls how temporary add commands should behave
|
||||
*/
|
||||
public static final ConfigKey<TemporaryMergeBehaviour> TEMPORARY_ADD_BEHAVIOUR = customKey(c -> {
|
||||
public static final ConfigKey<TemporaryNodeMergeStrategy> TEMPORARY_ADD_BEHAVIOUR = customKey(c -> {
|
||||
String option = c.getString("temporary-add-behaviour", "deny").toLowerCase();
|
||||
if (!option.equals("deny") && !option.equals("replace") && !option.equals("accumulate")) {
|
||||
option = "deny";
|
||||
|
@ -84,8 +84,8 @@ import net.luckperms.api.event.user.UserLoadEvent;
|
||||
import net.luckperms.api.event.user.track.UserDemoteEvent;
|
||||
import net.luckperms.api.event.user.track.UserPromoteEvent;
|
||||
import net.luckperms.api.extension.Extension;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.PlayerSaveResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
@ -38,10 +38,9 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.TemporaryDataMutateResult;
|
||||
import net.luckperms.api.model.TemporaryMergeBehaviour;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.model.data.TemporaryNodeMergeStrategy;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
@ -410,7 +409,7 @@ public abstract class PermissionHolder {
|
||||
|
||||
public DataMutateResult setNode(DataType dataType, Node node, boolean callEvent) {
|
||||
if (hasNode(dataType, node, NodeEqualityPredicate.IGNORE_EXPIRY_TIME) != Tristate.UNDEFINED) {
|
||||
return DataMutateResult.ALREADY_HAS;
|
||||
return DataMutateResult.FAIL_ALREADY_HAS;
|
||||
}
|
||||
|
||||
NodeMap data = getData(dataType);
|
||||
@ -428,8 +427,8 @@ public abstract class PermissionHolder {
|
||||
return DataMutateResult.SUCCESS;
|
||||
}
|
||||
|
||||
public TemporaryDataMutateResult setNode(DataType dataType, Node node, TemporaryMergeBehaviour mergeBehaviour) {
|
||||
if (node.hasExpiry() && mergeBehaviour != TemporaryMergeBehaviour.FAIL_WITH_ALREADY_HAS) {
|
||||
public DataMutateResult.WithMergedNode setNode(DataType dataType, Node node, TemporaryNodeMergeStrategy mergeStrategy) {
|
||||
if (node.hasExpiry() && mergeStrategy != TemporaryNodeMergeStrategy.NONE) {
|
||||
Node otherMatch = getData(dataType).immutable().values().stream()
|
||||
.filter(NodeEqualityPredicate.IGNORE_EXPIRY_TIME_AND_VALUE.equalTo(node))
|
||||
.findFirst().orElse(null);
|
||||
@ -437,7 +436,7 @@ public abstract class PermissionHolder {
|
||||
NodeMap data = getData(dataType);
|
||||
|
||||
Node newNode = null;
|
||||
switch (mergeBehaviour) {
|
||||
switch (mergeStrategy) {
|
||||
case ADD_NEW_DURATION_TO_EXISTING: {
|
||||
// Create a new Node with the same properties, but add the expiry dates together
|
||||
long newExpiry = otherMatch.getExpiry().plus(Duration.between(Instant.now(), node.getExpiry())).getEpochSecond();
|
||||
@ -462,18 +461,18 @@ public abstract class PermissionHolder {
|
||||
ImmutableCollection<? extends Node> after = data.immutable().values();
|
||||
this.plugin.getEventFactory().handleNodeAdd(newNode, this, dataType, before, after);
|
||||
|
||||
return new TemporaryResult(DataMutateResult.SUCCESS, newNode);
|
||||
return new MergedNodeResult(DataMutateResult.SUCCESS, newNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to the normal handling.
|
||||
return new TemporaryResult(setNode(dataType, node, true), node);
|
||||
return new MergedNodeResult(setNode(dataType, node, true), node);
|
||||
}
|
||||
|
||||
public DataMutateResult unsetNode(DataType dataType, Node node) {
|
||||
if (hasNode(dataType, node, NodeEqualityPredicate.IGNORE_EXPIRY_TIME_AND_VALUE) == Tristate.UNDEFINED) {
|
||||
return DataMutateResult.LACKS;
|
||||
return DataMutateResult.FAIL_LACKS;
|
||||
}
|
||||
|
||||
ImmutableCollection<? extends Node> before = getData(dataType).immutable().values();
|
||||
@ -543,11 +542,11 @@ public abstract class PermissionHolder {
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
|
||||
private static final class TemporaryResult implements TemporaryDataMutateResult {
|
||||
private static final class MergedNodeResult implements DataMutateResult.WithMergedNode {
|
||||
private final DataMutateResult result;
|
||||
private final Node mergedNode;
|
||||
|
||||
private TemporaryResult(DataMutateResult result, Node mergedNode) {
|
||||
private MergedNodeResult(DataMutateResult result, Node mergedNode) {
|
||||
this.result = result;
|
||||
this.mergedNode = mergedNode;
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.model.DataMutateResult;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.types.InheritanceNode;
|
||||
import net.luckperms.api.track.DemotionResult;
|
||||
@ -177,7 +177,7 @@ public final class Track {
|
||||
*/
|
||||
public DataMutateResult appendGroup(Group group) {
|
||||
if (containsGroup(group)) {
|
||||
return DataMutateResult.ALREADY_HAS;
|
||||
return DataMutateResult.FAIL_ALREADY_HAS;
|
||||
}
|
||||
|
||||
List<String> before = ImmutableList.copyOf(this.groups);
|
||||
@ -198,7 +198,7 @@ public final class Track {
|
||||
*/
|
||||
public DataMutateResult insertGroup(Group group, int position) throws IndexOutOfBoundsException {
|
||||
if (containsGroup(group)) {
|
||||
return DataMutateResult.ALREADY_HAS;
|
||||
return DataMutateResult.FAIL_ALREADY_HAS;
|
||||
}
|
||||
|
||||
List<String> before = ImmutableList.copyOf(this.groups);
|
||||
@ -227,7 +227,7 @@ public final class Track {
|
||||
*/
|
||||
public DataMutateResult removeGroup(String group) {
|
||||
if (!containsGroup(group)) {
|
||||
return DataMutateResult.LACKS;
|
||||
return DataMutateResult.FAIL_LACKS;
|
||||
}
|
||||
|
||||
List<String> before = ImmutableList.copyOf(this.groups);
|
||||
|
@ -35,7 +35,7 @@ import me.lucko.luckperms.common.model.manager.group.GroupManager;
|
||||
import me.lucko.luckperms.common.node.types.Inheritance;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.types.InheritanceNode;
|
||||
|
||||
|
@ -28,8 +28,8 @@ package me.lucko.luckperms.common.plugin.util;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.PlayerSaveResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.platform.Platform;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -53,8 +53,8 @@ import me.lucko.luckperms.common.util.MoreFiles;
|
||||
import net.luckperms.api.actionlog.Action;
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.PlayerSaveResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeBuilder;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
@ -59,8 +59,8 @@ import net.luckperms.api.context.Context;
|
||||
import net.luckperms.api.context.ContextSet;
|
||||
import net.luckperms.api.context.DefaultContextKeys;
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.PlayerSaveResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.HeldNode;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeBuilder;
|
||||
|
@ -49,8 +49,8 @@ import me.lucko.luckperms.common.storage.misc.PlayerSaveResultImpl;
|
||||
import me.lucko.luckperms.common.util.gson.GsonProvider;
|
||||
|
||||
import net.luckperms.api.actionlog.Action;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.PlayerSaveResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.HeldNode;
|
||||
import net.luckperms.api.node.Node;
|
||||
|
||||
|
@ -32,7 +32,7 @@ import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.factory.NodeBuilders;
|
||||
import me.lucko.luckperms.nukkit.inject.dummy.DummyPlugin;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.metadata.NodeMetadataKey;
|
||||
import net.luckperms.api.util.Result;
|
||||
|
@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Tristate;
|
||||
|
||||
import org.spongepowered.api.service.permission.SubjectData;
|
||||
|
@ -31,7 +31,7 @@ import me.lucko.luckperms.sponge.service.model.LPSubject;
|
||||
import me.lucko.luckperms.sponge.service.model.LPSubjectCollection;
|
||||
import me.lucko.luckperms.sponge.service.model.LPSubjectData;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import org.spongepowered.api.service.permission.PermissionDescription;
|
||||
import org.spongepowered.api.service.permission.PermissionService;
|
||||
|
@ -37,7 +37,7 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData;
|
||||
import me.lucko.luckperms.sponge.service.model.LPSubjectReference;
|
||||
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Tristate;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
|
@ -30,7 +30,7 @@ import me.lucko.luckperms.sponge.service.model.LPSubject;
|
||||
import me.lucko.luckperms.sponge.service.model.LPSubjectReference;
|
||||
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Tristate;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -45,7 +45,7 @@ import me.lucko.luckperms.sponge.service.model.LPSubject;
|
||||
import me.lucko.luckperms.sponge.service.model.LPSubjectReference;
|
||||
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Tristate;
|
||||
import net.luckperms.api.query.QueryOptions;
|
||||
|
||||
|
@ -45,7 +45,7 @@ import me.lucko.luckperms.sponge.service.model.LPSubjectData;
|
||||
import me.lucko.luckperms.sponge.service.model.LPSubjectReference;
|
||||
|
||||
import net.luckperms.api.context.ImmutableContextSet;
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.ChatMetaType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
@ -35,7 +35,7 @@ import me.lucko.luckperms.sponge.service.model.calculated.CalculatedSubject;
|
||||
import me.lucko.luckperms.sponge.service.model.calculated.CalculatedSubjectData;
|
||||
import me.lucko.luckperms.sponge.service.model.calculated.MonitoredSubjectData;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
import org.spongepowered.api.command.CommandSource;
|
||||
import org.spongepowered.api.service.permission.Subject;
|
||||
|
@ -28,7 +28,7 @@ package me.lucko.luckperms.sponge.service.model.persisted;
|
||||
import me.lucko.luckperms.sponge.service.LuckPermsService;
|
||||
import me.lucko.luckperms.sponge.service.model.calculated.MonitoredSubjectData;
|
||||
|
||||
import net.luckperms.api.model.DataType;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
|
||||
/**
|
||||
* Extension of CalculatedSubjectData which persists data when modified
|
||||
|
Loading…
Reference in New Issue
Block a user