Package com.comphenix.protocol
Class CommandFilter.Filter
java.lang.Object
com.comphenix.protocol.CommandFilter.Filter
- Enclosing class:
CommandFilter
A filter that will be used to process a packet event.
-
Constructor Summary
ConstructorsConstructorDescriptionFilter(String name, String predicate, Set<PacketType> packets) Construct a new immutable filter. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose(ScriptEngine context) Clean up all associated code from this filter in the provided script engine.voidcompile(ScriptEngine context) Force the compilation of a specific filter.booleanevaluate(ScriptEngine context, PacketEvent event) Evaluate the current filter using the provided ScriptEngine as context.getName()Retrieve the unique name of the filter.Retrieve the JavaScript predicate that will be used to filter packet events.Retrieve a copy of the set of packets this filter applies to.
-
Constructor Details
-
Filter
Construct a new immutable filter.- Parameters:
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.
-
-
Method Details
-
getName
Retrieve the unique name of the filter.- Returns:
- Unique name of the filter.
-
getPredicate
Retrieve the JavaScript predicate that will be used to filter packet events.- Returns:
- Predicate itself.
-
getRanges
Retrieve a copy of the set of packets this filter applies to.- Returns:
- Set of packets this filter applies to.
-
evaluate
Evaluate the current filter using the provided ScriptEngine as context.This context may be modified with additional code.
- Parameters:
context- - the current script context.event- - the packet event to evaluate.- Returns:
- TRUE to pass this packet event on to the debug listeners, FALSE otherwise.
- Throws:
ScriptException- If the compilation failed or the filter is not valid.
-
compile
Force the compilation of a specific filter.- Parameters:
context- - the current script context.- Throws:
ScriptException- If the compilation failed.
-
close
Clean up all associated code from this filter in the provided script engine.- Parameters:
context- - the current script context.
-