How to create text on client

Discussion in 'Plugin Development' started by tytwining, Sep 1, 2015.

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

    tytwining

    I was seeing how some servers have text above where it says the item name when you scroll over an item have custom text there. How can you do that?
     
  2. Offline

    finalblade1234

    If your making plugins:
    http://hastebin.com/atilepuxus.coffee Is a simple method i like using to rename items.
    If your looking for plugins:
    Essentials has a command called /item, you can get a renamed peice of dirt by typing: /item dirt 1 name:&6custom_text_here
     
  3. Offline

    mine-care

    @finalblade1234 I think the op means the action bar.

    The action bar can be accessed by a PacketPlayOutChat sent with a message in json format. To achieve this construct a new packet and as the display slot byte put 2 and as the text the string you want to send in json.
     
  4. Offline

    Im4youPlay

    Code:
      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);
                ((CraftPlayer) p).getHandle().playerConnection.sendPacket(ppoc);
            }
     
  5. Offline

    mine-care

    @Im4youPlay In these forums most active members are against spoonfeeding, i belong in these members as well.
    The reason why we are so against it is because from experience most people end up directly copying and parting the code without reading it or gaining any knowledge from it. Then more questions arise and so on. So guiding a player thorught the solution is way better than just giving them a piece of code without even bothering to explain it.

    Also i got reasons to suspect that you are not the author of this pieace of code:
    http://bukkit.org/threads/second-item-name-bar-like-on-hive.317003/#post-2853419
    https://www.spigotmc.org/threads/send-action-bar-message.81232/
    https://github.com/grzegorz2047/SpectatorMode/blob/master/src/pl/grzegorz2047/testapi/Utils.java
     
    DuaneTheDev_ likes this.
  6. Offline

    stormneo7

    If you can Google the solution, the OP can too. In addition, there's nothing to 'learn' about how to send an Action Bar message without learning packets all together; it takes more than 1 thread. Nothing's wrong with giving away a constructor that Bukkit should have in Player.java The same goes for sending Title and SubTitle messages! I support spoonfeeding in minor cases but from the larger perspective where someone is asking what 3+3 is, that's obviously not okay.
     
  7. Offline

    mine-care

    @stormneo7
    i will disagree with you. If the op had thought of googling the question, then probably we wouldnt have this thread on.
    Also
    So you need to know how all packets work to be able to set the action bar message ? Also you should get a start from somewhere, what i learned from packets so far was because i discovered through the docs and different attempts that they have more to offer than the Bukkit api or that i can do crazy things with them, I am not saying that telling someone "Look up packets. " would be an answer but couldnt we just explain how it can be done step by step? this way the OP could gain some knowledge about the message format followed by MC (Json), how to send a packet and so on and so forth. i cant accept that there is no knowledge to be gained. There is always knowledge to be gained.
    Lets see it from another point of view now, Would it hurt explaining to someone what they are puting in their plugins? If the code provided was documented and explained what does what then the storry would have been differnt, that would be a tutorial not raw spoonfeeding;

    Lastly the quote "Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime." exists for a reason.

    I can show some understanding to what you are saying but in this case i dont think spoonfeeding is nessesayrry. Lets allow people to follow the path twards achieving something themselvs instead of getting it ready in a box from someone else.
     
  8. Offline

    tytwining

    I will note that I did attempt to google it, however without knowing the exact name you will not usually get very far.

    In addition, what would learning about packets do to help really any normal person? I'm not trying to start any argument or anything here, it is a serious question.
     
  9. Offline

    mine-care

    @tytwining Since you are the OP and you ask this:
    Ill consider it On topic and ill answer, Packets is the core comunication between server & client, i dont think that people learning packets are paranormal, As i said,
    Thats enough, for example Title/subtitle messages, action bar messages, and many more are available only through packets. Also i belive that most of us will at some point wonder how they work, how they are sent/received, throungh what protocol and other questions about them.
    For me it all started as an attempt to edit the ammount of Player slots apearing on the tab list for a client despite the ammount they where for the client, (Back in 1.7.X as you remember the tab list was of fixed columns and rows specified by the max players set on the properties. Eventually i succeeded in editing the outgoing login packet. That is what got me to discover all the abilities that packets have and what they have to offer you.
     
Thread Status:
Not open for further replies.

Share This Page