Solved ActionBar Messsage

Discussion in 'Spigot Plugin Development' started by Nosmakos, May 22, 2016.

  1. hey guys when i went to a server and i was killing zombies i received money but the message wasn't in the chat but it was above the xp bar and every time i was killing zombies it showed me above the xp bar +10 any idea how this works?
     
  2. @Nosma_Stew there's no 'API' for the protocol.

    TitleManager can do what you want without having to make your hands dirty with reflection.
    The JavaDoc can be found here
     
  3. thank you so much for the help!! i appreciate it ! i will use the protocol so i can do this i want :D
     
  4. Wat? You cannot say "I will use the protocol" - Thats like saying "I will use the airplane fuel" when you fly somewhere!
     
  5. don't try to say that for the likes :p
    yeah well now im searching for the position so i can take the message above the bar
     
  6. What do you mean?
     
  7. i don't really want to use an api i want to create it :/
     
  8. Use packets.
     
  9. hmm nice idea thanks because when a player kills a zombie the message show in the chat and this can be really spamming method
     
  10. @Nosma_Stew if you want to do it yourself, this page can help:
    https://www.spigotmc.org/threads/actionbar-help.43909/
    Code (Java):
    public static void sendActionBar(Player player, String message){
            CraftPlayer p = (CraftPlayer) player;
            IChatBaseComponent cbc = ChatSerializer.a("{\"text\": \"" + message + "\"}");
            PacketPlayOutChat ppoc = new PacketPlayOutChat(cbc, (byte) 2);
            p.getHandle().playerConnection.sendPacket(ppoc);
        }
    OP from that thread used a different server version in their IDE as their server, that's why it didn't work there. If you make sure you have the same version, it should work. Make sure to include CraftBukkit/Spigot Server as dependency instead of Bukkit/Spigot API.

    This is not version-stable, unfortunately. But since you're not so experienced with this yet, I recommend using this for now
     
  11. Please do not spoonfeed

    Gesendet von meinem Nexus 5 mit Tapatalk
     
  12. yeah i already went there before to search as much i can to make this also thanks for the help i will try as much i can to do this ! i will set the thread as solved thought.
     
  13. he is not spoonfeeding and please only english here.
     
    • Funny Funny x 1
  14. The last sentence is automated xD
     
    • Agree Agree x 1
  15. hahaha lol
     
  16. @Jo_Jo_2000 Something is usually called spoonfeeding when you can easily explain how to do something and some other special cases. When I'm just giving a utility method, I wouldn't call it spoonfeeding.

    How would you have 'explained' it?
     
    • Agree Agree x 1
  17. so i just tried a code for the actionbar message and it's worked. When player is killing a zombie it adds to his bank 10 Points and now when he kills it i take this message on the action bar. :D
    upload_2016-5-23_0-13-14.png