Hiding a playername for another player

Discussion in 'Plugin Development' started by Gravious, Sep 1, 2012.

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

    Gravious

    Hello everyone,

    How do I hide the name that appears above a player's head for another player?
    Similar to holding SHIFT, but then only hiding it for one player while the others can still see the name.

    Thanks in advance
     
  2. Offline

    jamietech

    You could try setting it to a blank string with TagAPI or the DisguseCraftAPI
     
  3. Offline

    Gravious

    But how would I be able to make it blank for ONLY ONE specific player?

    Does anyone have experience with TagAPI and how to use it?
    I don't quite understand the PlayerReceiveNameTagEvent...

    Sorry for the triple post, but I've figured out a bit more about TagAPI.

    TagAPI Github: https://github.com/KittehOrg/TagAPI/tree/master/src
    TagAPI itself: https://github.com/KittehOrg/TagAPI/tree/master/src/main/java/org/kitteh/tag
    TagAPI example: https://github.com/KittehOrg/TagAPI.../java/org/kitteh/tag/ExampleTagAPIPlugin.java

    Now what I want to do is similar to what Kitteh did in the example:


    @EventHandler
    public void onNameTag(PlayerReceiveNameTagEvent event) {
    // Here are some examples, to be considered separately as they may overlap
    /*
    * First example.
    * Every player I see will be Notch
    */
    if (event.getPlayer().getName().equals("ViewingPlayer")) { // ViewingPlayer is the user RECEIVING the nametag packet
    event.setTag("Notch"); // Set the tag for this event to Notch
    }
    }


    But then instead of 'Notch' I could change it to ''.

    So I put this in my plugin but the event never gets called (and yes, I did add an @EventHandler).


    How would I make this work? Anyone has experience with this?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  4. Offline

    jamietech

    Code:java
    1. @EventHandler
    2. public void onNameTag(PlayerReceiveNameTagEvent event) {
    3. if (event.getPlayer().getName().equals("PlayerWhoCan'tSeeTheName") && event.getNamedPlayer().getName().equals("PlayerToHide")) {
    4. event.setTag("");
    5. }
    6. }
     
  5. Offline

    Gravious

    I'm using that exact code, but the event doesn't get called at all, how do I fix this?
     
  6. Offline

    jamietech

    The event gets called every time a user is sent a name tag.
     
  7. Offline

    Gravious

    I have figured it out. Thanks for the help jamietech!
    Also, thanks to 'ammar2' on the #kitteh.org IRC
     
Thread Status:
Not open for further replies.

Share This Page