mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-13 01:57:31 +00:00
Permission holder refactoring
This commit is contained in:
85 files changed
+663
-721
No files matched your search
@@ -40,7 +40,7 @@ public interface NodeAddEvent extends NodeMutateEvent {
|
||||
*
|
||||
* @return the node that was added
|
||||
*/
|
||||
@Param(3)
|
||||
@Param(4)
|
||||
@NonNull Node getNode();
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ package me.lucko.luckperms.api.event.node;
|
||||
|
||||
import me.lucko.luckperms.api.event.LuckPermsEvent;
|
||||
import me.lucko.luckperms.api.event.Param;
|
||||
import me.lucko.luckperms.api.model.DataType;
|
||||
import me.lucko.luckperms.api.model.PermissionHolder;
|
||||
import me.lucko.luckperms.api.model.group.Group;
|
||||
import me.lucko.luckperms.api.model.user.User;
|
||||
@@ -49,12 +50,20 @@ public interface NodeMutateEvent extends LuckPermsEvent {
|
||||
@Param(0)
|
||||
@NonNull PermissionHolder getTarget();
|
||||
|
||||
/**
|
||||
* Gets the data type that was mutated.
|
||||
*
|
||||
* @return the data type
|
||||
*/
|
||||
@Param(1)
|
||||
@NonNull DataType getDataType();
|
||||
|
||||
/**
|
||||
* Gets an immutable copy of the holders data before the change
|
||||
*
|
||||
* @return the data before the change
|
||||
*/
|
||||
@Param(1)
|
||||
@Param(2)
|
||||
@NonNull Set<Node> getDataBefore();
|
||||
|
||||
/**
|
||||
@@ -62,7 +71,7 @@ public interface NodeMutateEvent extends LuckPermsEvent {
|
||||
*
|
||||
* @return the data after the change
|
||||
*/
|
||||
@Param(2)
|
||||
@Param(3)
|
||||
@NonNull Set<Node> getDataAfter();
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,7 +40,7 @@ public interface NodeRemoveEvent extends NodeMutateEvent {
|
||||
*
|
||||
* @return the node that was removed
|
||||
*/
|
||||
@Param(3)
|
||||
@Param(4)
|
||||
@NonNull Node getNode();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.model;
|
||||
|
||||
/**
|
||||
* Represents a type of data.
|
||||
*/
|
||||
public enum DataType {
|
||||
|
||||
/**
|
||||
* Normal data.
|
||||
*/
|
||||
NORMAL,
|
||||
|
||||
/**
|
||||
* Data which expires automatically at the end of a session.
|
||||
* (when a user logs off)
|
||||
*
|
||||
* <p>This data is never saved to the backend storage provider.</p>
|
||||
*/
|
||||
TRANSIENT
|
||||
|
||||
}
|
||||
@@ -140,25 +140,6 @@ public interface PermissionHolder {
|
||||
*/
|
||||
@NonNull Data transientData();
|
||||
|
||||
/**
|
||||
* Represents a type of data.
|
||||
*/
|
||||
enum DataType {
|
||||
|
||||
/**
|
||||
* Normal data.
|
||||
*/
|
||||
NORMAL,
|
||||
|
||||
/**
|
||||
* Data which expires automatically at the end of a session.
|
||||
* (when a user logs off)
|
||||
*
|
||||
* <p>This data is never saved to the backend storage provider.</p>
|
||||
*/
|
||||
TRANSIENT
|
||||
}
|
||||
|
||||
interface Data {
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,8 @@ package me.lucko.luckperms.api.node;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* A rule for determining if two nodes are equal.
|
||||
*
|
||||
@@ -48,6 +50,17 @@ public interface NodeEqualityPredicate {
|
||||
*/
|
||||
boolean areEqual(@NonNull Node o1, @NonNull Node o2);
|
||||
|
||||
/**
|
||||
* Returns a {@link Predicate}, returning true if the tested node is equal
|
||||
* to the one given, according to the {@link NodeEqualityPredicate}.
|
||||
*
|
||||
* @param node the given node
|
||||
* @return a predicate
|
||||
*/
|
||||
default Predicate<Node> equalTo(Node node) {
|
||||
return other -> areEqual(node, other);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Some 'default' implementations of NodeEqualityPredicate are provided below.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user