player.setName(String Name) method

  • on our server we do not want to allow spaces in player names that is mainly because most plugins do not support spaces in player names. An important example is that there exists currently no teleport to player function that supports spaces in player names and if someone is griefing/misbehaving we cannot go to them fast to see what is going on.


    Thus would like to ask for a player.setName(String Name) method so I can manually change their names when they log in to our server to use underscores instead of spaces.


    If that is not something you would like to give as a function @red51 (as it can be abused to change player names to w/e a plugin creator would want) then could we get some method like e.g. player.trimName() that automatically changes spaces to underscores so that it is safer for everyone players and plugin creators?

  • I know this may be out of place, but wouldn't it also be feasible to be able to use the current player ID number from the TAB window? It may need a new plug-in,


    Even if the underscore/space is removed, it will be difficult to teleport to players who have names similar to "000010101010101010001", "x__X__x_Name_X_x_", and so on. Being able to simply use "/tp 11", for that current player's ID, would seem much more feasible.


    I know this was possible, just not sure if that might have changed in the last few months.

  • It is not only about teleporting, that was just an example, for instance the areaprotection script doesn't support names with spaces and similarly the current areaprotection plugin doesn't too.


    Having spaces in names is just a super extra hassle plugin creators have to care for when creating plugins (most of them don't even consider it atm and their plugins do not work with spaces in names) and I don't think it is worth the effort for the 10 people who like a space in their name.

    I know this may be out of place, but wouldn't it also be feasible to be able to use the current player ID number from the TAB window? It may need a new plug-in,

    yes this is entirely possible and would be an easy fast solution at least for the teleporting problem :) I think one of the teleporting plugins or scripts did support this at some point but can't remember right now :/

  • Yes, I should have clarified more, the ID was able to be used to add the Owner to the claim as well, not just to TP, for the same reasons I mentioned.

  • Huh? Which area protection script/plugin was that, non i have seen have had this capability :/

  • While I cannot think of a specific example, I would not be surprised if such a user renaming would raise other problems, so I would not be so sure about it.


    Plug-ins should phase player names out anyway, as they no longer are distinctive and may, at least in theory, be duplicate. Probably it will take a while for the existing plug-ins to catch up but sooner or later they will have to.

  • The point is @Miwarre not that the plugins are storing the names ofc all plugins should store UIDs now but when using commands in game.


    Then when I want to have a command /tp PlayerName I would have to care what the playername consists of and if it has 1, 2, 3, infinite spaces in it. Noone will use a /tp UID command because it is a burden to look up a UID every time I want to tp to my friend. Similarly for more complex commands.

  • just tested this and I can write a name in game with up to 9 space characters, having to write a command that can accept that would be stupid imo

  • The point is @Miwarre not that the plugins are storing the names ofc all plugins should store UIDs now but when using commands in game.

    I understood this point. Still, once names start to be non-unique, typing names in commands would be ambiguous and a way around them would be needed.

    Then when I want to have a command /tp PlayerName I would have to care what the playername consists of and if it has 1, 2, 3, infinite spaces in it. Noone will use a /tp UID command because it is a burden to look up a UID every time I want to tp to my friend. Similarly for more complex commands.

    A 17-digit number is definitely not user-friendly to remember and to type without typos. Still, something should be thought in place of typing names.

  • Thing is it is really easy to use the name as a reference for a currently online player, similarly ofc you can use their current server ID or their general world database ID which are both definitely shorter than the steam UID. So these two are good solutions but I still like the name method more as it is more user friendly to type /tp Miwarre than press TAB to find your ID and then type /tp 45.


    A common practice many gaming companies use it to not allow spaces in names as it saves them a lot of trouble dealing with these space characters. Similarly in Unix based systems we do not like spaces in file/directory names as they can cause problems in Shell commands.

  • @red51 any thoughts on this? I would like to hear your opinion too :)

  • Sorry for the late response! I put that on my list, but I have to check out first if name changes on the fly really do not cause any trouble for the server. Since the hive update in February, the user name no longer matters (although most game commands still use it, but that shouldn't matter), so basically that should work.


    Unless I find some serious issues with the name changes, a player.setName(String) method will be available with the next update :)


    In the medium run, we will probably also add another way to execute certain commands. Maybe by rightclicking on the player name in the scoreboard or something like that^^

  • Btw now that you said game commands, the console tp and goto commands don't work with spaces in the player name if I am not mistaken :/


    Haven't tested but I would expect a similar behaviour from the setplayergroup command :/

  • [...]Unless I find some serious issues with the name changes, a player.setName(String) method will be available with the next update :)

    Sorry for having routed the discussion away (into whether to use player names in commands or not).


    The main point I initially wanted to raise was that such a totally generic player renaming method would be very easy to abuse; I for one would be very upset if I find my character renamed on a server; not to mention that it could be renamed to something offensive (or that I consider offensive) or rude or...


    I am sure that @Minotorious will never do this, as well as most of the server owners we know and respect. But we can also be pretty sure that sooner or later someone will rename some (or all?) the characters on a server in a censurable way.


    If the problem are blanks in the name (as well as other problematic characters, like possibly quotes or apostrophe), I would understand an automatic procedure which replaces these characters in player names with underscores (or another 'jolly' character). Such a procedure could be documented and run 'blindly'.


    But the name of my character is my choice (within the rules), and not anybody else's.

  • Not a problem at all @Miwarre and you raise some really valid concerns on the topic, tbh I would prefer the suggested version of player.trimName() (or some similar command that automates the process so that I as a plugin creator don't have access to a player's name at all) as it is fully abuse free.

  • The main point I initially wanted to raise was that such a totally generic player renaming method would be very easy to abuse; I for one would be very upset if I find my character renamed on a server; not to mention that it could be renamed to something offensive (or that I consider offensive) or rude or...

    Hmm... good point! That's indeed an issue... although I don't know if a plugin (or a server) is really going to abuse it (probably players will leave a server anyway if it's messing around with their names, especially in an abusive way). On the other hand, there might be some valid cases where a name change makes sense, e.g. a "reallife server", which assigns a real name to the player (i.e. first name + last name)...
    But I'm not sure if the advantages really outweigh the possible risks :|


    tbh I would prefer the suggested version of player.trimName()

    I'm not sure about that... it feels like a workaround for an issue that needs to be addressed anyway :D Instead of removing whitepaces, I'd prefer to replace them by underlines anyway (replacing "I am a rw player" by "I_am_a_rw_player" looks better than "Iamarwplayer")^^


    Maybe we have to look for other solutions. If changing the player name isn't a good idea, maybe it makes sense to restrict whitespaces by the game again (so they will be replaced by underlines or something like that automatically). Or maybe a new function for the PlayerCommandEvent which returns the individual arguments of the command (so you don't have to use "split()" anymore), but takes characters like " or ' into account (so you could use sth like "/command 'I am a rw player' param1 param2").

  • (replacing "I am a rw player" by "I_am_a_rw_player" looks better than "Iamarwplayer")^^

    oh that is what I meant by the trim command not remove the spaces but replace them with underscores:

    e.g. player.trimName() that automatically changes spaces to underscores so that it is safer for everyone players and plugin creators?

    Maybe we have to look for other solutions. If changing the player name isn't a good idea, maybe it makes sense to restrict whitespaces by the game again (so they will be replaced by underlines or something like that automatically).

    That would indeed make sense so when you type your character's name in the profile menu, when you press space an unerscore is written instead.

    Or maybe a new function for the PlayerCommandEvent which returns the individual arguments of the command (so you don't have to use "split()" anymore), but takes characters like " or ' into account (so you could use sth like "/command 'I am a rw player' param1 param2").

    I am not sure if this will fully work as a solution as in some keyboards when you press the: '/" key this character is written instead: `

  • I had a guy on my server last night that swore up and down he had a underscore in his name NL_Newfie but it showed up as NL Newfie with a space when I tried to TP to him I could not. I could not use his name at all in the console. The database captured he was using a space not underscore. The guestbook routine wrote the space too.


    If I edit the database to match his UID to a new name without the space would that mess with him or would the server just correct it or add another entry next time he logs on?

  • Just a little heads up, actually there will be a player.setName() method in the next update. I don't think that plugins are going to abuse this feature (if a plugin wants to troll a player, there are many other ways to do that which are even worse). In the end, the server owner is responsible to make sure he doesn't use any "troll plugins" (although if there will be ever a malicious plugin in the forums, we will remove it anyway) ^^

  • I had a guy on my server last night that swore up and down he had a underscore in his name NL_Newfie but it showed up as NL Newfie with a space when I tried to TP to him I could not. I could not use his name at all in the console. The database captured he was using a space not underscore. The guestbook routine wrote the space too.


    If I edit the database to match his UID to a new name without the space would that mess with him or would the server just correct it or add another entry next time he logs on?

    I suspect what happened here is that the player changed his Steam name, not the RW IGN. I've had that happen a few times so now I spell out that they need to return to the main menu and edit their Profile to change the name.

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!