Skip to content

Commit a23d60c

Browse files
Wiki work
- Added some pages to the wiki - Changed the code for the command to mirror the code in the wiki
1 parent f6ff359 commit a23d60c

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/main/java/de/littleprogrammer/guiapi/SimpleGui.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ public class SimpleGui {
1717
private final UUID uuid;
1818
private final Map<UUID, Component> components;
1919
private final Map<UUID, Button> buttons;
20+
private final String title;
2021
private Component content;
2122
private Location centerLocation;
2223
private boolean open;
2324

24-
public SimpleGui(String title, int gridWidth, int gridHeight) {
25+
public SimpleGui(String title) {
26+
this.title = title;
2527
this.uuid = UUID.randomUUID();
2628
this.components = new HashMap<>();
2729
this.buttons = new HashMap<>();

src/main/java/de/littleprogrammer/guiapi/commands/SpawnCommand.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@
1111
public class SpawnCommand implements CommandExecutor {
1212
@Override
1313
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
14-
Button button = new Button("\uE001", "\uE002", 1).setSize(2).onClick(event -> {
15-
event.getPlayer().sendMessage("You clicked a button1");
16-
});
14+
Button button = new Button("\uE001", "\uE002", 1)
15+
.setSize(2)
16+
.onClick(event -> {
17+
event.getPlayer().sendMessage("You clicked a button1");
18+
})
19+
.onHover(event -> {
20+
event.getPlayer().sendMessage("You hovered over a button");
21+
})
22+
.onUnHover(event -> {
23+
event.getPlayer().sendMessage("You unhovered a button");
24+
});
1725

1826
Button button2 = new Button("\uE001", "\uE002", 2).onClick(event -> {
1927
event.getPlayer().sendMessage("You clicked a button2");
@@ -23,7 +31,14 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
2331
event.getPlayer().sendMessage("You clicked a button3");
2432
});
2533

26-
SimpleGui gui = new SimpleGui("Some title", 1, 1).addContent(new Text("Test").setSize(2)).addButton(button).addButton(button2).addButton(button3);
34+
Text text = new Text("Here you can put some text for testing purposes")
35+
.setSize(2);
36+
37+
SimpleGui gui = new SimpleGui("Some title")
38+
.addContent(text)
39+
.addButton(button)
40+
.addButton(button2)
41+
.addButton(button3);
2742
gui.open((Player) commandSender);
2843

2944
return false;

0 commit comments

Comments
 (0)