Resource SignMenu [1.15.2] - Get Player Sign Input!

Discussion in 'Spigot Plugin Development' started by FrostedSnowman, Jun 19, 2017.

  1. How do we go about manually closing the sign editor?
     
  2. FrostedSnowman

    Resource Staff

    Updated to the recommended 1.15.2 Build.

    Changelog (v4.0)
    • Less arguments required for creating a menu: you only need the text now. See main page for new syntax.
    • Optimized some things, menu now caches the BlockPosition as opposed to another map.
    • Menus can now be opened for any player, not specific to a certain player, which was a limitation in previous implementations.
    I'll be releasing another update at another time over on GitHub, not a fan of the single class implementation which originally inspired this.
     
    #43 FrostedSnowman, Mar 7, 2020
    Last edited: Mar 7, 2020
  3. I m trying to use this resource but if i click "done" o "esc" when the sign is displayed the game crash "
    The game crashed whilst keypressed event handler
    Error: java.lang.NullPointerException: keyPressed event handler
    "
     
  4. @FrostedSnowman today I've start using BungeeCord and when I click on Done (sign), I'm kicked with: "The server you were previosly on went down, you have been connected to a fallback server"
     
  5. FrostedSnowman

    Resource Staff

    What spigot version are you using and can you provide a console log?
     
  6. I have start disabling plugins one by one until I found that an anticheat (Matrix) is causing the issue. I've disabled all the checks, even badpackets check and it still hapens.


    Edit: The anticheat author has found the issue. The sendBlockChange should be executed next tick. I don't know why it was only happening with the anticheat.
    [​IMG][​IMG]
     
    #47 YellowZaki, Mar 20, 2020
    Last edited: Mar 20, 2020
  7. No idea why, but this resource only works when I set all the lines in the sign first.
    Code (Java):
     .newMenu(Lists.newArrayList(, "Enter HP"))
    doesn't work for me, it has to be
    Code (Java):
     .newMenu(Lists.newArrayList("Enter HP", "", "", ""))
    Otherwise the game crashes like the others already pointed out.
     
  8. FrostedSnowman

    Resource Staff

    Yes, you need to specify all of them. The resource currently does not auto populate the remaining indexes if they're null, you need to handle that yourself.
     
  9. Was just a bit confusing since you didn't fill in the list completely and while in theory you receive the result in the screenshot from the main post, upon any action the game will crash.
     
  10. FrostedSnowman

    Resource Staff

    Haha, my bad. I must've had v1.0 handle auto population and removed it in later versions, thanks for pointing that out :)

    I'm planning to release a better structured version of it all on Github very soon.
     
  11. @FrostedSnowman your resource is very helpful and I'm trying to use this as a way to get inputs but I'm having issues when trying to re-open the chest gui that activated the sign gui.

    Code (Java):
    SignMenuFactory signMenuFactory = plugin.getSignMenuFactory();

            signMenuFactory
                    .newMenu(Lists.newArrayList("###", "^^^^^^^^", "Please Enter", "Custom Amount"))
                    .reopenIfFail()
                    .response((player, lines) -> {
                        if (isNumeric(lines[0])){
                            BuyMenu.openMenu(player, material, file, Integer.parseInt(lines[0]));
                            return true;
                        } else {
                            return false;
                        }
                    })
                    .open(target);


    Also, if I have timings on or have anything before the return true; you have to close the sign at least once before you can edit if.
     
    #52 BUTTERFEILD8, Apr 2, 2020
    Last edited: Apr 3, 2020
  12. It crashed when i click done :( zero error in console ?
     
  13. FrostedSnowman

    Resource Staff

    I've updated the example now, but make sure you are filling in 4 arguments into the list, even if you want blank lines.

    Code (Java):
    .newMenu(Lists.newArrayList("Enter HP", "", "", ""))
     
  14. I don't get how to open this Sign GUI by right clicking a sign.
    I want to show the text of the sign i clicked on, but I don't how. Is it even possible with this resource?
     
  15. Get the sign clicked -> cast to sign -> get lines -> open sign gui with lines
     
  16. This is a resource, they're not asking for help on how to do it
     
  17. He’s answering to the guy on top


     
  18. I thought i have.. But
    Code (Java):
        @EventHandler
        public void SignClick(PlayerInteractEvent event) {
            Action action = event.getAction();
            Player player = event.getPlayer();
            Block block = event.getClickedBlock();

            if (event.getHand() == EquipmentSlot.HAND) {
                if (action.equals(Action.RIGHT_CLICK_BLOCK)) {
                    if(block.getState() instanceof Sign) {
                        Sign sign = (Sign) block.getState();
                        String[] ln = sign.getLines();

                       this.signMenuFactory
                        .newMenu(Lists.newArrayList(ln[0], ln[1], ln[2], ln[3]))
                        .reopenIfFail()
                        .response((player, lines) -> {
                            if (player.getName().equals("Notch") && lines[0].equals("Hello")) {
                                return true;
                            }
                            return false; // failure. becaues reopenIfFail was called, menu will reopen when closed.
                        })
                        .open(player);
                    }
                }
            }
        }
    I get an error in Eclipse at line 52:
    Lambda expression's parameter player cannot redeclare another local variable defined in an enclosing scope.

    This is line 52:
    .response((player, lines) -> {

     
  19. You already have a variable called player... this is basic Java. You just need to change the variable name (player) to something else.

    .response((somethingElse, lines) -> {
    if (somethingElse.getName().equals("Notch") && lines[0].equals("Hello")) {
    return true;
    }