Form Window tools for Nukkit and NukkitX plugin developers
GUI - FormWindow tools ()Chinese README
This plugin is made for developers. By using GUI, you can easily create forms. Contribution is welcomed
Only available in Kotlin Learn more in Sample for showing FormSimple
player.showFormSimple() {
title("Set title here")
content("Set content here")
buttons("Button1", "Button2", "Vararg buttons")
onClicked {//it: Int
player.sendMessage("You clicked a button whose id is $it")
}
onClosed {//it: Player
it.sendMessage("You closed the form")
}
}
(ResponseListener.java) Sample:
class A extends ResponsibleFormWindowSimple {
A() {
super("Title", "Content");
addButton(new ElementButton("Say Hi"));
addButton(new ElementButton("Say Hello"));
}
public void onClicked(int id, Player player) {
switch (id){
case 0:
player.sendMessage("Hi");
break;
case 1:
player.sendMessage("Hello");
break;
}
}
public void onClosed(Player player) {
player.sendMessage("You Closed");
}
}
Functional method(lambda) support
You can send FormWindow and process only in one line
Sample:
player.showFormWindow(new FormModal("Tips", "Hello", "Yes", "No") .onResponded(confirmation -> player.sendMessage("Your choice:"+confirmation)));
ResponsibleFormWindowSimpleAdvanced.java:
ResponseListener and Functional listeners can be used at the same time Notice that: ResponseListener will be called before Functional listeners
ResponsibleButton for ResponsibleFormWindowSimple Sample:
class A extends ResponsibleFormWindowSimple {
A() {
super("Title", "Content");
addButton("Say Hi", player->player.sendMessage("Hi"));//fast addButton
addButton(new ResponsibleElementButton("Say Hello", player->player.sendMessage("Hello")));//common addButton
}
public void onClosed(Player player) {
player.sendMessage("You Closed");
}
}
ResponsibleFormWindowSimpleAdvanced This is a wonderful implement of ResponsibleFormWindowSimple! (I can't translate this paragraph into English)
id , GUI . !
, 1 int, ID.
Simple , . ,
, , click, (List,Map) n , .
, . !
, java, ,
Please use a minute to check the source code
extends ResponsibleFormWindow
By using it, you can get responses from your custom key such as enum
, String
The template has checkers(parsers) to TemplateElementInput
, It can automatically check whether the input is correct.
(I can't translate this paragraph into English)
, ID"test" Input , , ID "test" . NKID, .
, , , , `Level`, `Player`, `Item`!(, 10, ?)
, . `ExceptionConsumer` . : , , https://github.com/Him188/GUI/blob/master/src/main/java/moe/him188/gui/window/ResponsibleFormWindowSimpleAdvanced.java?)
Please check the source code Or fast know hot wo use: template example
Each ResponsibleFormWindow
supports directly back to the window which has been sent before.
And you just need to code one line:
window.goBack(player);
You can also get players' latest windows, please view Backable.java
repository
in repositories
<repository>
<id>mamoe-repo</id>
<url>http://mamoe.net:8081/repository/public/</url>
</repository>
This repo may permanently work.dependency
in build.dependencies
<dependency>
<groupId>moe.him188</groupId>
<artifactId>gui</artifactId>
<version>LATEST</version>
</dependency>
Sometimes the 'LATEST' version signal does not work, in this case, you need to use the latest version, such as 1.14
instead.pom.xml
depend
into plugin.yml
depend:
- GUI
Run command mvn clean package
in project root path
Find JAR in target/