Only allow characters that are valid in usernames for os renames

This commit is contained in:
Goodlyay 2025-08-06 16:54:22 -07:00
parent 4aa61f7623
commit cec3a316ca
2 changed files with 4 additions and 1 deletions

View File

@ -443,6 +443,9 @@ namespace MCGalaxy.Commands.World {
"&H With <name>, renames to 'yourname[name]'.",
};
static void HandleRename(Player p, string args) {
if (args.Length > 0 && !Formatter.IsValidName(p, args, "os name", Player.USERNAME_ALPHABET)) {
return;
}
UseCommand(p, "RenameLvl", p.level.name + " " + GetLevelName(p, args));
}

View File

@ -90,7 +90,7 @@ namespace MCGalaxy
return IsValidName(p, name, "player", alphabet);
}
static bool IsValidName(Player p, string name, string type, string alphabet) {
public static bool IsValidName(Player p, string name, string type, string alphabet) {
if (name.Length > 0 && name.ContainsAllIn(alphabet)) return true;
p.Message("\"{0}\" is not a valid {1} name.", name, type);
return false;