> For the complete documentation index, see [llms.txt](https://vulkan-technologies.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vulkan-technologies.gitbook.io/documentation/vulkan-menu/api.md).

# API

We obviously provide you a complete API to interact with VulkanMenu directly in your plugin.

### First steps

Before you can actually make use of the API, you first have to import it into your project .\
Use the below code example matching your dependency manager.

{% hint style="success" %}
No needs for a custom repository, it's deployed on Maven Central!
{% endhint %}

#### Maven

```xml
<dependency>
    <groupId>com.vulkantechnologies</groupId>
    <artifactId>menu</artifactId>
    <version>1.0.6</version>
</dependency>
```

#### Gradle

```
implementation 'com.vulkantechnologies:menu:1.0.6'
```

#### Gradle Kotlin

```
implementation("com.vulkantechnologies:menu:1.0.6")
```

### Set VulkanMenu as (soft)depend

{% hint style="warning" %}
We do recommend setting VulkanMenu as a soft depend to your plugin so it won't disable if VulkaMenu is disabled.
{% endhint %}

```yaml
name: ExamplePlugin
version: 1.0
author: author
main: your.main.path.Here

softdepend: ["VulkanMenu"]
```

### Usage

We grouped all the useful methods in the `VMenuAPI` class.

#### Open a registered menu

```java
VMenuAPI.openMenu(player, "my-cool-menu");
```

#### Check if a player is in a menu

```java
boolean hasAnOpenMenu = VMenuAPI.hasOpenMenu(player);
```

#### Get the player's current menu

```java
Optional<Menu> currentMenu = VMenuAPI.getOpenMenu(player);
```

#### Get a menu configuration by its name

```java
Optional<MenuConfiguration> menuConfiguration = VMenuAPI.findMenuConfiguration("my-cool-menu");
```

#### Register a custom placeholder processor

```java
VMenuAPI.registerPlaceholderProcessor(new PlaceholderProcessor() {
    @Override
    public String process(Player player, String text) {
        return text.replace("%custom_placeholder%", "Custom Value");
    }
});
```

#### Close a player's menu

```java
VMenuAPI.closeMenu(player);
```

#### Reload all menus

```java
VMenuAPI.reloadMenus();
```

#### Get all loaded menu configurations

```java
Collection<MenuConfiguration> allMenus = VMenuAPI.getAllMenuConfigurations();
```
