-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the SimplestGUI wiki! This wiki will show you how to build a GUI with SimplestGUI.
Assuming you are using Maven.
First, add my repository:
<repository>
<id>lss233-repo</id>
<name>Lss233's Mirror</name>
<url>https://lss233.littleservice.cn/repositories/minecraft</url>
</repository>
Then, add this dependency:
<dependency>
<groupId>com.lss233</groupId>
<artifactId>SimplestGUI</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Tip: Remember to replace the
1.0-SNAPSHOT
version with the latest version:
Add following to your plugin.yml
:
depend: [SimplestGUI]
First, let's make a GUI class that extends GUI
, you will get:
public class TestGUI extends Gui{
public TestGUI(Player player) {
super(TestPlugin.getInstance(), player, "A test gui", 9);
}
@Override
protected void draw() {
}
@Override
protected void onClosed() {
}
}
This method will be called everytime the gui is opened to the player.
You can put components inside this method.
This method puts a component to the GUI.
A component is an ItemStack showing on the Inventory.
This method will be called everytime the gui is closed by player.
Let's put a button on the second slot.
@Override
protected void draw() {
setComponent(1, new Component.Builder()
.icon(Material.CARROT_STICK)
.title("Test button")
.lore(Arrays.asList("A", "Test", "BUTTON"))
.click((user, click) -> {
if(click.equals(ClickType.LEFT)){
user.sendMessage("You left clicked this");
} else if(click.equals(ClickType.RIGHT)) {
user.sendMessage("You right clicked this");
}
})
.build());
}
Cool, isn't it?
TestGUI gui = new TestGUI(player);
gui.open();
And... it is done!
If you want to know some more advanced usage, check out our other chapters on the wiki!