GithubHelp home page GithubHelp logo

phoenix616 / inventorygui Goto Github PK

View Code? Open in Web Editor NEW
162.0 9.0 19.0 368 KB

A library for Bukkit plugins to create GUIs with inventories

Home Page: https://wiki.phoenix616.dev/library/inventorygui/

License: MIT License

Java 100.00%
bukkit spigot inventory gui minecraft java java-8

inventorygui's Introduction

InventoryGui

A library that simplifies the creation of chest GUIs for Bukkit/Spigot plugins and allows assigning of the GUI to a specific InventoryHolder. If you are in need of a GUI for text inputs then take a look at WesJD's AnvilGUI library.

Please note that this is not a plugin!

Requires Java 8.

Using InventoryGui

Take a look at the examples in the wiki to learn how to create a GUI with this library or use the InventoryGui Javadocs.

Maven information

You can easily depend on the library with maven.

<repositories>
    <repository>
        <id>minebench-repo</id>
        <url>https://repo.minebench.de/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>de.themoep</groupId>
        <artifactId>inventorygui</artifactId>
        <!--The following version may not be the latest. Check it before using.-->
        <version>1.6.1-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

As this is not a standalone plugin you have to shade it into your plugin! E.g. with the maven-shade-plugin like this.

You can also get development builds directly from the Minebench Jenkins ci server if you want to manually add it to your project but I strongly advise using a dependency management tool like maven or gradle!

License

InventoryGui is licensed under the following, MIT license:

Copyright 2017 Max Lee (https://github.com/Phoenix616)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

inventorygui's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inventorygui's Issues

GuiPageElements are not shown.

Hey,

I did some testing today and noticed that the GuiPageElements are not displayed. If you click where they would actually be, the page changes anyway.

Sincerely yours

getPageAmount doesn't return the correct amount of pages

Used Version

1.6-SNAPSHOT

What is happening?

in my plugin I use "gui.getPageAmount(pViewer)" to get total amount of pages. gui is an InventoryGui filled with a group of items. Pagination works as expected, there are 3 pages. But the method above returns 1.

What did you expect to happen?

The method should return 3

Fallback for server reload

The library needs to close all the opened inventory on disabling, otherwise, it would be a duplication glitch. Many do use reload and some may accidentally run reload, so the library needs to support this functionality.


I noticed that if I reload the server, the inventory click handler will not work. so if a player has the menu open when the server reloads, the player is able to take out items from the gui because the events are not canceled.

Is this an expected behavior in the library? When I implemented my gui lib, I will iterate through all the opened inventory and just close them.

Originally posted by @weihao in #18 (comment)

Change page error

Used Version

1.4.3

Full Log

13:00:56 ERROR]: [mineAuctions] Exception while trying to run action for click on StaticGuiElement in slot 37 of &8Lista auckji GUI!
[13:00:56 WARN]: java.lang.NoSuchMethodError: de.themoep.inventorygui.InventoryGui.getPageNumber(Lorg/bukkit/entity/HumanEntity;)I
[13:00:56 WARN]:        at pl.mineAuctions.gui.list.ListGuiService.lambda$open$2(ListGuiService.java:87)
[13:00:56 WARN]:        at de.themoep.inventorygui.InventoryGui$GuiListener.onInventoryClick(InventoryGui.java:821)
[13:00:56 WARN]:        at com.destroystokyo.paper.event.executor.MethodHandleEventExecutor.execute(MethodHandleEventExecutor.java:40)
[13:00:56 WARN]:        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)
[13:00:56 WARN]:        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
[13:00:56 WARN]:        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:2663)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:32)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:10)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:43)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1214)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1207)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1183)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1027)
[13:00:56 WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:179)
[13:00:56 WARN]:        at java.lang.Thread.run(Thread.java:748)

What is happening?

If player click next page item throw this error.

Code

            if ((gui.getPageNumber(player) - 1) != -1) {
                gui.setPageNumber(player, gui.getPageNumber(player) - 1);
            }

Pagination elements : ItemStack amount

Is your feature request related to a problem? Please describe.

Currently, pagination elements will automatically set the item stack amount to the number of the next or previous page.

Describe the solution you'd like

Allowing us to disable this and set our own material amount OR as simple as a added Boolean method to disable automatically setting the item stacks amount for the pagination elements.

Describe alternatives you've considered

Additional context

My need for this is purely cosmetic. I am using custom textures within my server via resource pack. Because of this, custom textured arrows look nicer without the 2 added in from the item stack amount. (see photo) Thank you for your consideration, this resource is fantastic and I appreciate your dedication to it.

Missing dependency jar file for latest build of version "1.6.1-SNAPSHOT"

What is happening?

Error resolving dependency, see below for details and potential fix.

Building Process to reproduce:

  1. Attempt to gradle build project with latest version "1.6.1-SNAPSHOT" and gradle equivalent dependency information, as given in README.md (Can provide if necessary, but doesn't seem relevant to issue as described in following).
  2. Observe error resolving dependency (see log section).
    Uncertain if this can be reproduced with maven similarly.

What did you expect to happen?

Build as normal. Using version "1.6-SNAPSHOT" as a dependency instead resolves and builds successfully. Possibly a gradle issue that it doesn't allow using the previous build's jar file (uncertain if maven behaves the same or not).

It appears that the repo is missing the dependency jar file for latest build of version "1.6.1-SNAPSHOT", as can be seen in the repo at [1] and comparing the builds at [2]. E.g. latest build (#186) and #184 (last successful before latest)

Links (separate for readability):
[1] https://repo.minebench.de/de/themoep/inventorygui/1.6.1-SNAPSHOT/
[2] https://ci.minebench.de/job/InventoryGui/

Version

1.6.1-SNAPSHOT

Config

No relevant config

Server/system Version

unrelated

Log

Could not determine the dependencies of task ':shadowJar'.
> Could not resolve all files for configuration ':runtimeClasspath'.
   > Could not find inventorygui-1.6.1-SNAPSHOT.jar (de.themoep:inventorygui:1.6.1-SNAPSHOT:20240216.131015-1).
     Searched in the following locations:
         https://repo.minebench.de/de/themoep/inventorygui/1.6.1-SNAPSHOT/inventorygui-1.6.1-20240216.131015-1.jar

What other programs/plugins are you running?

Intellji IDEA and gradle (building issue)

Additional context

No response

DynamicGuiElement draw problem

Gui set up

                "di       ",
                "ggggggggg",
                "ggggggggg",
                "ggggggggg",
                "ggggggggg",
                "p       n"

Dynamic GUI element

        DynamicGuiElement d = new DynamicGuiElement('g', (viewer) -> {
            GuiElementGroup group = new GuiElementGroup('g');
            System.out.println(group.toString() + ": called.");
            String[] strings = new String[]{"one"};


            for (String str : strings) {
                StaticGuiElement s = new StaticGuiElement('g', new ItemStack(Material.PAPER), str);
                group.addElement(s);
            }
            return group;
        });

click to draw()

        new StaticGuiElement('d', new ItemStack(Material.OAK_SIGN), 1, click -> {
            click.getGui().draw();
            return true;
        }, "bug demo");

executions:

[23:43:08] [Server thread/INFO]: draw called once.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@4941bd28: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@7838ee2: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@2aaba250: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@5131cf0f: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@15dd90fc: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@e32f83b: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@797c628f: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@26ea8318: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@5f49ad49: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@462365bb: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@5c511fea: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@2ed1a53b: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@3c60664d: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@6133c2c7: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@35493f44: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@1612bcab: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@29fff22a: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@56a52828: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@2a6a8ea7: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@299e98a5: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@7f26511e: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@bdc2ba: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@7edc7bbc: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@235a8f72: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@6e3984a6: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@ff23c9: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@1de3a9f1: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@6a358420: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@480b2174: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@3193a2d7: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@31bf2935: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@776dafa6: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@667c20be: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@4a55b3bc: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@2ebdd42: called.
[23:43:08] [Server thread/INFO]: de.themoep.inventorygui.GuiElementGroup@18e14226: called.

Problem Description

I want to create a dynamic inventory that changes as the elements in the array changes. Elements can take up to four rows (36 slots) per page in the setup.
In the iterated array there is only one element, therefore, only one static element is created in the group.

What I expected

create 'd' Dynamic -> create a 'd' Group -> create many 'd' Statics -> fill any 'd' in the inventory

What actually happened

for all the 'd' (total number of 36 'd's) in the GUI setup, a group was created, and for every group, the called logic ran.

Nullpointer when i do gui.show

I am targeting against 1.14.2, I am passing the player to the function via the sender arg in the Oncommand function and line 163 is the gui.show line. I am not sure what could be causing the null pointer

           } else if (args[0].equalsIgnoreCase("menu")) {
                if (args.length == 1) {
                    Player p = ((Player) sender).getPlayer();
                    GuiElementGroup group = new GuiElementGroup('x');
                    InventoryGui gui = new InventoryGui(plugin, p, "&cOnline&4Players", plugin.getConfig().getStringList("matrix").toArray(new String[0]));
                    gui.addElement(new GuiPageElement('b', new ItemStack(Material.COAL, 1), GuiPageElement.PageAction.PREVIOUS, "&cPREVIOUS"));
                    gui.addElement(new GuiPageElement('f', new ItemStack(Material.CHARCOAL, 1), GuiPageElement.PageAction.NEXT, "&aNEXT"));
                    gui.setFiller(new ItemStack(Material.GRAY_STAINED_GLASS, 1));
                    group.setFiller(gui.getFiller());
                    gui.addElement(group);
                    gui.show(p);
                }
            }



The error i get when i run the command is

[04:07:35 INFO]: deadman96385 issued server command: /oxidepunch menu
[04:07:35 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'oxidepunch' in plugin OxidePunch v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[patched_1.14.2.jar:git-Paper-74]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.14.2.jar:git-Paper-74]
        at org.bukkit.craftbukkit.v1_14_R1.CraftServer.dispatchCommand(CraftServer.java:736) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.PlayerConnection.handleCommand(PlayerConnection.java:1832) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.PlayerConnection.a(PlayerConnection.java:1640) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.PacketPlayInChat.a(PacketPlayInChat.java:47) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.PacketPlayInChat.a(PacketPlayInChat.java:5) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:18) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.TickTask.run(SourceFile:18) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:127) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:105) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.MinecraftServer.aW(MinecraftServer.java:999) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.MinecraftServer.executeNext(MinecraftServer.java:992) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:115) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.MinecraftServer.sleepForTick(MinecraftServer.java:976) ~[patched_1.14.2.jar:git-Paper-74]
        at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:909) ~[patched_1.14.2.jar:git-Paper-74]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
Caused by: java.lang.NullPointerException
        at java.lang.String.replace(Unknown Source) ~[?:1.8.0_181]
        at de.themoep.inventorygui.InventoryGui.replaceVars(InventoryGui.java:951) ~[?:?]
        at de.themoep.inventorygui.InventoryGui.build(InventoryGui.java:431) ~[?:?]
        at de.themoep.inventorygui.InventoryGui.build(InventoryGui.java:420) ~[?:?]
        at de.themoep.inventorygui.InventoryGui.draw(InventoryGui.java:443) ~[?:?]
        at de.themoep.inventorygui.InventoryGui.show(InventoryGui.java:398) ~[?:?]
        at de.themoep.inventorygui.InventoryGui.show(InventoryGui.java:389) ~[?:?]
        at com.oxide.staffpunch.Main.onCommand(Main.java:163) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.14.2.jar:git-Paper-74]
        ... 17 more

License

Hey! Just wanted to let you know that this should technically be licensed under a GNU Public License (GPL) v3 license. This is because Bukkit is under this license and you're using their API. I suggest you change it, thanks!

Left / right click check

It would be great if it's possible to detect if a click interaction was a left or a right click. This way, both clicks can have different actions.
Probably depends on #38 to be fixed first.

Workaround until this is implemented:

if (!(action.getRawEvent() instanceof InventoryClickEvent)) return;
InventoryClickEvent event = (InventoryClickEvent) action.getRawEvent();
if (event.getClick() == ClickType.LEFT) {
     //This was a left click
} else if (event.getClick() == ClickType.RIGHT) {
     //This was a right click
}

Item duplication: NullPointerException on double click when I move storaged items to the cursor

What is happening?

immagine
This exception occours if I doubleClick on any item which is placed in more than a slot. This is used to duplicate items.

https://imgur.com/y5A6Lpa

The actual version is a fork from 1.6.1 with just this change to fix an issue:
immagine

What did you expect to happen?

No exception, no duplication

Version

1.6.1

Config

?

Server/system Version

Paper 1.19.4

Log

[22:23:17] [Server thread/ERROR]: Could not pass event InventoryClickEvent to Feudal v1.19
java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.HumanEntity.getUniqueId()" because "player" is null
	at libs.feudal.themoep.InventoryGui.getPageNumber(InventoryGui.java:467) ~[Feudal-3.2.0.jar:?]
	at libs.feudal.themoep.GuiStorageElement.getStorageSlot(GuiStorageElement.java:235) ~[Feudal-3.2.0.jar:?]
	at libs.feudal.themoep.GuiStorageElement.setStorageItem(GuiStorageElement.java:287) ~[Feudal-3.2.0.jar:?]
	at libs.feudal.themoep.GuiStorageElement.setStorageItem(GuiStorageElement.java:276) ~[Feudal-3.2.0.jar:?]
	at libs.feudal.themoep.InventoryGui.simulateCollectToCursor(InventoryGui.java:1599) ~[Feudal-3.2.0.jar:?]
	at libs.feudal.themoep.InventoryGui.handleInteract(InventoryGui.java:1112) ~[Feudal-3.2.0.jar:?]
	at libs.feudal.themoep.InventoryGui.access$500(InventoryGui.java:81) ~[Feudal-3.2.0.jar:?]
	at libs.feudal.themoep.InventoryGui$GuiListener.onInventoryClick(InventoryGui.java:1227) ~[Feudal-3.2.0.jar:?]
	at com.destroystokyo.paper.event.executor.MethodHandleEventExecutor.execute(MethodHandleEventExecutor.java:40) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
	at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:81) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:git-Paper-"483368e"]
	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
	at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.19.4.jar:git-Paper-"483368e"]
	at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[paper-1.19.4.jar:git-Paper-"483368e"]
	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:3196) ~[?:?]
	at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:58) ~[?:?]
	at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:23) ~[?:?]
	at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:51) ~[?:?]
	at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.4.jar:git-Paper-"483368e"]
	at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1342) ~[paper-1.19.4.jar:git-Paper-"483368e"]
	at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.19.4.jar:git-Paper-"483368e"]
	at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
	at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1319) ~[paper-1.19.4.jar:git-Paper-"483368e"]
	at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1312) ~[paper-1.19.4.jar:git-Paper-"483368e"]
	at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
	at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1290) ~[paper-1.19.4.jar:git-Paper-"483368e"]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1178) ~[paper-1.19.4.jar:git-Paper-"483368e"]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:320) ~[paper-1.19.4.jar:git-Paper-"483368e"]
	at java.lang.Thread.run(Thread.java:1583) ~[?:?]

What other programs/plugins are you running?

I tried with a minimum amount of custom plugins. No interaction with inventory events

Additional context

No response

GuiStateElement synced across multiple players

If I open the same gui for multiple players at once and one of them clicks a GuiStateElement, the Element is changed for the other players too. If I understand this api correctly, the goal is to have one InventoryGui instance that you open for all players. If you need to change something dynamically, you use DynamicGuiElements. If I have to create a new InventoryGui for every player, then why is there a DynamicGuiElement?

Async ItemStack update

Is your feature request related to a problem? Please describe.

Created a page full of player skulls, whenever the player opens the GUI for the first time, the server freezes.

Describe the solution you'd like

Asynchronous action on GUI icon itemstack after GUI is opened.

Describe alternatives you've considered

Additional context

After the recent update resourcepacks are not behaving as expected

What is happening?

This is the GUI in 1.6.1:
immagine

This is the GUI in 1.6.2:
immagine

What did you expect to happen?

The resourcePack's elements being showed as before or an option to choose the visualization mode if that was an intended behaviour

Version

1.6.2

Config

-

Server/system Version

Paper 1.19.4

Log

-

What other programs/plugins are you running?

Additional context

No response

CalculatePageAmount

Used Version

LATEST

What is happening?

I use the Inventory System to create an inventory with several pages. I use a GroupElement and there I add staticitems. However, 2 pages exist although the slots of the group are not full. In addition, the second page is equipped with the same items as page 1. If I make the slots of one page full and a few on the second page, it works with the pages. This means that the calculatePageAmount method does not work.

Additional context

Page 1: https://prnt.sc/11x6lr7
Page 2: https://prnt.sc/11x6m64

Per-player element

Having a per-player element (e.g. one which lets you say fish to Lax, but You're gold! to any other player) would quickly cut down on amount of times a GUI would have to be made in a single plugin if it has different behaviour per player.

I'd simply suggest a type such as PlayerDynamicElement(char setupSubstitution, Function<Player, StaticGuiElement> element).

Option to show inventory with custom replacements

I don't know if it possible to add (at least in an easy way) but option to show inventory with custom replacements would be great. Unfortunately it would require creating new inventory (bukkit inventory) every showing inventory but I think developers
who would use it should care about performance.

Pagination elements in Dynamic context do not update

I have a group in a dynamic gui element that changes size while the gui is open. Every element in my gui is therefore dynamic.
The issue is that the pagination elements do not appear when the group goes beyond the size limit of the gui. They only appear when closing the gui in the game and reopening it.

calling gui.close() and gui.show(player) after eachtother in the click callback does not update it either.

The following line is how I added one of my pagination elements
gui.addElement(new DynamicGuiElement('f', (viewer) -> new GuiPageElement('f', new ItemStack(Material.ARROW), GuiPageElement.PageAction.FIRST, "Go to first page (current: %page%)")));

Option to not allow the GUI to be closed

Add an option so that the GUI cannot be closed by the player, only via the library functions itself.

Will most likely need to reopen the GUI as there (currently) is no way to stop the closing server-side.

(Current way of implementing this would be via the GUI close handler but having an option could be nice)

Latest version caused bugs

Used Version

9ad5463

   <repositories>
   	<repository>
   	    <id>jitpack.io</id>
   	    <url>https://jitpack.io</url>
   	</repository>
   </repositories>
   <dependency>
       <groupId>com.github.Phoenix616</groupId>
       <artifactId>InventoryGui</artifactId>
       <version>9ad5463680</version>
   </dependency>

My code breaks when I use the latest version. Is there any testing before you pushed the code to master?

interact with player's inventory

Is your feature request related to a problem? Please describe.

N/A

Describe the solution you'd like

Add functionality to support click events when the player clicked on player inventory.

Version Compatiblity

Used Version

Latest Version

[02:26:55 ERROR]: [ACF] Exception in command: ir
[02:26:55 ERROR]: [ACF] java.lang.reflect.InvocationTargetException
[02:26:55 ERROR]: [ACF]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[02:26:55 ERROR]: [ACF]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[02:26:55 ERROR]: [ACF]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[02:26:55 ERROR]: [ACF]         at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[02:26:55 ERROR]: [ACF]         at co.aikar.commands.RegisteredCommand.invoke(RegisteredCommand.java:152)
[02:26:55 ERROR]: [ACF]         at co.aikar.commands.BaseCommand.executeCommand(BaseCommand.java:577)
[02:26:55 ERROR]: [ACF]         at co.aikar.commands.BaseCommand.execute(BaseCommand.java:513)
[02:26:55 ERROR]: [ACF]         at co.aikar.commands.RootCommand.execute(RootCommand.java:99)
[02:26:55 ERROR]: [ACF]         at co.aikar.commands.BukkitRootCommand.execute(BukkitRootCommand.java:81)
[02:26:55 ERROR]: [ACF]         at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
[02:26:55 ERROR]: [ACF]         at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641)
[02:26:55 ERROR]: [ACF]         at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162)
[02:26:55 ERROR]: [ACF]         at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997)
[02:26:55 ERROR]: [ACF]         at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45)
[02:26:55 ERROR]: [ACF]         at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1)
[02:26:55 ERROR]: [ACF]         at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13)
[02:26:55 ERROR]: [ACF]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[02:26:55 ERROR]: [ACF]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[02:26:55 ERROR]: [ACF]         at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44)
[02:26:55 ERROR]: [ACF]         at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715)
[02:26:55 ERROR]: [ACF]         at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374)
[02:26:55 ERROR]: [ACF]         at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654)
[02:26:55 ERROR]: [ACF]         at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557)
[02:26:55 ERROR]: [ACF]         at java.base/java.lang.Thread.run(Thread.java:830)
[02:26:55 ERROR]: [ACF] Caused by: java.lang.NoClassDefFoundError: org/bukkit/Nameable
[02:26:55 ERROR]: [ACF]         at de.themoep.inventorygui.InventoryGui.replaceVars(InventoryGui.java:1271)
[02:26:55 ERROR]: [ACF]         at de.themoep.inventorygui.InventoryGui.draw(InventoryGui.java:573)
[02:26:55 ERROR]: [ACF]         at de.themoep.inventorygui.InventoryGui.draw(InventoryGui.java:556)
[02:26:55 ERROR]: [ACF]         at de.themoep.inventorygui.InventoryGui.show(InventoryGui.java:499)
[02:26:55 ERROR]: [ACF]         at de.themoep.inventorygui.InventoryGui.show(InventoryGui.java:490)

What is the version compatibility? I don't see it mentioned anywhere on the docs. It did not work on 1.8.8

Lores of items get deleted

When adding a lore to an ItemStack of an StaticGuiElement (not sure about other elements, haven't tested yet), the lore will not be displayed in the inventory. No matter how many lines it has.
I'm not sure what's causing this, but it must be something in the InventoryGUI#setItemText() method. In one else block it sets the lores to null and i'm not sure why it should. If i remove this block, everything is working fine. But I don't think this is a good solution.

InventoryGui Issue while loading the plugin.

Hello Phoenix,
I don't know if this is the appropriate way to contact with you, but I dind't find another.
So, I'm having an issue while trying to use your library to create a GUI for my plugin. Probably is an idiot issue, but I'm a new dev and I'm still learning how to develop. If you have time, here I send you my issue.

https://hastebin.com/ituxejulab.cs

Thanks :)

Allow setting lore without setting display name

You can currently set both lore and display name with the text parameter. But you can't set the display name to for example null or an empty string to keep the original name. That would be useful if you don't want to change the display name and only want to change the lore.

Allow item numbers to be less than 1

Is your feature request related to a problem? Please describe.

The StaticGuiElement doesn't allow the number of items to be less than 1.

Describe the solution you'd like

Allow the number of items to be less than 1.

This is what happens when you do this:
image
It's a pretty cool effect, so that's why I would like to use it.

Close action not executed when using GuiBackElement

The close action for the current GUI should be executed when clicking a GuiBackElement, but the inventory is never actually closed so that doesn't seem to happen. I've tried to fix it myself but the methods I tried caused some very weird behavior (called 20+ times instead of zero...) and I have no idea why.

Make Folia compatible and thread-safe

With the advent of Paper's new multi-threaded fork Folia more people might try to use this utility in plugins designed for that. This ticket is for tracking that progress.

Stuff that needs to be done:

  • Use Folia task executor (Done with #45)
  • Ensure thread-safety of global maps
  • Ensure thread-safety of per gui instance map
  • Testing!

error :(

05.06 15:19:28 [Server] ERROR null
05.06 15:19:28 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'kolor' in plugin BoardPVP v1.0.0
05.06 15:19:28 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:48) ~[server.jar:]
05.06 15:19:28 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:161) ~[server.jar:]
05.06 15:19:28 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:775) ~[server.jar:]
05.06 15:19:28 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1490) ~[server.jar:]
05.06 15:19:28 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1294) ~[server.jar:]
05.06 15:19:28 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:56) ~[server.jar:]
05.06 15:19:28 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:5) ~[server.jar:]
05.06 15:19:28 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:7) ~[server.jar:]
05.06 15:19:28 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
05.06 15:19:28 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
05.06 15:19:28 [Server] INFO at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) ~[server.jar:]
05.06 15:19:28 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:918) ~[server.jar:]
05.06 15:19:28 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:454) ~[server.jar:]
05.06 15:19:28 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:854) ~[server.jar:]
05.06 15:19:28 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:707) ~[server.jar:]
05.06 15:19:28 [Server] INFO at java.lang.Thread.run(Thread.java:829) ~[?:?]
05.06 15:19:28 [Server] INFO Caused by: java.lang.NoClassDefFoundError: org/bukkit/Nameable
05.06 15:19:28 [Server] INFO at de.themoep.inventorygui.InventoryGui.replaceVars(InventoryGui.java:1381) ~[?:?]
05.06 15:19:28 [Server] INFO at de.themoep.inventorygui.InventoryGui.lambda$new$3(InventoryGui.java:210) ~[?:?]
05.06 15:19:28 [Server] INFO at de.themoep.inventorygui.InventoryGui.draw(InventoryGui.java:651) ~[?:?]
05.06 15:19:28 [Server] INFO at de.themoep.inventorygui.InventoryGui.draw(InventoryGui.java:634) ~[?:?]
05.06 15:19:28 [Server] INFO at de.themoep.inventorygui.InventoryGui.show(InventoryGui.java:576) ~[?:?]
05.06 15:19:31 [Server] INFO at de.themoep.inventorygui.InventoryGui.show(InventoryGui.java:567) ~[?:?]
05.06 15:19:31 [Server] INFO at pl.minecon724.boardpvp.Commands.onCommand(Commands.java:57) ~[?:?]
05.06 15:19:31 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[server.jar:]
05.06 15:19:31 [Server] INFO ... 15 more
05.06 15:19:31 [Server] INFO Caused by: java.lang.ClassNotFoundException: org.bukkit.Nameable
05.06 15:19:31 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:94) ~[server.jar:]
05.06 15:19:31 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:89) ~[server.jar:]
05.06 15:19:31 [Server] INFO at java.lang.ClassLoader.loadClass(ClassLoader.java:589) ~[?:?]
05.06 15:19:31 [Server] INFO at java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]
05.06 15:19:31 [Server] INFO at de.themoep.inventorygui.InventoryGui.replaceVars(InventoryGui.java:1381) ~[?:?]
05.06 15:19:31 [Server] INFO at de.themoep.inventorygui.InventoryGui.lambda$new$3(InventoryGui.java:210) ~[?:?]
05.06 15:19:31 [Server] INFO at de.themoep.inventorygui.InventoryGui.draw(InventoryGui.java:651) ~[?:?]
05.06 15:19:31 [Server] INFO at de.themoep.inventorygui.InventoryGui.draw(InventoryGui.java:634) ~[?:?]
05.06 15:19:31 [Server] INFO at de.themoep.inventorygui.InventoryGui.show(InventoryGui.java:576) ~[?:?]
05.06 15:19:31 [Server] INFO at de.themoep.inventorygui.InventoryGui.show(InventoryGui.java:567) ~[?:?]
05.06 15:19:31 [Server] INFO at pl.minecon724.boardpvp.Commands.onCommand(Commands.java:57) ~[?:?]
05.06 15:19:31 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[server.jar:]
05.06 15:19:31 [Server] INFO ... 15 more

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.