Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek committed Oct 5, 2024
1 parent 547e5a9 commit b37a061
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ dependencies {
### Code
```java
public final class Plugin extends JavaPlugin {
public static final TypedKey<CommandSender> CONSOLE_KEY =
TypedKey.of(CommandSender.class, "console");

private final Frame frame = Frame.create(this)
.with();

@Override
public void onEnable() {
this.frame.register();
this.frame.register(builder ->
builder.add(Plugin.CONSOLE_KEY, Bukkit.getConsoleSender()));
}
}

Expand All @@ -48,14 +52,15 @@ public final class View implements ViewHandler {

@Override
public void onFirstRender(@NotNull final ContextRender ctx) {
final CommandSender sender = ctx.instances().getOrThrow(Plugin.CONSOLE_KEY);
ctx.layoutSlot('x', new ItemStack(Material.GRAY_STAINED_GLASS_PANE));

ctx
.layoutSlot('a', new ItemStack(Material.DIAMOND))
.cancelOnClick()
.onClick(context -> {
context.closeForViewer();
context.clicker().sendMessage("You've clicked to a diamond!");
sender.sendMessage("Player " + context.clicker() + " clicked to a diamond!");
});
}
}
Expand Down

0 comments on commit b37a061

Please sign in to comment.