NukkitFormAPI
Form API for Nukkit. This API supports processing of form responses, so you do not have to make EventListener which processes ModalFormResponsePacket. It will provide you the new type of form processing.
Referenses
Depend with Maven
This API is developed by Maven project. So your plugin have to depend with this API through Maven.
<dependency>
<groupId>nukkit.form.api</groupId></dependency>
<artifactId>NukkitFormAPI</artifactId>
<version>Build-1.0</version>
Add EventListener
You have to register NukkitFormEventListener class to Nukkit Event processing system to handle events.
First, write these codes into onEnable() method.
//imports
import itsu.mcbe.form.event.NukkitFormEventListener;
//Write into onEnable() method
this.getServer().getPluginManager().registerEvents(new NukkitFormEventListener(), this);
SimpleForm(A simple form which has some buttons and textarea)
Button button1 = new Button() {
@Override}
public void onClick(Player player) {
//This method is called when "button1" button clicked.}
.setText("BUTTON_TEXT")
.setImage("url", "IMAGE_URL");
SimpleForm form = new SimpleForm() {
@Override}
public void onEnter(Player player, int index) {
//This method is called when player clicked button.}
//"index" variable expresses an index number of the button.
.setId(123) //Form Id
.setTitle("TITLE") //Title
.setContent("CONTENT_TEXT") //Texts
.addButton(button1); //Add button
//You can use: addButtons(List<Button>)
You can add listener to button through override "onClick()" method in Button class.
Or you can add listener to SimpleForm through override "onEnter()" method in SimpleForm class.
ModalForm(A form which has two buttons and one textarea)
ModalForm form = new ModalForm() {
@Override
public void onButton1Click(Player player) {
//This method is called when upside button clicked.}
@Override}
public void onButton2Click(Player player) {
//This method is called when downside button clicked.}
.setId(123) //Form id
.setTitle("TITLE") //Title
.setContent("CONTENT_TEXT"); //Text
You can add a listener through override "onButton1Click()" and "onButton2()" methods in ModalForm class.
(Button1 = upside button, Button2 = downside button)
CustomForm(A form which has various elements)
Java:
CustomForm form = new CustomForm() {
@Override}
public void onEnter(Player player, List<Object> response) {
//This method is called when enter the form.}
.setId(123) //ID
.setTitle("TITLE") //Title
.addFormElement(new Label("LABEL_TEXT"))
//This API has more types of form elements.
.addFormElement(new Input()
.setText("INPUT_TEXT"));
.setPlaceHolder("PLACEHOLDER_TEXT")
.setDefaultText("DEFAULT_TEXT")
//You can use: addFormElements(List<FormElements>)
You can add a listener through override "onEnter(List)" method in CustomForm class.
Send Form
NukkitFormAPI.sendFormToPlayer(Player, Form);
You must use this method when you send form you made from this API.
I recommend you to see GitHub: https://github.com/itsu020402/NukkitFormAPI

NukkitFormAPI 2018-04-24
Form API for Nukkit - Incorporate forms into your plugin very easily.
Search
Dismiss Notice
We welcome you on our site. This site is devoted to the Nukkit project and all that is connected with him.
Here you can communicate, download plugins, also many other things get acquainted!
Register the account right now :3