@fnlb-project/fnbr 4.1.102 → 4.2.2
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/README.md +1 -1
- package/dist/resources/Endpoints.d.ts +1 -0
- package/dist/resources/Endpoints.js +2 -0
- package/dist/resources/Endpoints.js.map +1 -1
- package/dist/resources/defaultPartyMemberMeta.d.ts +30 -0
- package/dist/resources/defaultPartyMemberMeta.js +264 -0
- package/dist/resources/defaultPartyMemberMeta.js.map +1 -0
- package/dist/resources/enums.d.ts +8 -0
- package/dist/resources/enums.js +11 -1
- package/dist/resources/enums.js.map +1 -1
- package/dist/resources/httpResponses.d.ts +9 -0
- package/dist/resources/structs.d.ts +5 -17
- package/dist/src/managers/ChatManager.d.ts +59 -4
- package/dist/src/managers/ChatManager.js +127 -54
- package/dist/src/managers/ChatManager.js.map +1 -1
- package/dist/src/stomp/STOMP.d.ts +0 -1
- package/dist/src/stomp/STOMP.js +3 -21
- package/dist/src/stomp/STOMP.js.map +1 -1
- package/dist/src/structures/party/ClientPartyMember.d.ts +8 -11
- package/dist/src/structures/party/ClientPartyMember.js +116 -297
- package/dist/src/structures/party/ClientPartyMember.js.map +1 -1
- package/dist/src/structures/party/ClientPartyMemberMeta.js +15 -7
- package/dist/src/structures/party/ClientPartyMemberMeta.js.map +1 -1
- package/dist/src/structures/party/PartyChat.js +3 -1
- package/dist/src/structures/party/PartyChat.js.map +1 -1
- package/dist/src/structures/party/PartyMember.d.ts +0 -8
- package/dist/src/structures/party/PartyMember.js +0 -12
- package/dist/src/structures/party/PartyMember.js.map +1 -1
- package/dist/src/structures/party/PartyMemberMeta.d.ts +5 -5
- package/dist/src/structures/party/PartyMemberMeta.js +44 -31
- package/dist/src/structures/party/PartyMemberMeta.js.map +1 -1
- package/dist/src/util/Util.d.ts +1 -0
- package/dist/src/util/Util.js +21 -1
- package/dist/src/util/Util.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const util_1 = require("util");
|
|
4
6
|
const Endpoints_1 = tslib_1.__importDefault(require("../../resources/Endpoints"));
|
|
5
7
|
const enums_1 = require("../../resources/enums");
|
|
6
8
|
const Base_1 = tslib_1.__importDefault(require("../Base"));
|
|
7
|
-
const UserNotFoundError_1 = tslib_1.__importDefault(require("../exceptions/UserNotFoundError"));
|
|
8
9
|
function customUUID() {
|
|
9
10
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
10
11
|
const r = Math.random() * 16 | 0;
|
|
@@ -18,98 +19,170 @@ const generateCustomCorrelationId = () => `EOS-${Date.now()}-${customUUID()}`;
|
|
|
18
19
|
* Represent's the client's chat manager (dm, party chat) via eos.
|
|
19
20
|
*/
|
|
20
21
|
class ChatManager extends Base_1.default {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
/**
|
|
25
|
+
* DM conversations cache map (account id -> conversation id)
|
|
26
|
+
*/
|
|
27
|
+
this.dmConversations = new Map();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether the keypair for message signing exists
|
|
31
|
+
*/
|
|
32
|
+
get keypairExists() {
|
|
33
|
+
return !!this.privateKey && !!this.publicKey;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Whether the keypair has been registered on epic's servers
|
|
37
|
+
*/
|
|
38
|
+
get keypairRegistered() {
|
|
39
|
+
return !!this.publicKeyData;
|
|
40
|
+
}
|
|
21
41
|
/**
|
|
22
42
|
* Returns the chat namespace, this is the eos deployment id
|
|
23
43
|
*/
|
|
24
44
|
get namespace() {
|
|
25
45
|
return this.client.config.eosDeploymentId;
|
|
26
46
|
}
|
|
27
|
-
async getConversationId(userId) {
|
|
28
|
-
const data = await this.client.http.epicgamesRequest({
|
|
29
|
-
method: 'POST',
|
|
30
|
-
url: `${Endpoints_1.default.EOS_CHAT}/v1/public/_/conversations?createIfExists=false`,
|
|
31
|
-
headers: {
|
|
32
|
-
'Content-Type': 'application/json',
|
|
33
|
-
},
|
|
34
|
-
data: {
|
|
35
|
-
title: '',
|
|
36
|
-
type: 'dm',
|
|
37
|
-
members: [this.client.user.self.id, userId],
|
|
38
|
-
},
|
|
39
|
-
}, enums_1.AuthSessionStoreKey.FortniteEOS);
|
|
40
|
-
return data.conversationId;
|
|
41
|
-
}
|
|
42
47
|
/**
|
|
43
48
|
* Sends a private message to the specified user
|
|
44
49
|
* @param user the account id or displayname
|
|
45
50
|
* @param message the message object
|
|
46
51
|
* @returns the message id
|
|
52
|
+
* @throws {UserNotFoundError} When the specified user was not found
|
|
53
|
+
* @throws {EpicgamesAPIError} When the api request failed
|
|
47
54
|
*/
|
|
48
55
|
async whisperUser(user, message) {
|
|
49
56
|
const accountId = await this.client.user.resolveId(user);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
const conversationId = await this.getDMConversationId(accountId);
|
|
58
|
+
return this.sendMessageInConversation(conversationId, message, [accountId, this.client.user.self.id], enums_1.ConversationType.DirectMessage);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Sends a message in the specified conversation (e.g. party chat)
|
|
62
|
+
* @param conversationId the conversation id, usually `p-[PARTYID]`
|
|
63
|
+
* @param message the message object
|
|
64
|
+
* @param allowedRecipients the account ids, that should receive the message
|
|
65
|
+
* @returns the message id
|
|
66
|
+
* @throws {EpicgamesAPIError}
|
|
67
|
+
*/
|
|
68
|
+
async sendMessageInConversation(conversationId, message, allowedRecipients, conversationType) {
|
|
69
|
+
const correlationId = generateCustomCorrelationId();
|
|
70
|
+
const { body, signature } = await this.createSignedMessage(conversationId, message.body, conversationType === enums_1.ConversationType.DirectMessage ? enums_1.SignedMessageType.Persistent : enums_1.SignedMessageType.Party);
|
|
55
71
|
await this.client.http.epicgamesRequest({
|
|
56
72
|
method: 'POST',
|
|
57
|
-
url: `${Endpoints_1.default.EOS_CHAT}/v1/public
|
|
73
|
+
url: `${Endpoints_1.default.EOS_CHAT}/v1/public/${conversationType === enums_1.ConversationType.DirectMessage ? '_' : this.namespace}`
|
|
74
|
+
+ `/conversations/${conversationId}/messages?fromAccountId=${this.client.user.self.id}`,
|
|
58
75
|
headers: {
|
|
59
76
|
'Content-Type': 'application/json',
|
|
60
|
-
|
|
77
|
+
'X-Epic-Correlation-ID': correlationId,
|
|
61
78
|
},
|
|
62
79
|
data: {
|
|
63
|
-
allowedRecipients
|
|
80
|
+
allowedRecipients,
|
|
64
81
|
message: {
|
|
65
82
|
body,
|
|
66
83
|
},
|
|
67
84
|
isReportable: false,
|
|
68
85
|
metadata: {
|
|
69
86
|
TmV: '2',
|
|
70
|
-
Pub: this.
|
|
71
|
-
Sig:
|
|
87
|
+
Pub: this.publicKeyData.jwt,
|
|
88
|
+
Sig: signature,
|
|
89
|
+
NPM: conversationType === enums_1.ConversationType.Party ? '1' : undefined,
|
|
72
90
|
PlfNm: this.client.config.platform,
|
|
73
91
|
PlfId: this.client.user.self.id,
|
|
74
92
|
},
|
|
75
93
|
},
|
|
76
|
-
});
|
|
77
|
-
return
|
|
94
|
+
}, enums_1.AuthSessionStoreKey.FortniteEOS);
|
|
95
|
+
return correlationId;
|
|
96
|
+
}
|
|
97
|
+
async createDMConversation(recepientId, createIfExists = false) {
|
|
98
|
+
return this.client.http.epicgamesRequest({
|
|
99
|
+
method: 'POST',
|
|
100
|
+
url: `${Endpoints_1.default.EOS_CHAT}/v1/public/_/conversations?createIfExists=${createIfExists}`,
|
|
101
|
+
headers: {
|
|
102
|
+
'Content-Type': 'application/json',
|
|
103
|
+
},
|
|
104
|
+
data: {
|
|
105
|
+
title: '',
|
|
106
|
+
type: 'dm',
|
|
107
|
+
members: [this.client.user.self.id, recepientId],
|
|
108
|
+
},
|
|
109
|
+
}, enums_1.AuthSessionStoreKey.FortniteEOS);
|
|
78
110
|
}
|
|
79
111
|
/**
|
|
80
|
-
*
|
|
81
|
-
* @param conversationId the conversation id, usually `p-[PARTYID]`
|
|
82
|
-
* @param message the message object
|
|
83
|
-
* @param allowedRecipients the account ids, that should receive the message
|
|
84
|
-
* @returns the message id
|
|
112
|
+
* Ensures that message signing is possible
|
|
85
113
|
*/
|
|
86
|
-
async
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
114
|
+
async ensureMessageSigning() {
|
|
115
|
+
if (!this.keypairExists) {
|
|
116
|
+
await this.generateKeypair();
|
|
117
|
+
}
|
|
118
|
+
if (!this.keypairRegistered) {
|
|
119
|
+
await this.registerKeypair();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Resolves the conversation id for a dm with the specified user
|
|
124
|
+
* @param recepientId The account id of the recepient
|
|
125
|
+
* @returns The conversation id
|
|
126
|
+
*/
|
|
127
|
+
async getDMConversationId(recepientId) {
|
|
128
|
+
if (this.dmConversations.has(recepientId)) {
|
|
129
|
+
return this.dmConversations.get(recepientId);
|
|
130
|
+
}
|
|
131
|
+
const conversationData = await this.createDMConversation(recepientId);
|
|
132
|
+
this.dmConversations.set(recepientId, conversationData.conversationId);
|
|
133
|
+
return conversationData.conversationId;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Signs a message for the specified conversation
|
|
137
|
+
* @param conversationId The conversation id
|
|
138
|
+
* @param content The message content
|
|
139
|
+
* @param type The signed message type
|
|
140
|
+
*/
|
|
141
|
+
async createSignedMessage(conversationId, content, type) {
|
|
142
|
+
await this.ensureMessageSigning();
|
|
143
|
+
const timestamp = Date.now();
|
|
144
|
+
const messageInfo = {
|
|
145
|
+
mid: customUUID(),
|
|
146
|
+
sid: this.client.user.self.id,
|
|
147
|
+
rid: conversationId,
|
|
148
|
+
msg: content,
|
|
149
|
+
tst: timestamp,
|
|
150
|
+
seq: 1,
|
|
151
|
+
rec: false,
|
|
152
|
+
mts: [],
|
|
153
|
+
cty: type,
|
|
154
|
+
};
|
|
155
|
+
const body = Buffer.from(JSON.stringify(messageInfo), 'utf-8').toString('base64');
|
|
156
|
+
const messageToSign = Buffer.concat([Buffer.from(body, 'utf-8'), Buffer.from([0])]);
|
|
157
|
+
const signature = (0, crypto_1.sign)(null, messageToSign, this.privateKey).toString('base64');
|
|
158
|
+
return { body, signature };
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Generates a ed25519 keypair for message signing
|
|
162
|
+
*/
|
|
163
|
+
async generateKeypair() {
|
|
164
|
+
const { privateKey, publicKey } = await (0, util_1.promisify)(crypto_1.generateKeyPair)('ed25519');
|
|
165
|
+
const spkiDer = publicKey.export({ type: 'spki', format: 'der' });
|
|
166
|
+
const rawPublicKey = spkiDer.subarray(spkiDer.length - 32);
|
|
167
|
+
this.privateKey = privateKey;
|
|
168
|
+
this.publicKey = rawPublicKey.toString('base64');
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Registers the public key on epic's servers
|
|
172
|
+
*/
|
|
173
|
+
async registerKeypair() {
|
|
174
|
+
const publicKeyData = await this.client.http.epicgamesRequest({
|
|
90
175
|
method: 'POST',
|
|
91
|
-
url: `${Endpoints_1.default.
|
|
176
|
+
url: `${Endpoints_1.default.PUBLICKEY}/v2/publickey`,
|
|
92
177
|
headers: {
|
|
93
178
|
'Content-Type': 'application/json',
|
|
94
|
-
Authorization: `bearer ${eosSession.easAccessToken}`,
|
|
95
179
|
},
|
|
96
180
|
data: {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
body,
|
|
100
|
-
},
|
|
101
|
-
isReportable: false,
|
|
102
|
-
metadata: {
|
|
103
|
-
TmV: '2',
|
|
104
|
-
Pub: this.client.keyData.jwt,
|
|
105
|
-
Sig: signatureString,
|
|
106
|
-
NPM: '1',
|
|
107
|
-
PlfNm: this.client.config.platform,
|
|
108
|
-
PlfId: this.client.user.self.id,
|
|
109
|
-
},
|
|
181
|
+
key: this.publicKey,
|
|
182
|
+
algorithm: 'ed25519',
|
|
110
183
|
},
|
|
111
|
-
});
|
|
112
|
-
|
|
184
|
+
}, enums_1.AuthSessionStoreKey.Fortnite);
|
|
185
|
+
this.publicKeyData = publicKeyData;
|
|
113
186
|
}
|
|
114
187
|
}
|
|
115
188
|
exports.default = ChatManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatManager.js","sourceRoot":"","sources":["../../../src/managers/ChatManager.ts"],"names":[],"mappings":";;;AAAA,kFAAkD;AAClD,
|
|
1
|
+
{"version":3,"file":"ChatManager.js","sourceRoot":"","sources":["../../../src/managers/ChatManager.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAC/C,+BAAiC;AACjC,kFAAkD;AAClD,iDAAiG;AACjG,2DAA2B;AAK3B,SAAS,UAAU;IACjB,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;QAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gBAAgB;AAChB,MAAM,2BAA2B,GAAG,GAAG,EAAE,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,UAAU,EAAE,EAAE,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAY,SAAQ,cAAI;IAA9B;;QACE;;WAEG;QACK,oBAAe,GAAwB,IAAI,GAAG,EAAE,CAAC;IAyN3D,CAAC;IAxMC;;OAEG;IACH,IAA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c,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE;gBACJ,GAAG,EAAE,IAAI,CAAC,SAAS;gBACnB,SAAS,EAAE,SAAS;aACrB;SACF,EAAE,2BAAmB,CAAC,QAAQ,CAAC,CAAC;QAEjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -28,7 +28,6 @@ declare class STOMP extends Base {
|
|
|
28
28
|
* Whether the internal websocket is connected
|
|
29
29
|
*/
|
|
30
30
|
get isConnected(): boolean | undefined;
|
|
31
|
-
private decodeBody;
|
|
32
31
|
/**
|
|
33
32
|
* Connect to the STOMP server
|
|
34
33
|
* @throws {AuthenticationMissingError} When there is no EOS auth to use for STOMP auth
|
package/dist/src/stomp/STOMP.js
CHANGED
|
@@ -11,6 +11,7 @@ const PartyMessage_1 = tslib_1.__importDefault(require("../structures/party/Part
|
|
|
11
11
|
const STOMPConnectionTimeoutError_1 = tslib_1.__importDefault(require("../exceptions/STOMPConnectionTimeoutError"));
|
|
12
12
|
const STOMPMessage_1 = tslib_1.__importDefault(require("./STOMPMessage"));
|
|
13
13
|
const STOMPConnectionError_1 = tslib_1.__importDefault(require("../exceptions/STOMPConnectionError"));
|
|
14
|
+
const Util_1 = require("../util/Util");
|
|
14
15
|
/**
|
|
15
16
|
* Represents the client's EOS Connect STOMP manager (i.e. chat messages)
|
|
16
17
|
*/
|
|
@@ -31,25 +32,6 @@ class STOMP extends Base_1.default {
|
|
|
31
32
|
get isConnected() {
|
|
32
33
|
return this.connection && this.connection.readyState === ws_1.default.OPEN;
|
|
33
34
|
}
|
|
34
|
-
decodeBody(body) {
|
|
35
|
-
var _a;
|
|
36
|
-
if (!body)
|
|
37
|
-
return '';
|
|
38
|
-
try {
|
|
39
|
-
const decoded = Buffer.from(body, 'base64')
|
|
40
|
-
.toString('utf-8')
|
|
41
|
-
.replace(/\0+$/, '');
|
|
42
|
-
try {
|
|
43
|
-
return (_a = JSON.parse(decoded).msg) !== null && _a !== void 0 ? _a : decoded;
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
return decoded;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
return '';
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
35
|
/**
|
|
54
36
|
* Connect to the STOMP server
|
|
55
37
|
* @throws {AuthenticationMissingError} When there is no EOS auth to use for STOMP auth
|
|
@@ -150,7 +132,7 @@ class STOMP extends Base_1.default {
|
|
|
150
132
|
if (!friend || senderId === this.client.user.self.id)
|
|
151
133
|
return;
|
|
152
134
|
const friendMessage = new ReceivedFriendMessage_1.default(this.client, {
|
|
153
|
-
content:
|
|
135
|
+
content: (0, Util_1.decodeSTOMPMessageBody)(body),
|
|
154
136
|
author: friend,
|
|
155
137
|
id: data.id,
|
|
156
138
|
sentAt: new Date(time),
|
|
@@ -171,7 +153,7 @@ class STOMP extends Base_1.default {
|
|
|
171
153
|
if (!authorMember)
|
|
172
154
|
return;
|
|
173
155
|
const partyMessage = new PartyMessage_1.default(this.client, {
|
|
174
|
-
content:
|
|
156
|
+
content: (0, Util_1.decodeSTOMPMessageBody)(body),
|
|
175
157
|
author: authorMember,
|
|
176
158
|
sentAt: new Date(time),
|
|
177
159
|
id: data.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"STOMP.js","sourceRoot":"","sources":["../../../src/stomp/STOMP.ts"],"names":[],"mappings":";;;AAAA,oDAA2B;AAC3B,2DAA2B;AAC3B,iDAA4D;AAC5D,kHAAkF;AAClF,kFAAkD;AAClD,+GAA+E;AAC/E,4FAA4D;AAC5D,oHAAoF;AACpF,0EAA0C;AAC1C,sGAAsE;
|
|
1
|
+
{"version":3,"file":"STOMP.js","sourceRoot":"","sources":["../../../src/stomp/STOMP.ts"],"names":[],"mappings":";;;AAAA,oDAA2B;AAC3B,2DAA2B;AAC3B,iDAA4D;AAC5D,kHAAkF;AAClF,kFAAkD;AAClD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AAW,CAAC,IAAI,CAAC,IAAI,sBAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF;AAED,kBAAe,KAAK,CAAC"}
|
|
@@ -47,11 +47,9 @@ declare class ClientPartyMember extends PartyMember {
|
|
|
47
47
|
* Updates the client party member's battle pass info
|
|
48
48
|
* @param isPurchased Whether the battle pass is purchased
|
|
49
49
|
* @param level The battle pass level
|
|
50
|
-
* @param selfBoost The battle pass self boost percentage
|
|
51
|
-
* @param friendBoost The battle pass friend boost percentage
|
|
52
50
|
* @throws {EpicgamesAPIError}
|
|
53
51
|
*/
|
|
54
|
-
setBattlePass(isPurchased: boolean, level: number
|
|
52
|
+
setBattlePass(isPurchased: boolean, level: number): Promise<void>;
|
|
55
53
|
/**
|
|
56
54
|
* Updates the client party member's banner
|
|
57
55
|
* @param bannerId The new banner's id
|
|
@@ -60,14 +58,13 @@ declare class ClientPartyMember extends PartyMember {
|
|
|
60
58
|
*/
|
|
61
59
|
setBanner(bannerId: string, color: string): Promise<void>;
|
|
62
60
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
setCosmetics({ outfit, backpack, pickaxe, shoes, sidekick, }?: Cosmetics): Promise<void>;
|
|
61
|
+
* Updates multiple cosmetics for the client party member.
|
|
62
|
+
* If a cosmetic is set to `null`, it will be cleared.
|
|
63
|
+
* If a cosmetic is set to `undefined` or is not provided, it will remain unchanged.
|
|
64
|
+
* @param cosmetics An object specifying the cosmetics to update, including outfit, backpack, pickaxe and shoes.
|
|
65
|
+
* @throws {EpicgamesAPIError}
|
|
66
|
+
*/
|
|
67
|
+
setCosmetics(cosmetics?: Cosmetics): Promise<void>;
|
|
71
68
|
/**
|
|
72
69
|
* Updates the client party member's outfit
|
|
73
70
|
* @param id The outfit's ID
|