1
0
mirror of https://github.com/lucko/LuckPerms.git synced 2025-08-25 07:20:44 +02:00

MetaCache refactoring

This commit is contained in:
Luck
2022-07-17 11:53:52 +01:00
parent 016f35a6f0
commit bf93077474
9 changed files with 257 additions and 89 deletions

View File

@@ -29,6 +29,7 @@ import net.luckperms.api.metastacking.MetaStackDefinition;
import net.luckperms.api.node.types.MetaNode;
import net.luckperms.api.node.types.PrefixNode;
import net.luckperms.api.node.types.SuffixNode;
import net.luckperms.api.node.types.WeightNode;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -177,6 +178,30 @@ public interface CachedMetaData extends CachedData {
return querySuffix().result();
}
/**
* Query for a weight.
*
* <p>This method will always return a {@link Result}, and the
* {@link Result#result() inner result} {@link Integer} will never be null.
* A value of {@code 0} is equivalent to null.</p>
*
* @return a result containing the weight
* @since 5.5
*/
@NonNull Result<Integer, WeightNode> queryWeight();
/**
* Gets the weight.
*
* <p>If the there is no defined weight, {@code 0} is returned.</p>
*
* @return the weight
* @since 5.5
*/
default int getWeight() {
return queryWeight().result();
}
/**
* Gets a map of all accumulated {@link MetaNode meta}.
*