From 9ef683eaea0b9f7649e7dc4930e8c4da9cd197c9 Mon Sep 17 00:00:00 2001 From: Angelillo15 Date: Fri, 5 Jul 2024 14:56:21 +0200 Subject: [PATCH] Add example command from documentation --- .../com/nookure/core/inv/ExampleCommand.java | 27 +++++++++ .../main/java/com/nookure/core/inv/Main.java | 2 + .../src/main/resources/gui/our-first-gui.xml | 60 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 NookureInventory-Test/src/main/java/com/nookure/core/inv/ExampleCommand.java create mode 100644 NookureInventory-Test/src/main/resources/gui/our-first-gui.xml diff --git a/NookureInventory-Test/src/main/java/com/nookure/core/inv/ExampleCommand.java b/NookureInventory-Test/src/main/java/com/nookure/core/inv/ExampleCommand.java new file mode 100644 index 0000000..8c759fe --- /dev/null +++ b/NookureInventory-Test/src/main/java/com/nookure/core/inv/ExampleCommand.java @@ -0,0 +1,27 @@ +package com.nookure.core.inv; + +import com.nookure.core.inv.paper.PaperNookureInventoryEngine; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class ExampleCommand extends Command { + private final PaperNookureInventoryEngine engine; + + protected ExampleCommand(@NotNull PaperNookureInventoryEngine engine) { + super("example"); + this.engine = engine; + } + + @Override + public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) { + if (sender instanceof Player player) { + engine.openAsync(player, "our-first-gui.xml"); + return true; + } + + sender.sendRichMessage("You are the console!"); + return true; + } +} diff --git a/NookureInventory-Test/src/main/java/com/nookure/core/inv/Main.java b/NookureInventory-Test/src/main/java/com/nookure/core/inv/Main.java index 7f57a6d..8547f8c 100644 --- a/NookureInventory-Test/src/main/java/com/nookure/core/inv/Main.java +++ b/NookureInventory-Test/src/main/java/com/nookure/core/inv/Main.java @@ -26,6 +26,7 @@ public void onEnable() { saveResource("gui/PaginationTest.peb", true); saveResource("gui/PaginationCommon.peb", true); saveResource("gui/PlayerPaginationTest.peb", true); + saveResource("gui/our-first-gui.xml", false); engine = new PaperNookureInventoryEngine.Builder() .templateFolder("gui") @@ -34,6 +35,7 @@ public void onEnable() { .build(); CommandMap commandMap = Bukkit.getServer().getCommandMap(); + commandMap.register("nookure", new ExampleCommand(engine)); commandMap.register("nookure", new Command("test") { @Override diff --git a/NookureInventory-Test/src/main/resources/gui/our-first-gui.xml b/NookureInventory-Test/src/main/resources/gui/our-first-gui.xml new file mode 100644 index 0000000..a5dbc1b --- /dev/null +++ b/NookureInventory-Test/src/main/resources/gui/our-first-gui.xml @@ -0,0 +1,60 @@ + + + + + + + [#FF6545] Your awesome inventory + + + 1 + + + + + + + + [red]Magic Stone ✨[/red] + + + + This is a magic stone + [red]It's very powerful[/red] + + + + \ No newline at end of file