@quenty/playerutils 8.16.0 → 8.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +6 -6
- package/src/Shared/PlayerUtils.lua +29 -16
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.16.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playerutils@8.16.0...@quenty/playerutils@8.16.1) (2025-03-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/playerutils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [8.16.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playerutils@8.15.0...@quenty/playerutils@8.16.0) (2025-02-18)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @quenty/playerutils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/playerutils",
|
|
3
|
-
"version": "8.16.
|
|
3
|
+
"version": "8.16.1",
|
|
4
4
|
"description": "Player utility functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/brio": "^14.16.
|
|
32
|
-
"@quenty/instanceutils": "^13.16.
|
|
31
|
+
"@quenty/brio": "^14.16.1",
|
|
32
|
+
"@quenty/instanceutils": "^13.16.1",
|
|
33
33
|
"@quenty/loader": "^10.8.0",
|
|
34
34
|
"@quenty/maid": "^3.4.0",
|
|
35
|
-
"@quenty/promise": "^10.10.
|
|
36
|
-
"@quenty/rx": "^13.16.
|
|
35
|
+
"@quenty/promise": "^10.10.1",
|
|
36
|
+
"@quenty/rx": "^13.16.1"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "6b7c3e15e60cdb185986207b574e2b5591261e7a"
|
|
39
39
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
@class PlayerUtils
|
|
3
4
|
]=]
|
|
@@ -20,7 +21,7 @@ local PlayerUtils = {}
|
|
|
20
21
|
@param player Player
|
|
21
22
|
@return string -- Formatted name
|
|
22
23
|
]=]
|
|
23
|
-
function PlayerUtils.formatName(player)
|
|
24
|
+
function PlayerUtils.formatName(player: Player): string
|
|
24
25
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
25
26
|
|
|
26
27
|
local name = player.Name
|
|
@@ -50,12 +51,18 @@ function PlayerUtils.formatDisplayName(name: string, displayName: string): strin
|
|
|
50
51
|
end
|
|
51
52
|
end
|
|
52
53
|
|
|
54
|
+
export type UserInfo = {
|
|
55
|
+
Username: string,
|
|
56
|
+
DisplayName: string,
|
|
57
|
+
HasVerifiedBadge: boolean,
|
|
58
|
+
}
|
|
59
|
+
|
|
53
60
|
--[=[
|
|
54
61
|
Formats the display name from the user info
|
|
55
62
|
@param userInfo UserInfo
|
|
56
63
|
@return string
|
|
57
64
|
]=]
|
|
58
|
-
function PlayerUtils.formatDisplayNameFromUserInfo(userInfo): string
|
|
65
|
+
function PlayerUtils.formatDisplayNameFromUserInfo(userInfo: UserInfo): string
|
|
59
66
|
assert(type(userInfo) == "table", "Bad userInfo")
|
|
60
67
|
assert(type(userInfo.Username) == "string", "Bad userInfo.Username")
|
|
61
68
|
assert(type(userInfo.DisplayName) == "string", "Bad userInfo.DisplayName")
|
|
@@ -80,9 +87,9 @@ function PlayerUtils.addVerifiedBadgeToName(name: string): string
|
|
|
80
87
|
end
|
|
81
88
|
|
|
82
89
|
local NAME_COLORS = {
|
|
83
|
-
BrickColor.new("Bright red").Color
|
|
84
|
-
BrickColor.new("Bright blue").Color
|
|
85
|
-
BrickColor.new("Earth green").Color
|
|
90
|
+
BrickColor.new("Bright red").Color,
|
|
91
|
+
BrickColor.new("Bright blue").Color,
|
|
92
|
+
BrickColor.new("Earth green").Color,
|
|
86
93
|
BrickColor.new("Bright violet").Color,
|
|
87
94
|
BrickColor.new("Bright orange").Color,
|
|
88
95
|
BrickColor.new("Bright yellow").Color,
|
|
@@ -90,15 +97,15 @@ local NAME_COLORS = {
|
|
|
90
97
|
BrickColor.new("Brick yellow").Color,
|
|
91
98
|
}
|
|
92
99
|
|
|
93
|
-
local function hashName(
|
|
100
|
+
local function hashName(playerName: string): number
|
|
94
101
|
local value = 0
|
|
95
|
-
for index = 1, #
|
|
96
|
-
local cValue = string.byte(string.sub(
|
|
97
|
-
local reverseIndex = #
|
|
98
|
-
if #
|
|
102
|
+
for index = 1, #playerName do
|
|
103
|
+
local cValue = string.byte(string.sub(playerName, index, index))
|
|
104
|
+
local reverseIndex = #playerName - index + 1
|
|
105
|
+
if #playerName % 2 == 1 then
|
|
99
106
|
reverseIndex = reverseIndex - 1
|
|
100
107
|
end
|
|
101
|
-
if reverseIndex%4 >= 2 then
|
|
108
|
+
if reverseIndex % 4 >= 2 then
|
|
102
109
|
cValue = -cValue
|
|
103
110
|
end
|
|
104
111
|
value = value + cValue
|
|
@@ -112,7 +119,7 @@ end
|
|
|
112
119
|
@param displayName string
|
|
113
120
|
@return Color3
|
|
114
121
|
]=]
|
|
115
|
-
function PlayerUtils.getDefaultNameColor(displayName)
|
|
122
|
+
function PlayerUtils.getDefaultNameColor(displayName: string): Color3
|
|
116
123
|
return NAME_COLORS[(hashName(displayName) % #NAME_COLORS) + 1]
|
|
117
124
|
end
|
|
118
125
|
|
|
@@ -122,7 +129,7 @@ end
|
|
|
122
129
|
@param player Player
|
|
123
130
|
@return Promise<Model>
|
|
124
131
|
]=]
|
|
125
|
-
function PlayerUtils.promiseLoadCharacter(player)
|
|
132
|
+
function PlayerUtils.promiseLoadCharacter(player: Player)
|
|
126
133
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
127
134
|
|
|
128
135
|
return Promise.spawn(function(resolve, reject)
|
|
@@ -144,9 +151,15 @@ end
|
|
|
144
151
|
@param humanoidDescription HumanoidDescription
|
|
145
152
|
@return Promise<Model>
|
|
146
153
|
]=]
|
|
147
|
-
function PlayerUtils.promiseLoadCharacterWithHumanoidDescription(
|
|
154
|
+
function PlayerUtils.promiseLoadCharacterWithHumanoidDescription(
|
|
155
|
+
player: Player,
|
|
156
|
+
humanoidDescription: HumanoidDescription
|
|
157
|
+
)
|
|
148
158
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
149
|
-
assert(
|
|
159
|
+
assert(
|
|
160
|
+
typeof(humanoidDescription) == "Instance" and humanoidDescription:IsA("HumanoidDescription"),
|
|
161
|
+
"Bad humanoidDescription"
|
|
162
|
+
)
|
|
150
163
|
|
|
151
164
|
return Promise.spawn(function(resolve, reject)
|
|
152
165
|
local ok, err = pcall(function()
|
|
@@ -160,4 +173,4 @@ function PlayerUtils.promiseLoadCharacterWithHumanoidDescription(player, humanoi
|
|
|
160
173
|
end)
|
|
161
174
|
end
|
|
162
175
|
|
|
163
|
-
return PlayerUtils
|
|
176
|
+
return PlayerUtils
|