@quenty/playerutils 1.1.0 → 1.1.1-canary.38bdfe3.0

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 CHANGED
@@ -3,6 +3,17 @@
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
+ ## [1.1.1-canary.38bdfe3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playerutils@1.1.0...@quenty/playerutils@1.1.1-canary.38bdfe3.0) (2022-09-07)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add PlayerUtils.getDefaultNameColor() API ([4cff733](https://github.com/Quenty/NevermoreEngine/commit/4cff733c86bb00a7c61c22af47994f5e6123c701))
12
+
13
+
14
+
15
+
16
+
6
17
  # 1.1.0 (2022-07-31)
7
18
 
8
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/playerutils",
3
- "version": "1.1.0",
3
+ "version": "1.1.1-canary.38bdfe3.0",
4
4
  "description": "Player utility functions",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -27,5 +27,5 @@
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "e31b3a35aa475bb5699a24898a8639e107165b36"
30
+ "gitHead": "38bdfe3721bddf1d272628b1104b1d8e0abaf24f"
31
31
  }
@@ -29,4 +29,40 @@ function PlayerUtils.formatName(player)
29
29
  end
30
30
  end
31
31
 
32
+ local NAME_COLORS = {
33
+ BrickColor.new("Bright red").Color;
34
+ BrickColor.new("Bright blue").Color;
35
+ BrickColor.new("Earth green").Color;
36
+ BrickColor.new("Bright violet").Color,
37
+ BrickColor.new("Bright orange").Color,
38
+ BrickColor.new("Bright yellow").Color,
39
+ BrickColor.new("Light reddish violet").Color,
40
+ BrickColor.new("Brick yellow").Color,
41
+ }
42
+
43
+ local function hashName(pName)
44
+ local value = 0
45
+ for index = 1, #pName do
46
+ local cValue = string.byte(string.sub(pName, index, index))
47
+ local reverseIndex = #pName - index + 1
48
+ if #pName%2 == 1 then
49
+ reverseIndex = reverseIndex - 1
50
+ end
51
+ if reverseIndex%4 >= 2 then
52
+ cValue = -cValue
53
+ end
54
+ value = value + cValue
55
+ end
56
+ return value
57
+ end
58
+
59
+ --[=[
60
+ Retrieves the display name color for a given player (for the Roblox chat)
61
+ @param displayName string
62
+ @return Color3
63
+ ]=]
64
+ function PlayerUtils.getDefaultNameColor(displayName)
65
+ return NAME_COLORS[(hashName(displayName) % #NAME_COLORS) + 1]
66
+ end
67
+
32
68
  return PlayerUtils