Resource AnvilGUI - Easily use anvil guis to get a user's input

Discussion in 'Spigot Plugin Development' started by WesJD, May 8, 2016.

  1. Hello, I use latest version 1.1.1-20171010.000243-6 and plugin dosn't support version 1.12.X... Where is problem ?

    Code (Text):
    [17:19:53 ERROR]: Could not pass event InventoryClickEvent to FancyMessages v1.0
    org.bukkit.event.EventException: null
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:499) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:484) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1877) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:33) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:10) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_121]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_121]
            at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:747) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:405) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    Caused by: java.lang.NullPointerException: Your server version isn't supported in AnvilGUI!
            at org.apache.commons.lang3.Validate.notNull(Validate.java:225) ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.wesjd.anvilgui.AnvilGUI.<init>(AnvilGUI.java:95) ~[?:?]
            at cz.flay.fancymessages.menu.menus.DetailsMenu.onClick(DetailsMenu.java:129) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            ... 15 more

    Fixed, there was more plugins which use AnvilGUIs...
     
    #62 FlayZ04, Nov 15, 2017
    Last edited: Nov 15, 2017
  2. Is there any way to run action when anvil gui is closed without clicking on output item (using ESC for example)? I need to open menu when player close Anvil GUI without clicking on output item, I modified the library, I add one more BiFunction for this and it works, but events not trigger on opened menu...
     
  3. just released a huge project restructure (which also includes support for 1.13). make sure to update to version 1.2-SNAPSHOT.
     
    • Winner Winner x 1
  4. I cant seem to get all the artifacts for building, i am not very familiar with maven, can i target 1.13 so i dont have to build every other version?
     
  5. you don't need to build it yourself - just use the maven repository.
     
  6. just released 1.2.1-SNAPSHOT with a smaller size and dependency fixes (probably fixed your issues, @Chasewhip8 ).
     
    • Like Like x 1
  7. nice work! I'll probably find this useful sooner or later.
     
  8. Hey, I shaded AnvilGUI in my jar, it works fine except that I keep getting this whenever I use anything other than 1.13.2:
    Code (Text):

    org.bukkit.event.EventException: null
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:306) ~[spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:499) [spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:484) [spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.jav
    a:1877) [spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:33
    ) [spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:10
    ) [spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:
    13) [spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [
    ?:1.8.0_121]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_121]
            at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot-1.
    12.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:
    747) [spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:
    405) [spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:
    678) [spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.jav
    a:576) [spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    Caused by: java.lang.ExceptionInInitializerError
            at net.islandearth.reporter.ui.ReportPlayerInventory.lambda$init$1(Repor
    tPlayerInventory.java:47) ~[?:?]
            at fr.minuskube.inv.ClickableItem.run(ClickableItem.java:26) ~[?:?]
            at fr.minuskube.inv.InventoryManager$InvListener.lambda$onInventoryClick
    $2(InventoryManager.java:140) ~[?:?]
            at java.util.Optional.ifPresent(Unknown Source) ~[?:1.8.0_121]
            at fr.minuskube.inv.InventoryManager$InvListener.onInventoryClick(Invent
    oryManager.java:140) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0
    _121]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0
    _121]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .8.0_121]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:302) ~[spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            ... 15 more
    Caused by: java.lang.RuntimeException: Your server version isn't supported in An
    vilGUI!
            at net.wesjd.anvilgui.version.VersionMatcher.lambda$1(VersionMatcher.jav
    a:35) ~[?:?]
            at java.util.Optional.orElseThrow(Unknown Source) ~[?:1.8.0_121]
            at net.wesjd.anvilgui.version.VersionMatcher.match(VersionMatcher.java:3
    5) ~[?:?]
            at net.wesjd.anvilgui.AnvilGUI.<clinit>(AnvilGUI.java:31) ~[?:?]
            at net.islandearth.reporter.ui.ReportPlayerInventory.lambda$init$1(Repor
    tPlayerInventory.java:47) ~[?:?]
            at fr.minuskube.inv.ClickableItem.run(ClickableItem.java:26) ~[?:?]
            at fr.minuskube.inv.InventoryManager$InvListener.lambda$onInventoryClick
    $2(InventoryManager.java:140) ~[?:?]
            at java.util.Optional.ifPresent(Unknown Source) ~[?:1.8.0_121]
            at fr.minuskube.inv.InventoryManager$InvListener.onInventoryClick(Invent
    oryManager.java:140) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0
    _121]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0
    _121]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .8.0_121]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:302) ~[spigot-1.12.jar:git-Spigot-596221b-9a1fc1e]
            ... 15 more
    I tried 1.12 and 1.12.2, neither worked...
     
  9. What do you mean, I do not get it.
    I have the dependency and repository.
     
  10. MiniDigger

    Supporter

    > replying to a 2 year old comment
    lol

    you need to use the maven shade plugin to include the lib in your plugins jar file
     
  11. OK, I searched the whole day, but found no solution. I have installed the shade plugin, but when I join danine, I somehow get erros and get kicked because of internet server error. He also includes somehow all the other API's in prom.xml.
     
  12. I use maven for some dependencys, but I do not use it for building. I am getting the Caused by: java.lang.NoClassDefFoundError: net/wesjd/anvilgui/AnvilGUI error, which I know can be fixed by shading the lib into the jar. However, I think that requires that you use maven as a build tool.

    Is there a simple jar file I can add to my build path?
     
  13. MiniDigger

    Supporter

    that would fix nothing.

    you need to build via maven or tell your IDE to do the shading (which most likely will be harder). do your self a favor and learn maven properly. if you get stuck with that, many ppl on the forums or irc are happy to assist you.
     
  14. there is a bug, https://github.com/WesJD/AnvilGUI/issues/20 i just change my listener like that:
    Code (Java):
    package io.github.utsukushihito.utsutil.base.anvil

    import io.github.utsukushihito.utsutil.api.anvil.SlotType
    import io.github.utsukushihito.utsutil.base.misc.AnvilUtil
    import org.bukkit.Material
    import org.bukkit.entity.Player
    import org.bukkit.event.EventHandler
    import org.bukkit.event.Listener
    import org.bukkit.event.inventory.ClickType
    import org.bukkit.event.inventory.InventoryClickEvent
    import org.bukkit.event.inventory.InventoryCloseEvent

    class AnvilListener(
        private val util: AnvilUtil
    ) : Listener {

        @EventHandler
        fun onInventoryClick(event: InventoryClickEvent) {
            if (util.compare(event.inventory)) {
                event.isCancelled = true

                if (event.click != ClickType.LEFT) return

                if (event.rawSlot == SlotType.OUTPUT.id) {
                    val clicked = util.getItem(event.rawSlot)

                    if (clicked.type == Material.AIR) return

                    val ret = util.apply(
                        event.whoClicked as Player,
                        if (clicked.hasItemMeta())
                            clicked.itemMeta.displayName
                        else
                            clicked.type.toString())

                    val meta = clicked.itemMeta
                    meta.displayName = ret
                    clicked.itemMeta = meta

                    util.setItem(event.rawSlot, clicked)
                }
            }
        }

        @EventHandler
        fun onInventoryClose(e: InventoryCloseEvent) {
            if (util.isOpen() && util.compare(e.inventory)) util.close()
        }

    }
     
     


  15. What is Shade? I get the same error but I don't understand what Shade is
     
  16. Bumping this resource. I just finally sat down and resolved all issues!
     
    • Like Like x 1
  17. I made a Dependency with Maven and wanted to open the Anvil GUI for testing onJoin() for the Player. Problem: It isn't opening and there are no errors in the consoleā€¦Could Anyone help me (My Plugin is 1.15)