@quenty/friendutils 7.0.0-canary.331.7eefa75.0 → 7.0.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,7 +3,133 @@
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
- # [7.0.0-canary.331.7eefa75.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.1.0...@quenty/friendutils@7.0.0-canary.331.7eefa75.0) (2023-02-27)
6
+ # [7.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.15.0...@quenty/friendutils@7.0.0) (2023-10-11)
7
+
8
+ **Note:** Version bump only for package @quenty/friendutils
9
+
10
+
11
+
12
+
13
+
14
+ # [6.15.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.14.0...@quenty/friendutils@6.15.0) (2023-09-21)
15
+
16
+ **Note:** Version bump only for package @quenty/friendutils
17
+
18
+
19
+
20
+
21
+
22
+ # [6.14.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.13.0...@quenty/friendutils@6.14.0) (2023-09-04)
23
+
24
+ **Note:** Version bump only for package @quenty/friendutils
25
+
26
+
27
+
28
+
29
+
30
+ # [6.13.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.12.0...@quenty/friendutils@6.13.0) (2023-08-23)
31
+
32
+ **Note:** Version bump only for package @quenty/friendutils
33
+
34
+
35
+
36
+
37
+
38
+ # [6.12.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.11.0...@quenty/friendutils@6.12.0) (2023-07-28)
39
+
40
+ **Note:** Version bump only for package @quenty/friendutils
41
+
42
+
43
+
44
+
45
+
46
+ # [6.11.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.10.0...@quenty/friendutils@6.11.0) (2023-07-15)
47
+
48
+ **Note:** Version bump only for package @quenty/friendutils
49
+
50
+
51
+
52
+
53
+
54
+ # [6.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.9.0...@quenty/friendutils@6.10.0) (2023-06-17)
55
+
56
+ **Note:** Version bump only for package @quenty/friendutils
57
+
58
+
59
+
60
+
61
+
62
+ # [6.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.8.0...@quenty/friendutils@6.9.0) (2023-05-26)
63
+
64
+ **Note:** Version bump only for package @quenty/friendutils
65
+
66
+
67
+
68
+
69
+
70
+ # [6.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.7.0...@quenty/friendutils@6.8.0) (2023-05-08)
71
+
72
+ **Note:** Version bump only for package @quenty/friendutils
73
+
74
+
75
+
76
+
77
+
78
+ # [6.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.6.0...@quenty/friendutils@6.7.0) (2023-04-24)
79
+
80
+
81
+ ### Bug Fixes
82
+
83
+ * Fix missing dependencies ([3fbd817](https://github.com/Quenty/NevermoreEngine/commit/3fbd817b1fee45bda1b963b61a6ed22b0db12b82))
84
+
85
+
86
+
87
+
88
+
89
+ # [6.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.5.1...@quenty/friendutils@6.6.0) (2023-04-10)
90
+
91
+ **Note:** Version bump only for package @quenty/friendutils
92
+
93
+
94
+
95
+
96
+
97
+ ## [6.5.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.5.0...@quenty/friendutils@6.5.1) (2023-04-07)
98
+
99
+ **Note:** Version bump only for package @quenty/friendutils
100
+
101
+
102
+
103
+
104
+
105
+ # [6.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.4.0...@quenty/friendutils@6.5.0) (2023-04-03)
106
+
107
+
108
+ ### Features
109
+
110
+ * RxFriendUtils is available on server ([2d90850](https://github.com/Quenty/NevermoreEngine/commit/2d90850b5926fc953fd4875b8c6d243946291bf7))
111
+
112
+
113
+
114
+
115
+
116
+ # [6.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.3.0...@quenty/friendutils@6.4.0) (2023-03-31)
117
+
118
+ **Note:** Version bump only for package @quenty/friendutils
119
+
120
+
121
+
122
+
123
+
124
+ # [6.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.2.0...@quenty/friendutils@6.3.0) (2023-03-05)
125
+
126
+ **Note:** Version bump only for package @quenty/friendutils
127
+
128
+
129
+
130
+
131
+
132
+ # [6.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@6.1.0...@quenty/friendutils@6.2.0) (2023-02-27)
7
133
 
8
134
  **Note:** Version bump only for package @quenty/friendutils
9
135
 
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2014-2022 Quenty
3
+ Copyright (c) 2014-2023 James Onnen (Quenty)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/friendutils",
3
- "version": "7.0.0-canary.331.7eefa75.0",
3
+ "version": "7.0.0",
4
4
  "description": "Utlity functions to help find friends of a user. Also contains utility to make testing in studio easier.",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,11 +25,14 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/loader": "6.1.0",
29
- "@quenty/promise": "7.0.0-canary.331.7eefa75.0"
28
+ "@quenty/brio": "^9.0.0",
29
+ "@quenty/loader": "^7.0.0",
30
+ "@quenty/maid": "^2.6.0",
31
+ "@quenty/promise": "^7.0.0",
32
+ "@quenty/rx": "^8.0.0"
30
33
  },
31
34
  "publishConfig": {
32
35
  "access": "public"
33
36
  },
34
- "gitHead": "7eefa756f8bd892b1210349a8133d6d56992dffb"
37
+ "gitHead": "fdeae46099587019ec5fc15317dc673aed379400"
35
38
  }
@@ -20,9 +20,14 @@ local RxFriendUtils = {}
20
20
  The lifetimes exist for the whole duration another player is a friend and in your server.
21
21
  This means if a player is unfriended + friended multiple times per session, they will have emitted multiple friend lifetimes.
22
22
 
23
+ @param player Player | nil
23
24
  @return Observable<Brio<Player>>
24
25
  ]=]
25
- function RxFriendUtils.observeFriendsInServerAsBrios()
26
+ function RxFriendUtils.observeFriendsInServerAsBrios(player)
27
+ player = player or Players.LocalPlayer
28
+
29
+ assert(typeof(player) == "Instance", "Bad player")
30
+
26
31
  -- Note that 'PlayerFriendedEvent' and 'PlayerUnfriendedEvent' are currently unreliable.
27
32
  -- See: https://devforum.roblox.com/t/getcores-playerfriendedevent-and-playerunfriendedevent-bindableevents-firing-at-inappropriate-times/570403/4
28
33
  -- Due to players initially starting with an 'unknown' friend value, they fire for all players in the game at launch, and on the first time another player that joins the server.
@@ -49,43 +54,49 @@ function RxFriendUtils.observeFriendsInServerAsBrios()
49
54
  end
50
55
  end
51
56
 
52
- -- Handle players leaving / joining.
53
- maid:GiveTask(Players.PlayerRemoving:Connect(function(player: Player)
54
- maid[player] = nil
55
- end))
56
- local function handleNewPlayer(otherPlayer: Player)
57
- if otherPlayer ~= Players.LocalPlayer then
58
- -- You can't be friends with yourself!
59
- -- Pcall as :IsFriendsWith() could throw.
60
- local success, isFriendsWith = pcall(function()
61
- return Players.LocalPlayer:IsFriendsWith(otherPlayer.UserId)
57
+ local function handleNewPlayerAsync(otherPlayer: Player)
58
+ if otherPlayer ~= player then
59
+ local ok, isFriendsWith = pcall(function()
60
+ return player:IsFriendsWith(otherPlayer.UserId)
62
61
  end)
63
- if not success then
64
- warn(("[RxFriendUtils] Couldn't get friendship status with %q!"):format(otherPlayer.Name))
62
+ if not ok then
63
+ warn(string.format("[RxFriendUtils.observeFriendsInServerAsBrios] Couldn't get friendship status with %q!",
64
+ otherPlayer.Name))
65
+
66
+ -- If the call failed, then 'isFriendsWith' will be nil.
67
+ -- We'll assume that this player isn't a friend on failure.
68
+ handleFriendState(otherPlayer, false)
69
+ return
65
70
  end
66
- -- If the call failed, then 'isFriendsWith' will be nil.
67
- -- We'll assume that this player isn't a friend on failure.
71
+
68
72
  handleFriendState(otherPlayer, isFriendsWith)
69
73
  end
70
74
  end
71
- maid:GiveTask(Players.PlayerAdded:Connect(handleNewPlayer))
75
+
76
+ -- Handle players leaving / joining.
77
+ maid:GiveTask(Players.PlayerRemoving:Connect(function(otherPlayer: Player)
78
+ maid[otherPlayer] = nil
79
+ end))
80
+ maid:GiveTask(Players.PlayerAdded:Connect(handleNewPlayerAsync))
81
+
72
82
  for _, otherPlayer in Players:GetPlayers() do
73
- -- :IsFriendsWith() yields, so we call it in a new thread.
74
- task.defer(handleNewPlayer, otherPlayer)
83
+ task.spawn(handleNewPlayerAsync, otherPlayer)
75
84
  end
76
85
 
77
86
  -- Handle changes for players already in this server.
78
87
  -- There's a non-zero chance these get removed someday... :(
79
88
  -- https://devforum.roblox.com/t/playerfriendedevent-was-deleted-from-corescripts/696683
80
89
  -- So just incase these connections throw, use a new thread so we don't error out the whole observable.
81
- task.spawn(function()
82
- maid:GiveTask(StarterGui:GetCore("PlayerFriendedEvent").Event:Connect(function(player: Player)
83
- handleFriendState(player, true)
84
- end))
85
- maid:GiveTask(StarterGui:GetCore("PlayerUnfriendedEvent").Event:Connect(function(player: Player)
86
- handleFriendState(player, false)
87
- end))
88
- end)
90
+ if player == Players.LocalPlayer then
91
+ task.spawn(function()
92
+ maid:GiveTask(StarterGui:GetCore("PlayerFriendedEvent").Event:Connect(function(otherPlayer: Player)
93
+ handleFriendState(otherPlayer, true)
94
+ end))
95
+ maid:GiveTask(StarterGui:GetCore("PlayerUnfriendedEvent").Event:Connect(function(otherPlayer: Player)
96
+ handleFriendState(otherPlayer, false)
97
+ end))
98
+ end)
99
+ end
89
100
 
90
101
  return maid
91
102
  end)