Package com.ohacd.matchbox.api
Interface ChatProcessor
public interface ChatProcessor
Interface for custom chat processors that can modify, filter, or reroute chat messages.
Servers can implement this interface to add custom chat behavior for specific sessions.
Processors are called in registration order and can:
- Modify message content or formatting
- Change the target channel
- Filter messages (deny/cancel)
- Add custom routing logic
Example usage:
public class CustomChatProcessor implements ChatProcessor {
public ChatProcessingResult process(ChatMessage message) {
// Add custom prefix for spectators
if (message.channel() == ChatChannel.SPECTATOR) {
Component newMessage = Component.text("[SPEC] ").append(message.formattedMessage());
return ChatProcessingResult.allowModified(message.withFormattedMessage(newMessage));
}
return ChatProcessingResult.allow(message);
}
}
- Since:
- 0.9.5
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordResult of chat processing with optional modified message. -
Method Summary
Modifier and TypeMethodDescription@NotNull ChatProcessor.ChatProcessingResultprocess(@NotNull ChatMessage message) Processes a chat message and returns the result.
-
Method Details
-
process
Processes a chat message and returns the result. This method is called for every message in the associated session.- Parameters:
message- the chat message to process (immutable)- Returns:
- the result of processing, including any modified message
-