> For the complete documentation index, see [llms.txt](https://glitchtechs.gitbook.io/galaxy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://glitchtechs.gitbook.io/galaxy/starapi-spigot-paper/builders/message-builder.md).

# Message Builder

Create messages with hover events and other cool stuff

### Overview

The `MessageBuilder` class provides utility methods to build clickable and hoverable text components using the BungeeCord API.

### Methods

#### `buildHoverText`

```java
public static TextComponent buildHoverText(TextComponent baseComponent, String hoverText)
```

Builds a hoverable text component with the specified base component and hover text.

**Parameters**

* `baseComponent`: The base TextComponent to which the hover event will be added.
* `hoverText`: The text to be displayed when hovering over the base component.

**Returns**

* `TextComponent`: The modified TextComponent with the added hover event.

#### `buildCommandText`

```java
public static TextComponent buildCommandText(String text, String clickCommand)
```

Builds a clickable text component with the specified text and command to be executed when clicked.

**Parameters**

* `text`: The text to be displayed.
* `clickCommand`: The command to be executed when the text is clicked.

**Returns**

* `TextComponent`: The clickable TextComponent.

#### `buildEntityText`

```java
public static TextComponent buildEntityText(String text, EntityType entityType)
```

Builds a hoverable text component displaying information about an entity type when hovered over.

**Parameters**

* `text`: The text to be displayed.
* `entityType`: The EntityType to be displayed information about.

**Returns**

* `TextComponent`: The hoverable TextComponent displaying entity information.

#### `buildOpenUrlText`

```java
public static TextComponent buildOpenUrlText(String text, String url)
```

Builds a clickable text component that opens a URL when clicked.

**Parameters**

* `text`: The text to be displayed.
* `url`: The URL to be opened when the text is clicked.

**Returns**

* `TextComponent`: The clickable TextComponent.

### Usage

1. Use the static methods of the `MessageBuilder` class to create clickable and hoverable text components.
2. Provide the necessary parameters to each method to customize the text behavior.
3. Use the returned `TextComponent` objects wherever you need to display formatted and interactive text in your plugin.

### Example

```java
// Build a hoverable text component
TextComponent hoverTextComponent = new TextComponent("Hover me!");
MessageBuilder.buildHoverText(hoverTextComponent, "This is hover text.");

// Build a clickable text component with a command
TextComponent commandTextComponent = MessageBuilder.buildCommandText("Click me!", "/example_command");

// Build a hoverable text component displaying entity information
TextComponent entityTextComponent = MessageBuilder.buildEntityText("Entity info", EntityType.ZOMBIE);

// Build a clickable text component that opens a URL
TextComponent openUrlTextComponent = MessageBuilder.buildOpenUrlText("Open link", "https://example.com");
```
