fix /name visual bug

This commit is contained in:
D1GQ committed 2024-08-10 18:20:50 -05:00
1 parent 5e9180c5d2
commit 331145b227
1 file changed
+11 -4
+11 -4
View File
@@ -190,12 +190,15 @@ class CommandsPatch
Main.CommandPrefix.Value = subArgs;
break;
case "name":
bool hasSet = false;
if (GameStates.IsHost)
{
PlayerControl.LocalPlayer.RpcSetName(command[1]);
_ = new LateTask(() =>
{
RPC.SyncAllNames();
hasSet = true;
}, 1f, $"Command {Main.CommandPrefix.Value}name");
}
else if (command.Length > 1 && !string.IsNullOrWhiteSpace(command[1]) && System.Text.RegularExpressions.Regex.IsMatch(command[1], @"^[a-zA-Z0-9]+$"))
@@ -203,6 +206,7 @@ class CommandsPatch
if (HandleHasPermission(command) == true)
{
PlayerControl.LocalPlayer.CmdCheckName(command[1]);
hasSet = true;
}
}
else
@@ -211,9 +215,12 @@ class CommandsPatch
return;
}
PlayerControl.LocalPlayer.Data.PlayerName = command[1];
DataManager.Player.customization.Name = command[1];
Utils.AddChatPrivate($"Player name has been sent to: {command[1]}");
if (hasSet)
{
PlayerControl.LocalPlayer.Data.PlayerName = command[1];
DataManager.Player.customization.Name = command[1];
Utils.AddChatPrivate($"Player name has been sent to: {command[1]}");
}
break;
case "kick" or "ban":
if (HandlePlayerArgument(command, subArgs) == true)
@@ -475,7 +482,7 @@ class CommandsPatch
{
string error = "<color=#f50000><size=150%><b>Error:</b></size></color>";
if (HasPermission != true && !GameStates.IsHost && !GameStates.IsDev)
if (HasPermission != true || !GameStates.IsHost && !GameStates.IsDev)
{
Utils.AddChatPrivate($"{error}\n<color=#e0b700><b>{command[0]}</b></color> Is only available with the host permission!\nask the host to type /allow in chat to get permissions");
return false;