Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Add a way to change name of Console and Remote Console `CommandSender`s

Open molor opened this issue 1 year ago • 1 comments
trafficstars

Is your feature request related to a problem?

Yes.

I want to change name of these senders to something that regular players cannot have (that doesn't match the regular expression [a-zA-Z0-9_.]{2,16} AKA valid player name).

Thus, in the case of public chat notifications about [remote] administration actions, and if a player "Rcon" or "CONSOLE" is connected to the server, it will be easy to understand who exactly performed some action (player CONSOLE or real console with name changed to, for example, "$erver" ($ isn't a valid symbol in player name) or "Remote Console" (player can't contain space in their name)).

Describe the solution you'd like.

Add a setting to Paper configuration, i.e. console-sender-name and remote-console-sender-name, with "default" values by default to keep the current behavior.

Describe alternatives you've considered.

Just check for the command sender class type in my plugins and use my custom Strings instead of CommandSender#getName().

But, even if I omit the fact that I have a lot of plugins and support for "custom Strings" needs to be added to each separately, then what to do with 3rd-party plugin notifications?...

Other

PR should be very simple, so I hope someone can save me from having to fork the entire server just to change a couple of lines in its source...

Related files:

  1. https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java#46
  2. https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java#39

molor avatar Mar 10 '24 10:03 molor

I wouldn't mind this, its not really a super common usecase, but not really harmful to add this.

lynxplay avatar Mar 10 '24 11:03 lynxplay

Another solution is to add a method like setName(String/Component) to these senders so their names can be changed via API to something different than current hard-coded default.

molor avatar Mar 22 '24 13:03 molor

hmm im curious about if is better a config or allow plugins alter this directly by code (method)

Doc94 avatar Mar 24 '24 19:03 Doc94