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

# Mines API

## Mines API

All of these live on `SimplyMinesAPI` (`SimplyMinesAPI.getInstance()`).

### Read mines

```java
BasicMine mine = api.getMine("diamond");        // null if it doesn't exist (exact name match)
Collection<BasicMine> allMines = api.getMines();
```

`BasicMine` exposes (among others):

| Method                                                                        | Description                                                     |
| ----------------------------------------------------------------------------- | --------------------------------------------------------------- |
| `isInsideMine(Location)`                                                      | Whether a location falls inside the mine's region.              |
| `getPercentageOfMineLeft()`                                                   | Percentage of the mine still unmined.                           |
| `getMainMaterial()`                                                           | The highest-weighted block in the composition.                  |
| `getPercentage(String block)` / `setPercentage(String block, double percent)` | Read/set a block's weight in the composition.                   |
| `getTotalPercentage()`                                                        | Sum of all configured block percentages.                        |
| `getMaterials()`                                                              | The full block-composition map.                                 |
| `addBlockBroken()`                                                            | Increments the mine's "blocks broken since last reset" counter. |
| `reset()`                                                                     | Triggers an immediate reset of the mine.                        |
| `isEnabled()`                                                                 | Whether the mine's auto-reset timer is enabled.                 |

***

### Create and delete mines

```java
BasicMine mine = new BasicMine(/* ... */);
api.addMine(mine);       // registers it in-memory only — persisted on the next scheduled save
```

```java
api.deleteMine("diamond");   // removes it from memory AND deletes mines/diamond.json from disk
```

{% hint style="warning" %}
`addMine` does **not** save to disk immediately — it's picked up by the next periodic save (`save_mines_seconds` in `config.yml`), or you can force it with `/sm save <name>` in-game.
{% endhint %}

***

### Read a player's wand selection

```java
Pair<Location, Location> corners = api.getPlayerSelection(player.getUniqueId());
if (corners != null && corners.first() != null && corners.second() != null) {
    // both corners have been selected
}
```

{% hint style="info" %}
This mirrors what `/sm create` and `/sm reassign` use internally — `first()`/`second()` may be `null` individually if the player has only selected one corner so far, or the whole `Pair` may be `null` if they haven't selected anything.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://simplymines.gitbook.io/simplymines-docs/introduction/api-developer-guide/mines-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
