mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-17 13:25:03 +00:00
Remove MinimalApiProvider & refactor usages away from static access
This commit is contained in:
40 files changed
+242
-240
No files matched your search
@@ -41,6 +41,7 @@ import net.luckperms.api.model.user.UserManager;
|
||||
import net.luckperms.api.node.NodeBuilderRegistry;
|
||||
import net.luckperms.api.platform.Platform;
|
||||
import net.luckperms.api.platform.PluginMetadata;
|
||||
import net.luckperms.api.query.QueryOptionsRegistry;
|
||||
import net.luckperms.api.track.Track;
|
||||
import net.luckperms.api.track.TrackManager;
|
||||
|
||||
@@ -172,6 +173,14 @@ public interface LuckPerms {
|
||||
*/
|
||||
@NonNull NodeBuilderRegistry getNodeBuilderRegistry();
|
||||
|
||||
/**
|
||||
* Gets the {@link QueryOptionsRegistry}.
|
||||
*
|
||||
* @return the query options registry
|
||||
* @since 5.1
|
||||
*/
|
||||
@NonNull QueryOptionsRegistry getQueryOptionsRegistry();
|
||||
|
||||
/**
|
||||
* Gets the {@link MetaStackFactory}.
|
||||
*
|
||||
|
||||
@@ -45,64 +45,91 @@ public interface NodeBuilderRegistry {
|
||||
/**
|
||||
* Gets a {@link NodeBuilder} applicable for the given key.
|
||||
*
|
||||
* <p>Prefer using the {@link Node#builder(String)} accessor.</p>
|
||||
*
|
||||
* @param key the key
|
||||
* @return the node builder
|
||||
* @see Node#builder(String)
|
||||
*/
|
||||
@NonNull NodeBuilder<?, ?> forKey(String key);
|
||||
|
||||
/**
|
||||
* Gets a {@link NodeBuilder} for {@link PermissionNode}s.
|
||||
*
|
||||
* <p>Prefer using the {@link PermissionNode#builder()} accessor.</p>
|
||||
*
|
||||
* @return the node builder
|
||||
* @see PermissionNode#builder()
|
||||
*/
|
||||
PermissionNode.@NonNull Builder forPermission();
|
||||
|
||||
/**
|
||||
* Gets a {@link NodeBuilder} for {@link RegexPermissionNode}s.
|
||||
*
|
||||
* <p>Prefer using the {@link RegexPermissionNode#builder()} accessor.</p>
|
||||
*
|
||||
* @return the node builder
|
||||
* @see RegexPermissionNode#builder()
|
||||
*/
|
||||
RegexPermissionNode.@NonNull Builder forRegexPermission();
|
||||
|
||||
/**
|
||||
* Gets a {@link NodeBuilder} for {@link InheritanceNode}s.
|
||||
*
|
||||
* <p>Prefer using the {@link InheritanceNode#builder()} accessor.</p>
|
||||
*
|
||||
* @return the node builder
|
||||
* @see InheritanceNode#builder()
|
||||
*/
|
||||
InheritanceNode.@NonNull Builder forInheritance();
|
||||
|
||||
/**
|
||||
* Gets a {@link NodeBuilder} for {@link PrefixNode}s.
|
||||
*
|
||||
* <p>Prefer using the {@link PrefixNode#builder()} accessor.</p>
|
||||
*
|
||||
* @return the node builder
|
||||
* @see PrefixNode#builder()
|
||||
*/
|
||||
PrefixNode.@NonNull Builder forPrefix();
|
||||
|
||||
/**
|
||||
* Gets a {@link NodeBuilder} for {@link SuffixNode}s.
|
||||
*
|
||||
* <p>Prefer using the {@link SuffixNode#builder()} accessor.</p>
|
||||
*
|
||||
* @return the node builder
|
||||
* @see SuffixNode#builder()
|
||||
*/
|
||||
SuffixNode.@NonNull Builder forSuffix();
|
||||
|
||||
/**
|
||||
* Gets a {@link NodeBuilder} for {@link MetaNode}s.
|
||||
*
|
||||
* <p>Prefer using the {@link MetaNode#builder()} accessor.</p>
|
||||
*
|
||||
* @return the node builder
|
||||
* @see MetaNode#builder()
|
||||
*/
|
||||
MetaNode.@NonNull Builder forMeta();
|
||||
|
||||
/**
|
||||
* Gets a {@link NodeBuilder} for {@link WeightNode}s.
|
||||
*
|
||||
* <p>Prefer using the {@link WeightNode#builder()} accessor.</p>
|
||||
*
|
||||
* @return the node builder
|
||||
* @see WeightNode#builder()
|
||||
*/
|
||||
WeightNode.@NonNull Builder forWeight();
|
||||
|
||||
/**
|
||||
* Gets a {@link NodeBuilder} for {@link DisplayNameNode}s.
|
||||
*
|
||||
* <p>Prefer using the {@link DisplayNameNode#builder()} accessor.</p>
|
||||
*
|
||||
* @return the node builder
|
||||
* @see DisplayNameNode#builder()
|
||||
*/
|
||||
DisplayNameNode.@NonNull Builder forDisplayName();
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public interface QueryOptions {
|
||||
* @return the default non contextual query options
|
||||
*/
|
||||
static @NonNull QueryOptions nonContextual() {
|
||||
return DefaultQueryOptions.nonContextual();
|
||||
return LuckPermsProvider.get().getQueryOptionsRegistry().defaultNonContextualOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +107,7 @@ public interface QueryOptions {
|
||||
* @return the default contextual query options
|
||||
*/
|
||||
static @NonNull QueryOptions defaultContextualOptions() {
|
||||
return DefaultQueryOptions.contextual();
|
||||
return LuckPermsProvider.get().getQueryOptionsRegistry().defaultContextualOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+26
-26
@@ -25,35 +25,35 @@
|
||||
|
||||
package net.luckperms.api.query;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* Some default {@link QueryOptions} instances.
|
||||
* A registry providing useful {@link QueryOptions} instances.
|
||||
*
|
||||
* @since 5.1
|
||||
*/
|
||||
final class DefaultQueryOptions {
|
||||
private DefaultQueryOptions() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
public interface QueryOptionsRegistry {
|
||||
|
||||
private static boolean setup = false;
|
||||
private static QueryOptions contextual;
|
||||
private static QueryOptions nonContextual;
|
||||
/**
|
||||
* Gets the default {@link QueryMode#CONTEXTUAL contextual}
|
||||
* query options.
|
||||
*
|
||||
* <p>Prefer using the {@link QueryOptions#defaultContextualOptions()} accessor.</p>>
|
||||
*
|
||||
* @return the default contextual query options
|
||||
* @see QueryOptions#defaultContextualOptions()
|
||||
*/
|
||||
@NonNull QueryOptions defaultContextualOptions();
|
||||
|
||||
private static void setup() {
|
||||
if (setup) {
|
||||
return;
|
||||
}
|
||||
setup = true;
|
||||
contextual = QueryOptions.builder(QueryMode.CONTEXTUAL).build();
|
||||
nonContextual = QueryOptions.builder(QueryMode.NON_CONTEXTUAL).build();
|
||||
}
|
||||
|
||||
static QueryOptions contextual() {
|
||||
setup();
|
||||
return contextual;
|
||||
}
|
||||
|
||||
static QueryOptions nonContextual() {
|
||||
setup();
|
||||
return nonContextual;
|
||||
}
|
||||
/**
|
||||
* Gets the default {@link QueryMode#NON_CONTEXTUAL non contextual}
|
||||
* query options.
|
||||
*
|
||||
* <p>Prefer using the {@link QueryOptions#nonContextual()} accessor.</p>>
|
||||
*
|
||||
* @return the default non contextual query options
|
||||
* @see QueryOptions#nonContextual()
|
||||
*/
|
||||
@NonNull QueryOptions defaultNonContextualOptions();
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user