Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can I set the name of a player

Comments in 'Plugin Development' started by MyNameIsTriXz, Sep 1, 2016.

  1. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    How can I fully modify the name of a player? There is no Player::setName(), so how can I do it then?
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    You can change the name when the player logs in. Just handle DataPacketReceiveEvent, and change the username (16 character limit still applies). I wrote a small script awhile back to demonstrate it.
    But if you want to set it any other time, it might be a bit more difficult, maybe not. :)
  3. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    You can use reflections, but that's highly unstable, because many plugins use player names for identifying players, and changing them is very bad.

    Why do you want to do it though? Why not just change display name and nametag?
    If you just want to change the login name, check out NameCorrector. It might already do what you're trying to do
  4. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    There are so many players who dont know what login means or how to login. When they fail at login or their nane is Steve, then I give them a temporary name, so they can still play.
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Thanks
  6. JUZEXMOD
    Offline

    JUZEXMOD New Member

    Joined:
    May 28, 2016
    Posts:
    19
    Minecraft User:
    JUZEXMOD
    PHP:
    $player->setNameTag("Change name");
  7. XShockinFireX
    Offline

    XShockinFireX New Member

    Joined:
    Jan 28, 2016
    Posts:
    14
    Minecraft User:
    XShockinFireX
    What? That does NOT change the name of a player at all, all you will change is the NameTag.
    Primus likes this.
  8. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Surprise, surprise. That is why people name functions with proper names.
    Primus likes this.

Share This Page

Advertisement