Auto Responses
Create predefined auto responses
Overview
The AutoResponses
class provides a utility for automatically responding to specific triggers in chat messages. This class allows you to define trigger-response pairs, play sounds, and display titles to players when a trigger is detected in a chat message.
Methods
autoResponses
autoResponses
Adds a trigger-response pair to the auto-responses map.
Parameters
trigger
: The trigger string to be detected in chat messages.response
: The response string to be sent when the trigger is detected.
Returns
AutoResponses
: ThisAutoResponses
instance for method chaining.
playSound
playSound
Sets the sound to be played when a trigger is detected.
Parameters
sound
: The Sound enum representing the sound to be played.volume
: The volume of the sound (0.0 to 1.0).pitch
: The pitch of the sound (0.5 to 2.0).
Returns
AutoResponses
: ThisAutoResponses
instance for method chaining.
sendTitle
sendTitle
Sets the title and subtitle to be displayed when a trigger is detected.
Parameters
title
: The title text to be displayed.subtitle
: The subtitle text to be displayed.
Returns
AutoResponses
: ThisAutoResponses
instance for method chaining.
build
build
Processes the chat message and triggers the corresponding response actions.
Parameters
player
: The player who sent the chat message.message
: The chat message to be processed.
Usage
Create an instance of the
AutoResponses
class.Add trigger-response pairs using the
autoResponses
method.Optionally, set sound and title/subtitle using the
playSound
andsendTitle
methods, respectively.Call the
build
method with the player and chat message to process the message and trigger responses.
Example
Last updated