FOR DEVELOPERS:
You can easily add the config editor option to your plugin by following these steps.
- Step 1. Install the plugin using maven -
Code (Text):
<repository>
<id>neomechanical-releases</id>
<url>https://hub.neomechanical.com/repository/maven-releases/</url>
</repository>
<!-- NeoUtils -->
<dependency>
<groupId>com.neomechanical</groupId>
<artifactId>NeoConfig</artifactId>
<version>ver</version>
</dependency>
or download the jar and install it with maven
Code (Text):
mvn install:install-file \
-Dfile= location/NeoConfig-ver.jar \
-DgroupId=com.neomechanical \
-DartifactId=NeoConfig \
-Dversion=ver \
-Dpackaging=jar \
-DgeneratePom=true
Replace ver with the latest version and location/NeoConfig-ver.jar with the location of the jar file. If you don't have maven you can install it following this guide
https://www.baeldung.com/install-maven-on-windows-linux-mac
- Step 2. Include the jar file in your maven dependencies -
Code (Text):
<!-- NeoConfig -->
<dependency>
<groupId>com.neomechanical</groupId>
<artifactId>NeoConfig</artifactId>
<version>ver</version>
</dependency>
Again, you will replace ver with the latest version.
- Step 3. Create your config editor
Create a ConfigMenu object, set your parameters and go.
Code (Java):
//NeoPerformance is an example plugin
ConfigMenu configMenu
=
new ConfigMenu
(NeoPerformance.
getInstance
(
)
)
;
configMenu.
onComplete
(
(playerAsAuthor, text
)
-> NeoPerformance.
reload
(
)
)
//Called one a player has finished editing a key
.
title
(
"Change key"
)
//Title of the anvil editor
.
onClose
(player
-> Logger.
info
(
"Anvil editor was closed"
)
)
//Function to run when the anvil editor is closed
.
permission
(
"neoperformance.config",
(
)
->
"You do not have permission to do that"
)
//Set the permission node and message to change a key
.
setPluginEditing
(myPluginInstance
)
//Set the menu for the player and plugin specified, if you don't specify a plugin instance to open the it will show all the plugins and their files
.
open
(playerAsPlayer
)
;
//Open the menu for the player specified
(Note) If you it doesn't work for you try manually shading the plugin or using the latest version of java and minecraft.
And your done.