Skip to content

Commit

Permalink
Add PlayerPaginationTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelillo15 committed Jul 4, 2024
1 parent 567e57b commit f68b52e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void onEnable() {
saveResource("gui/GuiLayoutTest.xml", false);
saveResource("gui/PaginationTest.peb", true);
saveResource("gui/PaginationCommon.peb", true);
saveResource("gui/PlayerPaginationTest.peb", true);

engine = new PaperNookureInventoryEngine.Builder()
.templateFolder("gui")
Expand All @@ -47,6 +48,13 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab
return true;
}

if (args.length > 0 && args[0].equals("players")) {
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());

engine.openAsync(player, "PlayerPaginationTest.peb", "players", players, "page", 1, "player", player);
return true;
}

engine.openAsync(player, "GuiLayoutTest.xml");
}
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{# @pebvariable name="page" type="java.lang.Integer" #}
{# @pebvariable name="pagination" type="com.nookure.core.inv.template.extension.PaginationItemExtension.PaginationData" #}
{# @pebvariable name="players" type="java.util.List" #}
{# @pebvariable name="player" type="org.bukkit.entity.Player" #}
{% import "PaginationCommon.peb" %}
<GuiLayout>
<Head>
<title tl="true">
[#F5A9C1]Players[#F5A9C1] >> [green]Page {{ page }}[/green]
</title>
<rows>6</rows>
</Head>
<Items>
{% set pag = pagination(9, 5, page, players.size) %}
{% for i in range(pag.start, pag.end, 1) %}
{% set player = players[i] %}
{% set slot = i - pag.start %}
<Item
slot="{{ slot }}"
headType="PLAYER_UUID"
head="{{ player.uniqueId }}"
>
<Name>
[red]{{ player.name }}[/red]
</Name>
<Lore>
<LoreLine>
[red]Magic Stone [/red]
</LoreLine>
<LoreLine>
[blue]Line 2[/blue]
</LoreLine>
</Lore>
<Actions>
<Action
type="CLOSE_INVENTORY"
/>
<Action
type="SEND_MESSAGE"
value="[green]Hello World!"
/>
</Actions>
</Item>
{% endfor %}
{{ paginationFooter(48, 50, page, pag) }}
</Items>
</GuiLayout>

0 comments on commit f68b52e

Please sign in to comment.