⭐
StarAPI Documentation
  • ⭐API Information
    • ❔About Our API's
    • ⬇️Installing Our API
  • 🌟StarAPI (Spigot/Paper)
    • 📂Abilities
      • ⏳Transmition
      • 🤯Implosion
      • 🏹MultiShot
    • 📂Builders
      • 👕Armor Builder
      • 📊Bossbar Builder
      • ☄️Command Builder
      • ⚔️Item Builder
      • 🧟‍♂️Mob Builder
      • 💯Scoreboard Builder
      • 🔗Webhook Builder
      • 🔨Message Builder
      • 🏗️Actionbar Builder
    • 📂Files
      • 📃Create Files
      • 📁Create Folders
      • 📖Read Files
      • 🖊️Write Files
    • 📂Inventory Utilities
      • 💎Animated Items
      • 📖Book Content
      • 📔Book GUI
      • 🎞️Filler
      • 🪁Inventory Items
      • 📝Inventory Name
      • 💀Inventory Skulls
    • 📂Message Utilities
      • 🤖Auto Responses
      • 🎨Message Colors
    • 📂Recipes
      • ⚒️Crafting Recipes
      • 🧑‍🍳Furnace Recipes
    • 📂Timers
      • 🕙Active Timers
      • ❌Cancel Timers
      • 🕙Delayed Timers
      • 🕐Create Timers
    • 📂Misc
      • 💀Give Skulls
      • 📈Progress Bars
      • ⬛Block Placer
Powered by GitBook
On this page
  • Overview
  • Methods
  • Usage
  • Example
  1. StarAPI (Spigot/Paper)
  2. Message Utilities

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

public AutoResponses autoResponses(String trigger, String response)

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: This AutoResponses instance for method chaining.

playSound

public AutoResponses playSound(Sound sound, float volume, float pitch)

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: This AutoResponses instance for method chaining.

sendTitle

public AutoResponses sendTitle(String title, String subtitle)

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: This AutoResponses instance for method chaining.

build

public void build(Player player, String message)

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

  1. Create an instance of the AutoResponses class.

  2. Add trigger-response pairs using the autoResponses method.

  3. Optionally, set sound and title/subtitle using the playSound and sendTitle methods, respectively.

  4. Call the build method with the player and chat message to process the message and trigger responses.

Example

// Create an instance of AutoResponses
AutoResponses autoResponses = new AutoResponses();

// Add trigger-response pairs
autoResponses.autoResponses("hello", "Hi there!");

// Set sound and title/subtitle
autoResponses.playSound(Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.0f)
            .sendTitle("Title", "Subtitle");

// Process chat message and trigger responses
autoResponses.build(player, chatMessage);
PreviousMessage UtilitiesNextMessage Colors

Last updated 1 year ago

🌟
📂
🤖