Force player to open Book & Quill

Discussion in 'Plugin Development' started by Lordloss, May 4, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    Lordloss

    Hello,
    i found this util for force-opening books

    https://www.spigotmc.org/threads/resource-bookutil-1-8-1-9.131549/

    it works well for 1.9, but i can only get it to work with written books. I need this for book & quill, so the player is able to write into it and i can listen for it in the PlayerEditBookEvent.

    If i change the Material to Material.BOOK_AND_QUILL it just does nothing at all.

    Thanks in advance for any suggestions you give me.
     
  2. Offline

    Lordloss

    bump, it would be really neat if someone could explain why this does not work.
     
  3. Offline

    WinX64

    I've done a quick read on the library, it calls this method via reflection:
    Code:
    public void a(ItemStack itemstack, EnumHand enumhand)
    {
      Item item = itemstack.getItem();
      if (item == Items.WRITTEN_BOOK)
      {
        PacketDataSerializer packetdataserializer = new PacketDataSerializer(Unpooled.buffer());
    
        packetdataserializer.a(enumhand);
        this.playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|BOpen", packetdataserializer));
      }
    }
    
    As you can see, it will only work for signed books. Both of them are handled via plugin message channels, but editable books are handled by a completely different one, in this case, MC|BEdit.
    There're should be(Haven't checked anything aside from this) another method that handles book & quill, but this one won't do it.


    EDIT: Ignore what I just said above, I got some things mixed up in there.
    Signed books are handled entirely by the server. You right click them, and the server sends the data back to your client telling it to open it and the uneditable text is displayed, that is done via MC|BOpen.

    Book & Quills however, are handled by the client. You open them via client, edit the book and when the edit is finished, the client sends the new updated text to the server, that is done via MC|BEdit.

    So in theory, opening editable book GUIs via the server shouldn't be possible.
     
    Last edited: May 5, 2016
    Lordloss likes this.
  4. Offline

    Lordloss

    Thats very sad if its true. It would have been a perfect solution for entering large texts without chat conversation. so i have to give them a written book and make sure they cant store them / do things theyre not supposed to do with it. :rolleyes:
     
  5. Offline

    WinX64

    An alternate solution would be using a sign instead of book & quill, although the text space is very limited compared to them.
     
    Lordloss likes this.
  6. Offline

    Lordloss

    Yes, its even shorter than the chat, so its no good alternative, but thanks for your suggestions ;)
     
  7. Offline

    teej107

    There's always the conversation API
     
    timtower likes this.
  8. Offline

    I Al Istannen

    @teej107
    He did say "large texts" though. Chat is capped at a few hundred chars. But, yes I do like the Conversation API too ;)
     
Thread Status:
Not open for further replies.

Share This Page