Package cn.nukkit.command.selector.args
Class CachedFilterSelectorArgument
java.lang.Object
cn.nukkit.command.selector.args.CachedFilterSelectorArgument
- All Implemented Interfaces:
ISelectorArgument
,Comparable<ISelectorArgument>
- Direct Known Subclasses:
C
@PowerNukkitXOnly
@Since("1.19.60-r1")
public abstract class CachedFilterSelectorArgument
extends Object
implements ISelectorArgument
与
CachedSimpleSelectorArgument
类似,但是适用于过滤器模式。此处不做过多解释- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncache
(SelectorType selectorType, CommandSender sender, Location basePos, String... arguments) 当未在缓存中找到解析结果时,则调用此方法对参数进行解析getFilter
(SelectorType selectorType, CommandSender sender, Location basePos, String... arguments) 仅当方法isFilter()返回true时调用此方法boolean
isFilter()
是否启用过滤器模式初始化缓存时调用此方法Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface cn.nukkit.command.selector.args.ISelectorArgument
compareTo, getDefaultValue, getKeyName, getPredicate, getPriority
-
Constructor Details
-
CachedFilterSelectorArgument
public CachedFilterSelectorArgument()
-
-
Method Details
-
getFilter
public Function<List<Entity>,List<Entity>> getFilter(SelectorType selectorType, CommandSender sender, Location basePos, String... arguments) throws SelectorSyntaxException Description copied from interface:ISelectorArgument
仅当方法isFilter()返回true时调用此方法 方法返回的实体集合将传递到下一个参数- Specified by:
getFilter
in interfaceISelectorArgument
- Parameters:
selectorType
- 选择器类型sender
- 命令发送者basePos
- 若此参数解析需要用到相对坐标,则应该以此坐标为依据 若此参数需要修改参照坐标(例如x,y,z参数),则应当在这个参数上修改 在一条解析链上的参数只会使用一个Location对象arguments
- 参数列表- Returns:
- 实体过滤器
- Throws:
SelectorSyntaxException
- 当解析出错
-
isFilter
public boolean isFilter()Description copied from interface:ISelectorArgument
是否启用过滤器模式 若一个参数为过滤器模式,解析器将不会调用getPredicate()方法而是调用filter()方法 这意味着参数将对到达此参数节点的所有实体进行检测,而不是相对于单个实体进行检测 对于部分参数(例如"c"),需要启用此功能- Specified by:
isFilter
in interfaceISelectorArgument
- Returns:
- 是否启用过滤器模式
-
cache
protected abstract Function<List<Entity>,List<Entity>> cache(SelectorType selectorType, CommandSender sender, Location basePos, String... arguments) throws SelectorSyntaxException 当未在缓存中找到解析结果时,则调用此方法对参数进行解析- Throws:
SelectorSyntaxException
-
provideCacheService
protected com.github.benmanes.caffeine.cache.Cache<Set<String>,Function<List<Entity>, provideCacheService()List<Entity>>> 初始化缓存时调用此方法 若需要自己的缓存实现,则可覆写此方法- Returns:
Cache<Set<String>, Function<List<Entity>, List<Entity>>>
-