-
Notifications
You must be signed in to change notification settings - Fork 0
2. Creating components
LitleProgrammer edited this page May 12, 2024
·
2 revisions
Creating components is easy.
- Create a new button and set it's texture, hover texture and it's slot (slots can range from 1-3 in SimpleGui's)
Button button = new Button("Normal Text", "Hover text", 1)
- You can set the size of the button
Button button = new Button("Normal Text", "Hover text", 1)
.setSize(2)
- You can listen to events such as:
The event variable is a org.bukkit.event.player.PlayerInteractEntityEvent
.onClick(event -> {
event.getPlayer().sendMessage("You clicked a button");
})
The event variable is a de.littleprogrammer.guiapi.customeEvents.HoverButtonEvent
.onHover(event -> {
event.getPlayer().sendMessage("You hovered over a button");
})
The event variable is a de.littleprogrammer.guiapi.customeEvents.UnHoverButtonEvent
.onUnHover(event -> {
event.getPlayer().sendMessage("You unhovered a button");
})
- Put everything together. A full grown button with all events can look like this
Button button = new Button("Normal Text", "Hover text", 1)
.setSize(2)
.onClick(event -> {
event.getPlayer().sendMessage("You clicked a button1");
})
.onHover(event -> {
event.getPlayer().sendMessage("You hovered over a button");
})
.onUnHover(event -> {
event.getPlayer().sendMessage("You unhovered a button");
});
- Create a new text with the text it should display
Text text = new Text("Here you can put some text for testing purposes")
- You can set the size of the text if you want
Text text = new Text("Here you can put some text for testing purposes")
.setSize(2);
If you have any questions regarding this, feel free to join my discord server https://discord.gg/YjmAFKTUHK