# API Methods and Events

## Methods

The main class for the API is `InteractionsAPI`. You can use this class whenever you want in your plugin.

```java
// Returns the conversation the player is currently in
PlayerConversation c = InteractionsAPI.getPlayerConversation(Player player)
```

```java
// Method to start a conversation from its file name (without .yml)
boolean startConversation = InteractionsAPI.startConversation(Player player,String conversationName)
```

```java
// Ends the current conversation the player is currently in
InterationsAPI.endConversation(Player player, ConversationEndReason reason)
```

## Events

```java
//Event called when a player is about to start a conversation. You can cancel
//cancel the event if you need to.
@EventHandler
public void conversationStart(ConversationStartEvent event){
   Player player = event.getPlayer();
   PlayerConversation c = event.getPlayerConversation();
}
```

```java
//Event called when a player has finished a conversation.
@EventHandler
public void conversationEnd(ConversationEndEvent event){
   Player player = event.getPlayer();
   PlayerConversation c = event.getPlayerConversation();
}
```

```java
//Event called when a player selects an option on a conversation. You can
//cancel the event if you need to.
@EventHandler
public void optionSelect(OptionSelectEvent event){
   Player player = event.getPlayer();
   PlayerConversation playerConversation = event.getPlayerConversation();
   Conversation c = event.getConversation();
   Option o = event.getOption();
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ajneb97.gitbook.io/interactions/api/api-methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
