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

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

  1. Hey @WesJD,
    I'm having some issues using AnvilGUI...
    If an Item is clicked nomatter what happens it just doesnt cancel the event, and the item gets renamed and put in my inventory
    Can I talk to you somewhere about this (or here ofcourse)?

    Btw: Your website is really fancy XD

    Luc,
     
  2. Would it be possible to add an event for when the GUI is closed by pressing escape?
     
  3. InventoryCloseEvent
     
  4. It seems your repo is down :(. 502 Bad Gateway ;)
     
  5. Works fine for me.
     
  6. MiniDigger

    Supporter

  7. Yep. Should have clarified that :p
     
  8. not sure what I did but I messed around and it worked again. yay? sorry for not seeing this sooner.
     
    • Funny Funny x 1
  9. When I try to perform a Maven Install it throws this exception.....
    Code (Text):
    Failed to collect dependencies at net.wesjd:anvilgui:jar:1.1-20160703.033527-1: Failed to read artifact descriptor for net.wesjd:anvilgui:jar:1.1-20160703.033527-1: Could not transfer artifact net.wesjd:anvilgui:pom:1.1-20160703.033527-1 from/to wesjd-repo (https://nexus.wesjd.net/repository/thirdparty/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
    Anyone could help me out?
     
  10. When I try to open anvil menu in game it throws error, can you help me ?

    Code (Text):
    [09:58:10 ERROR]: Could not pass event InventoryClickEvent to ShopsManager v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1630) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:31) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:9) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-db6de12-18fbb24]
            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_8_R3.SystemUtils.a(SourceFile:44) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    Caused by: java.lang.NoClassDefFoundError: net/wesjd/anvilgui/AnvilGUI
            at cz.flay.shopsmanager.menus.CreateShopMenu.onInventoryClick(CreateShopMenu.java:106) ~[?:?]
            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:306) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            ... 15 more
    Caused by: java.lang.ClassNotFoundException: net.wesjd.anvilgui.AnvilGUI
            at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_121]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_121]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_121]
            at cz.flay.shopsmanager.menus.CreateShopMenu.onInventoryClick(CreateShopMenu.java:106) ~[?:?]
            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:306) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            ... 15 more

    Code (Text):
        @EventHandler
        public void onInventoryClick(InventoryClickEvent e){

            Player p = (Player) e.getWhoClicked();

            //zkontroluje zda se jedna o menu s shopy
            if (e.getInventory().getName() == config.getMenuTitle("createmenu")) {

                    if (e.getCurrentItem().getItemMeta().getDisplayName().contains(setdescriptionitemmeta.getDisplayName()) && e.isLeftClick() || e.isRightClick()){
                        new AnvilGUI(Main.getInstance(), p, "Popis shopu", (player, reply) -> {
                            if (reply.equalsIgnoreCase("you")) {
                                player.sendMessage("You have magical powers!");
                                return null;
                            }
                            return "Incorrect.";
                        });
                    }
          }
    }
     
  11. java.lang.ClassNotFoundException: net.wesjd.anvilgui.AnvilGUI

    Also, what the hell is this symbol ->? Gives errors for me.
     
  12. MiniDigger

    Supporter

    Make sure you shade the lib into your plugin.
     
    • Agree Agree x 1
  13. Thank you, it works :)
     
  14. Now supports 1.12.2 - sorry for the wait!
     
    • Like Like x 1
    • Winner Winner x 1
  15. Was it broken in 1.12.2? Do I need to update?
     
  16. Yes, unfortunately. An update fixing it was released under the same version number though (1.1.1).
     
  17. Hey, trying to update to your new version, you used to have the 'slot' stuff, but that doesn't seem to be there anymore.. how do I set a slot now?
     
  18. isn't it better to use signs to get the input?
     
  19. No

    Signs can be confusing and there's not much space to type what you want. But still I'd like to see this API develop into a sign gui & more.