Placeholder per player in hologram

Discussion in 'Spigot Plugin Development' started by DarkKnights22, Jan 9, 2020.

  1. Either with Holographic Displays, or with my own armorstand creator (former is preferred), how do I create placeholders that change for every player that looks at it?
     
  2. Use placeholderapi's api which is really easy to use, then you can give each armorstand a custom displayname, this is only if you choose to create your own plugin, otherwise you can buy leaderheads which does exactly what you want :)
     
    • Informative Informative x 1
  3. SteelPhoenix

    Moderator

    They send different packets to each player, with the different armor stand names (because they differ per player) PacketPlayOutNamedEntitySpawn I believe
     
  4. PlaceholderAPI doesn't support holograms though.
     
  5. Oh, I'd rather stick to the Spigot API only and not use nms etc.
     
  6. ProtocolLib?
     
    • Like Like x 1
  7. Ah, yes how would I do it with ProtocolLib?
     
  8. SteelPhoenix

    Moderator

    Send the exact same packet but then use ProtocolLib to do it
     
    • Agree Agree x 2
  9. FrostedSnowman

    Resource Staff

    Either send packets that hold data specific to the player receiving the packet, or listen to entity meta data packet and rewrite the packet information to include specific data to the player receiving it before it actually gets sent
     
  10. Code (Java):
    PacketContainer packetContainer = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY);
    What would I do from here?
    packetContainer.getStrings().write()?
     
  11. You can do this using HolographicsDisplay coupled with ProtocolLib
     
  12. How?
     
  13. i still think spawning a server side only armor stand then modifying the display name then sending for each player a different one is easier
     
  14. How would you do that?
     
  15. FrostedSnowman

    Resource Staff

    Intercept entity meta data packets, and change the displayname in the packet being sent to whatever you want it to be
     
  16. Never dealt with packets before, cold you show me an example?
     
  17. I don't think is as easy as you think, like it's the very basic thing on how the server comunicates with it's clients,1. you would have to break out of the api interface into the craftbukkit then getting the handle of your entityarmorstand then after that changing the datawatcher of the entity then sending a packet thru the clients you want to see that datawatcher send, I don't know an example would help you, you would need to venture beyond what the bukkit provides and slowly learning how it works, it's actually not that hard plus you would learn a lot from it or 2. You can use protocollib, pretty sure you can find some examples of what you look for but you won't understand too much as it's built with being generic in mind and it's also a lot slower since it uses reflections to have multi version support with the ever changing minecraft server inners
     
    • Agree Agree x 1
  18. HolographicExtension
    Allows placeholders to be used in holograms
    https://www.spigotmc.org/resources/holographicextension.18461/

    Javascript Expansion
    Allows you to make custom placeholders
    https://api.extendedclip.com/expansions/javascript/
    Example:
    Code (Javascript):

    var e = "%player_has_permission_this.is.a.permission.1%";
    var i = "%player_has_permission_this.is.a.permission.2%";
    var a = args[0];

    function displays() {
        if (a === "text1"){
            if (e === "yes"){return "Text for permission 1";} else if (i === "yes"){return "Text for permission 2";}}
        else if (a === "text2"){
            if (e === "yes"){return "Text2 for permission 1";} else if (i === "yes"){return "Text2 for permission 2";}}
    }
    displays();
     
    And when you use %javascript_<name in cofig>_text1% the text will appear depending on the permission
     
    • Like Like x 1
  19. @Rubenicos
    Here's your first rating ツ I forgot about HoloExt... it's definitely a quality plugin.

    @DarkKnights22
    Seeming as you want to avoid packet management, you should take a look at his suggestion. It adds all of PlaceholderAPI's placeholders too, not just %player%, which might come in handy.
    Are you sure HolographicDisplays doesn't have a {PLAYER} placeholder or something alike?
     
    • Like Like x 1