Solved ActionBar Trouble

Discussion in 'Plugin Development' started by BaddCamden, Jun 29, 2021.

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

    BaddCamden

    I thought this would be simple but so far it is proving to be a herculean task to create a simple action bar. I started with the NMS (Edit: they weren't outdated, just using an outdated API as well as outdated imports ;/) packets but obviously, they don't work (outdated since 1.8 i think), then I used the action bar API, still doesn't work. I don't want to have to use spigot, so are there any ways to create an action bar without the use of spigot in 1.17?
     
    Last edited: Jul 1, 2021
  2. Offline

    Shqep

    @BaddCamden
    How can NMS packets be outdated tho? They are the core of a Minecraft server, without them, Craftbukkit and its forks won't really do anything on their own.
    Refer to this packet.

    For 1.8 - 1.10 ish (?), use the byte "2" for the action bar slot.
    After these versions up to 1.16.4, use the Title packet with the ActionBar enum.
    For the latest 1.17, there's an ActionBar packet.

    And if there's official methods in the Bukkit APIs from any versions, consider using them over NMS.
     
  3. Offline

    BaddCamden

    Ah I thought that NMS packets were outdated, but I think I was thinking about the specific imports I was using.

    Can you provide an example with the import? I think I understand what you are saying but I am still a little confused

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 29, 2021
  4. Offline

    Shqep

    @BaddCamden
    Keep in mind that you're using NMS, if you use 1.8 jar to develop, you will use the import "v1_8_R1".
    And that import will not work on any versions that's not 1.8.
    If you want cross-version support, see ProtocolLib, or look into Abstraction and Reflection if you want to do it yourself.

    Code:Java
    1. // 1.8 - some versions below 1.12
    2. PacketPlayOutChat(ChatSerializer.a(json), 2);
    3.  
    4. // 1.12
    5. // The times for the title need to be sent before the actual title.
    6. PacketPlayOutTitle(fadeIn, stay, fadeOut);
    7. // Then the action bar.
    8. PacketPlayOutTitle(EnumTitleAction.ACTION_BAR, stuff);


    I haven't messed around with 1.17, refer to these packets in the Protocol wiki:
    - ActionBar packet (0x41)
    - Times packet (0x5A)
     
  5. Offline

    BaddCamden


    Possibly unrelated to the previous issue, but I updated protocol lib and this error showed up when I attempted to send the packet: playerConnection cannot be resolved or is not a field.

    This is the line of code:
    Code:
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(bar);
    


    EDIT: Also this line previously worked on different plugins I have made
     
  6. Offline

    Shqep

    Is this an IDE error or a server error?

    If it's an IDE error, are you sure the field was not made private in the jar? Are you sure it's named "playerConnection"? What if obfuscation somehow changed the PlayerConnection field name?
    If this is the case, I'm pretty sure ProtocolLib does support sending the packets for you. Why not send through it?

    If it's a server error, is there a version mismatch between the development library and the server core?
    If this is the case, you know what to do.
     
  7. Offline

    BaddCamden

    Not an IDE error, not a version mismatch, and ProtocolLib can send packets for me but it has to be through PacketContainers I believe, and I wouldn't even the slightest idea on how to do that.


    EDIT: Went back to bukkit 1.16, it is obfuscation I believe. playerConnection no longer exists anymore


    EDIT EDIT: I think I figured out a way to do sidebars and by that extent, I think I am likely to find a way to use action bars as well since they both use scoreboards I believe.

    EDIT EDIT EDIT: Nevermind
     
    Last edited: Jun 29, 2021
  8. Offline

    Shqep

    @BaddCamden
    Code:Java
    1. public PlayerConnection b;

    PlayerConnection is now "b" in 1.17.
     
  9. Offline

    BaddCamden

    Thank you so much!



    I will post my code whenever I get to doing it, but I think this may have fixed my issue!
     
Thread Status:
Not open for further replies.

Share This Page