Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Username #267

Open
MTRNord opened this issue Aug 17, 2016 · 12 comments
Open

Set Username #267

MTRNord opened this issue Aug 17, 2016 · 12 comments
Labels

Comments

@MTRNord
Copy link
Contributor

MTRNord commented Aug 17, 2016

Hi is there an way to change the Username of the person who ran an command? Like an auto nick? (I only search the function to set the Username. The Rest am I working on)

@ghost
Copy link

ghost commented Aug 17, 2016

You may be able to change the username property on the player by running player.username = "name";

@MTRNord
Copy link
Contributor Author

MTRNord commented Aug 17, 2016

ok I will try that :)

@rom1504
Copy link
Member

rom1504 commented Aug 18, 2016

"Username of the person who ran an command" I'm not sure what you mean by that. When should the username be changed ?

@MTRNord
Copy link
Contributor Author

MTRNord commented Aug 18, 2016

Imagine someone types "/nick" in the Chat. My plugin should be triggerd and the name/nick of this Person should change for others. So I need a was to change the property username of the person who ran the command "/nick"

@rom1504
Copy link
Member

rom1504 commented Aug 18, 2016

Ok here is how you can add such a command #126 (comment)
It is not possible (because of the minecraft protocol) to change the username.
However you can change the displayName. To do that you need to send the player_info packet http://prismarinejs.github.io/minecraft-data/?d=protocol#toClient_player_info to everybody with action set to 3 and with the display name you want.

 serv._writeAll('player_info',{
      action: 3,
      data: [{
        UUID: player._client.uuid,
        displayName: "new_display_name"
      }]
    });

@MTRNord
Copy link
Contributor Author

MTRNord commented Aug 18, 2016

Yeah I think that is what I searched for :) thanks

@MTRNord
Copy link
Contributor Author

MTRNord commented Aug 18, 2016

Also: wouldn't it be better if the chat lib uses instead of the Username the displayName or do I mix something up there?

@rom1504
Copy link
Member

rom1504 commented Aug 18, 2016

here is an example to create a command https://github.com/PrismarineJS/flying-squid/blob/master/doc/API.md#playercommands

What do you mean by chat lib ?

I'm not sure where the display name should be used, but yeah maybe we should use it at some places. Do tell if you find places where the display name make more sense than the username ;)

@MTRNord
Copy link
Contributor Author

MTRNord commented Aug 18, 2016

I mean the Name that is showed before an chat message :) There could maybe the DisplayName make sense.

@rom1504
Copy link
Member

rom1504 commented Aug 18, 2016

Does the vanilla server do it ?
How is the display name set in the vanilla client (/with a vanilla server) ?

@MTRNord
Copy link
Contributor Author

MTRNord commented Aug 18, 2016

From Bukkit (Spigot Code GIT): https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/entity/Player.java#44 (I reference Bukkit because Bukkit also does have Nick plugins and the vanilla one doesn't)

There says the inline Documentation (at least i understand it in that way), that the Display Name is used in the Chat.

@ghost
Copy link

ghost commented Sep 1, 2016

Ah. I see. So the actual username of the player is retained, but the display name is changed. 👍 this should be fixed as to not cause future player data saving errors based off of username when people change the username instead of display name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants