public static class CommandFilter.Filter
extends java.lang.Object
Constructor and Description |
---|
CommandFilter.Filter(java.lang.String name,
java.lang.String predicate,
java.util.Set<PacketType> packets)
Construct a new immutable filter.
|
Modifier and Type | Method and Description |
---|---|
void |
close(javax.script.ScriptEngine context)
Clean up all associated code from this filter in the provided script engine.
|
void |
compile(javax.script.ScriptEngine context)
Force the compilation of a specific filter.
|
boolean |
evaluate(javax.script.ScriptEngine context,
PacketEvent event)
Evaluate the current filter using the provided ScriptEngine as context.
|
java.lang.String |
getName()
Retrieve the unique name of the filter.
|
java.lang.String |
getPredicate()
Retrieve the JavaScript predicate that will be used to filter packet events.
|
java.util.Set<PacketType> |
getRanges()
Retrieve a copy of the set of packets this filter applies to.
|
public CommandFilter.Filter(java.lang.String name, java.lang.String predicate, java.util.Set<PacketType> packets)
name
- - the unique name of the filter.predicate
- - the JavaScript predicate that will be used to filter packet events.packets
- - a list of packet types this filter applies to.public java.lang.String getName()
public java.lang.String getPredicate()
public java.util.Set<PacketType> getRanges()
public boolean evaluate(javax.script.ScriptEngine context, PacketEvent event) throws javax.script.ScriptException
This context may be modified with additional code.
context
- - the current script context.event
- - the packet event to evaluate.javax.script.ScriptException
- If the compilation failed or the filter is not valid.public void compile(javax.script.ScriptEngine context) throws javax.script.ScriptException
context
- - the current script context.javax.script.ScriptException
- If the compilation failed.public void close(javax.script.ScriptEngine context)
context
- - the current script context.