|
|
|
| **DISCLAIMER** |
|
|
|
|
| :------: |
|
|
|
|
| *The following is a feature only available in Mythic Dungeons 1.3.0+!* |
|
|
|
|
|
|
|
|
Mythic Dungeons has an extensive API for creating your own functions, triggers, and conditions for use in dungeons. We call these "Dungeon Elements". Many of them share code, and require a little work to setup in order to support the in-game menus needed to access them. Here, we will explore concepts that apply to all elements.
|
|
|
|
|
|
|
|
## Important Annotations
|
|
|
|
### Saved Fields
|
|
|
|
Mythic Dungeons will automatically save and load values stored on a Dungeon Element when players configure them in-game, however you must specify what you want to save and load! This is indicated with the `@SavedField` annotation.
|
|
|
|
|
|
|
|
```java
|
|
|
|
@SavedField private String message; // Mythic Dungeons will save and load this value.
|
|
|
|
private int delay; // Mythic Dungeons will NOT save and load this value.
|
|
|
|
```
|
|
|
|
|
|
|
|
Saved fields will also be displayed in the menus of meta elements, such as the multi-function.
|
|
|
|
![](https://i.imgur.com/LpMGOEx.png)
|
|
|
|
|
|
|
|
### Hidden Fields
|
|
|
|
But what if you don't want your saved field to appear in the menus of meta elements? This is achieved with the `@Hidden` annotation.
|
|
|
|
|
|
|
|
```java
|
|
|
|
@SavedField private String message; // Mythic Dungeons will display this in the meta element menu.
|
|
|
|
@Hidden @SavedField private int delay; // Mythic Dungeons will NOT display this in the meta element menu.
|
|
|
|
```
|
|
|
|
|
|
|
|
## Required Constructors
|
|
|
|
Due to constraints with automatically saving and loading elements, **all dungeon elements must include two constructors.**
|
|
|
|
- A constructor with no parameters: `public FunctionMessage()`
|
|
|
|
- A constructor taking a <String, Object> map as a parameter: `public FunctionMessage(Map<String, Object> config)`
|
|
|
|
|
|
|
|
```java
|
|
|
|
public FunctionMessage() {
|
|
|
|
super("Message"); // Parameter for the element's unique name.
|
|
|
|
}
|
|
|
|
|
|
|
|
public FunctionMessage(Map<String, Object> config) {
|
|
|
|
super("Message", config); // Parameter for the element's unique name and the config map.
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
The first constructor is used to create a brand new instance of the element with default options.
|
|
|
|
The second constructor is used to load an existing element and all of its saved fields, which are stored in the map.
|
|
|
|
|
|
|
|
Within these constructors, you can configure certain details of your element, such as what category it belongs to, its colour when displayed, whether it requires a target, etc. What options are available for different kinds of elements will be explored in their tutorials.
|
|
|
|
|
|
|
|
_You shouldn't ever need to call these constructors yourself! They are only required for Mythic Dungeons' internal systems to be able to use your custom element!_ |
|
|
|
\ No newline at end of file |