Skip to content

Commit

Permalink
Attempt to fix unbanning on changed player names (#1819)
Browse files Browse the repository at this point in the history
* Attempt to fix unbanning on changed player names

* Proactive fix for Banning API plugin

GetUserIdFromNameAsync & GetNameFromUserIdAsync returns the UserId/Name if a player Instance is passed.
  • Loading branch information
fxeP1 authored Jan 9, 2025
1 parent 258b376 commit 3f21e39
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MainModule/Server/Commands/Admins.luau
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ return function(Vargs, env)
UseFakePlayer = true;
})
do
if Admin.RemoveBan(v.Name) then
if Admin.RemoveBan(v) then
Functions.LogAdminAction(plr, "Unban", v.Name, "User has been unbanned.")
Functions.Hint(`{service.FormatPlayer(v, true)} has been unbanned`, {plr})
else
Expand Down
4 changes: 2 additions & 2 deletions MainModule/Server/Commands/HeadAdmins.luau
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ return function(Vargs, env)
do
Functions.LogAdminAction(plr, "Un-Time Ban", v.Name, "Removed from timeban list")
Functions.Hint(
if Admin.RemoveTimeBan(v.Name)
if Admin.RemoveTimeBan(v)
then `{service.FormatPlayer(v, true)} has been un-time-banned`
else `{service.FormatPlayer(v, true)} is not currently time-banned`,
{plr}
Expand Down Expand Up @@ -153,7 +153,7 @@ return function(Vargs, env)
do
Functions.LogAdminAction(plr, "Unbanned", v.Name, "N/A")
Functions.Hint(
if Admin.RemoveBan(v.Name, true)
if Admin.RemoveBan(v, true)
then `{service.FormatPlayer(v, true)} has been unbanned from the game`
else `{service.FormatPlayer(v, true)} is not currently banned`,
{plr}
Expand Down
14 changes: 11 additions & 3 deletions MainModule/Server/Core/Functions.luau
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ return function(Vargs, GetEnv)
table.insert(tab,result)
end
end

return tab
end;

Expand Down Expand Up @@ -1405,7 +1405,11 @@ return function(Vargs, GetEnv)
return AllGrabbedPlayers
end;

GetUserIdFromNameAsync = function(name)
GetUserIdFromNameAsync = function(name: string | Player)
if type(name) == "userdata" and name:IsA("Player") then
return name.UserId
end

local cache = Admin.UserIdCache[name]
if not cache then
local success, UserId = pcall(service.Players.GetUserIdFromNameAsync, service.Players, name)
Expand All @@ -1419,7 +1423,11 @@ return function(Vargs, GetEnv)
return cache
end;

GetNameFromUserIdAsync = function(id)
GetNameFromUserIdAsync = function(id: number | Player)
if type(id) == "userdata" and id:IsA("Player") then
return id.Name
end

local cache = Admin.UsernameCache[id]
if not cache then
local success, Username = pcall(service.Players.GetNameFromUserIdAsync, service.Players, id)
Expand Down

0 comments on commit 3f21e39

Please sign in to comment.