Resource SignMenu [1.15.2] - Get Player Sign Input!

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

  1. This error isn't caused just because of this resource. You use lamda expressions, which have to be (effectively) final. You declare Player player = event.getPlayer() above. Just rename your variable in the lamda, you create a new local variable in the lamda statement
     
    • Like Like x 1
  2. Yes that's working, error is gone.

    But when I right-click a sign, I get a nullpointer exception at line 50. That line is:
    .newMenu(Lists.newArrayList(ln[0], ln[1], ln[2], ln[3]))
     
  3. Maybe if a line on a sign is empty, the String[] array contains null elements?
    Try something along this
    Code (Text):
    Lists.newArrayList(ln[0] == null ? "" : ln[0], ...the same for the others);
     
  4. ok cool. nobody can do anything about it until you give the error

    /e if that line is the error, whatever .newMenu refers back to is null

    arraylists allow null elements. wouldnt NPE.

    although, ln could also be null.
     
  5. Google's newArrayList does, but this resource doesnt. I once posted on this thread that you have to fill in all 4 entries in the list.
    And ln cannot be null, the API has a @NotNull annotation to Sign#getLines
     
  6. that would depend on how the api handles it then, and why seeing the error would be helpful. nothing would directly cause an NPE, unless the api threw it from trying to use a null entry in a list. but if thats the line specifically that throws the NPE, then only an object access on that line would be invalid. so an object on that line is null. so something hes doing is null. unless hes looking at the wrong part of his error :shrug: which is why we need the error to be able to accurately help.
     
    • Agree Agree x 1
  7. ---Not part of the discussion directly above---

    Is it possible to modify the "Edit sign message" above the sign?
     
  8. I fixed this error by putting the EventHandler (the SignClick function) in the Main class.
    But how do I get this to work in another class? I tried several things but I can't get it to work... Is this possible with this resource?

    I have a few classes more (with EventHandlers) and they are working well.
    All EventHandlers are registered in the Main class. But only the SignClick function with PlayerInteractEvent creates the NullPointerException
     
  9. FrostedSnowman

    Resource Staff

    No, it's not possible unfortunately. This is client side :(
     
  10. Just found this as well :/
    signclientside.PNG
     
  11. If you return false inside the lamda so the sign GUI should reopen AND you open (logically) after the sign GUI code has been executed another GUI, it causes errors.
     
  12. The NullPointerException appears when I rightclick on the sign, and nothing else happens. No sign editor, nothing.
    But when I paste the function into the Main class, everything is working well.. My question is how do I get this to work in an other classfile..?
     
  13. Do you mean how to get the signMenuFactory instance to other classes? If that the case, then you need to pass an instance through a constructor to your desired class.
     
  14. Hey,

    first of all, thanks for this, this looks really awesome.
    Somehow, the Sign I am creating constantly closes and reopens when I call .open(player).
    As if it would constantly return false and therefore reopen due to .reopenIfFail().
    It doesen't wait for me till I close the gui, it closes it as soon as I call it...?

    Code (Text):

                                         this._signMenuFactory
                                         .newMenu(Lists.newArrayList("&9[Search]", "&bSearch String:", "&e", "&e"))
                                         .reopenIfFail()
                                         .response((player, lines) -> {
                                             if (player.getName().equals("Notch") && lines[0].equals("Hello")) {
                                                 return true;
                                             }
                                             return false;
                                         })
                                         .open(clicker);
     
     
  15. @FrostedSnowman so with this util how would i use it to open asign menu, have a player type in some text and when they hit enter send the text they entered to them via chat message?
     
  16. But where? I can't find it
     
  17. Opening the sign and getting the user's input seems to still work in 1.16.1. According to the protocol wiki, nothing changed packet wise. However, ingame in the sign GUI I'm not able to see the pre defined lines im setting in the code (it worked in 1.15.2). Is this just an issue with ProtocolLib or does the code have to be changed to support 1.16 fully?
     
  18. @Michey: The blank lines when using the sign editor to update an existing sign is a bug in the Minecraft 1.16.1 client. It is not possible to fix it or work around it from the server side.
     
    • Informative Informative x 1
  19. Interesting. Hopefully this will get fixed in 1.16.2 or beyond.