@takaro/gameserver 0.0.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/README.md +36 -0
- package/dist/TakaroEmitter.d.ts +26 -0
- package/dist/TakaroEmitter.js +97 -0
- package/dist/TakaroEmitter.js.map +1 -0
- package/dist/gameservers/7d2d/apiResponses.d.ts +193 -0
- package/dist/gameservers/7d2d/apiResponses.js +2 -0
- package/dist/gameservers/7d2d/apiResponses.js.map +1 -0
- package/dist/gameservers/7d2d/connectionInfo.d.ts +32 -0
- package/dist/gameservers/7d2d/connectionInfo.js +58 -0
- package/dist/gameservers/7d2d/connectionInfo.js.map +1 -0
- package/dist/gameservers/7d2d/emitter.d.ts +30 -0
- package/dist/gameservers/7d2d/emitter.js +261 -0
- package/dist/gameservers/7d2d/emitter.js.map +1 -0
- package/dist/gameservers/7d2d/index.d.ts +28 -0
- package/dist/gameservers/7d2d/index.js +267 -0
- package/dist/gameservers/7d2d/index.js.map +1 -0
- package/dist/gameservers/7d2d/itemWorker.d.ts +1 -0
- package/dist/gameservers/7d2d/itemWorker.js +31 -0
- package/dist/gameservers/7d2d/itemWorker.js.map +1 -0
- package/dist/gameservers/7d2d/items-7d2d.json +17705 -0
- package/dist/gameservers/7d2d/sdtdAPIClient.d.ts +14 -0
- package/dist/gameservers/7d2d/sdtdAPIClient.js +60 -0
- package/dist/gameservers/7d2d/sdtdAPIClient.js.map +1 -0
- package/dist/gameservers/mock/connectionInfo.d.ts +20 -0
- package/dist/gameservers/mock/connectionInfo.js +37 -0
- package/dist/gameservers/mock/connectionInfo.js.map +1 -0
- package/dist/gameservers/mock/emitter.d.ts +12 -0
- package/dist/gameservers/mock/emitter.js +33 -0
- package/dist/gameservers/mock/emitter.js.map +1 -0
- package/dist/gameservers/mock/index.d.ts +31 -0
- package/dist/gameservers/mock/index.js +135 -0
- package/dist/gameservers/mock/index.js.map +1 -0
- package/dist/gameservers/rust/connectionInfo.d.ts +28 -0
- package/dist/gameservers/rust/connectionInfo.js +51 -0
- package/dist/gameservers/rust/connectionInfo.js.map +1 -0
- package/dist/gameservers/rust/emitter.d.ts +30 -0
- package/dist/gameservers/rust/emitter.js +160 -0
- package/dist/gameservers/rust/emitter.js.map +1 -0
- package/dist/gameservers/rust/index.d.ts +29 -0
- package/dist/gameservers/rust/index.js +189 -0
- package/dist/gameservers/rust/index.js.map +1 -0
- package/dist/gameservers/rust/items-rust.json +20771 -0
- package/dist/getGame.d.ts +8 -0
- package/dist/getGame.js +26 -0
- package/dist/getGame.js.map +1 -0
- package/dist/interfaces/GameServer.d.ts +57 -0
- package/dist/interfaces/GameServer.js +95 -0
- package/dist/interfaces/GameServer.js.map +1 -0
- package/dist/main.d.ts +9 -0
- package/dist/main.js +10 -0
- package/dist/main.js.map +1 -0
- package/package.json +26 -0
- package/src/TakaroEmitter.ts +138 -0
- package/src/TakaroEmitter.unit.test.ts +125 -0
- package/src/__tests__/gameEventEmitter.test.ts +36 -0
- package/src/gameservers/7d2d/__tests__/7d2dActions.unit.test.ts +91 -0
- package/src/gameservers/7d2d/__tests__/7d2dEventDetection.unit.test.ts +324 -0
- package/src/gameservers/7d2d/apiResponses.ts +214 -0
- package/src/gameservers/7d2d/connectionInfo.ts +40 -0
- package/src/gameservers/7d2d/emitter.ts +325 -0
- package/src/gameservers/7d2d/index.ts +318 -0
- package/src/gameservers/7d2d/itemWorker.ts +34 -0
- package/src/gameservers/7d2d/items-7d2d.json +17705 -0
- package/src/gameservers/7d2d/sdtdAPIClient.ts +82 -0
- package/src/gameservers/mock/connectionInfo.ts +25 -0
- package/src/gameservers/mock/emitter.ts +37 -0
- package/src/gameservers/mock/index.ts +156 -0
- package/src/gameservers/rust/__tests__/rustActions.unit.test.ts +140 -0
- package/src/gameservers/rust/connectionInfo.ts +35 -0
- package/src/gameservers/rust/emitter.ts +198 -0
- package/src/gameservers/rust/index.ts +230 -0
- package/src/gameservers/rust/items-rust.json +20771 -0
- package/src/getGame.ts +32 -0
- package/src/interfaces/GameServer.ts +95 -0
- package/src/main.ts +14 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +9 -0
- package/typedoc.json +3 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { logger } from '@takaro/util';
|
|
2
|
+
import EventSource from 'eventsource';
|
|
3
|
+
import { ChatChannel, EventChatMessage, EventEntityKilled, EventLogLine, EventPlayerConnected, EventPlayerDeath, EventPlayerDisconnected, GameEvents, IGamePlayer, } from '@takaro/modules';
|
|
4
|
+
import { TakaroEmitter } from '../../TakaroEmitter.js';
|
|
5
|
+
import { SevenDaysToDie } from './index.js';
|
|
6
|
+
import ms from 'ms';
|
|
7
|
+
/**
|
|
8
|
+
* 7d2d servers can get really spammy with bugged vehicles, buggy mods, etc.
|
|
9
|
+
* This is a list of messages that we don't want to emit events for.
|
|
10
|
+
*/
|
|
11
|
+
const blackListedMessages = [
|
|
12
|
+
'NullReferenceException',
|
|
13
|
+
'VehicleManager write #',
|
|
14
|
+
'Infinity or NaN floating point numbers appear when calculating the transform matrix for a Collider',
|
|
15
|
+
'IsMovementBlocked',
|
|
16
|
+
'Particle System is trying to spawn on a mesh with zero surface area',
|
|
17
|
+
'AddDecorationAt',
|
|
18
|
+
'EntityFactory CreateEntity: unknown type',
|
|
19
|
+
];
|
|
20
|
+
const EventRegexMap = {
|
|
21
|
+
[GameEvents.PLAYER_CONNECTED]: /PlayerSpawnedInWorld \(reason: (JoinMultiplayer|EnterMultiplayer), position: [-\d]+, [-\d]+, [-\d]+\): EntityID=(?<entityId>[-\d]+), PltfmId='(Steam|XBL)_[\w\d]+', CrossId='EOS_[\w\d]+', OwnerID='(Steam|XBL)_\d+', PlayerName='(?<name>.+)'/,
|
|
22
|
+
[GameEvents.PLAYER_DISCONNECTED]: /(Player disconnected: )/,
|
|
23
|
+
[GameEvents.CHAT_MESSAGE]: /Chat \(from '(?<platformId>[\w\d-]+)', entity id '(?<entityId>[-\d]+)', to '(?<channel>\w+)'\): '(?<name>.+)':(?<message>.+)/,
|
|
24
|
+
[GameEvents.PLAYER_DEATH]: /GMSG: Player '(?<name1>.+)' died|\[CSMM_Patrons\]playerDied: (?<name2>.+) \((?<steamOrXboxId>.+)\) died @ (?<xCoord>[-\d]+) (?<yCoord>[-\d]+) (?<zCoord>[-\d]+)/,
|
|
25
|
+
[GameEvents.ENTITY_KILLED]: /\[CSMM_Patrons\]entityKilled: (?<killerName>.+) \((?<steamOrXboxId>.+)\) killed (?<entityType>\w+) (?<entityName>\w+) with (?<weapon>.+)|Entity (?<entityName2>\w+) \d+ killed by (?<killerName2>.+) \d+/,
|
|
26
|
+
};
|
|
27
|
+
export class SevenDaysToDieEmitter extends TakaroEmitter {
|
|
28
|
+
constructor(config) {
|
|
29
|
+
super();
|
|
30
|
+
this.config = config;
|
|
31
|
+
this.SSERegex = /\d+-\d+-\d+T\d+:\d+:\d+ \d+\.\d+ INF (.+)/;
|
|
32
|
+
this.logger = logger('7D2D:SSE');
|
|
33
|
+
this.recentMessages = new Set(); // To track recent messages
|
|
34
|
+
this.lastMessageTimestamp = Date.now();
|
|
35
|
+
this.keepAliveTimeout = ms('30s');
|
|
36
|
+
this.sdtd = new SevenDaysToDie(config, {});
|
|
37
|
+
}
|
|
38
|
+
get url() {
|
|
39
|
+
return `${this.config.useTls ? 'https' : 'http'}://${this.config.host}/sse/log`;
|
|
40
|
+
}
|
|
41
|
+
async start() {
|
|
42
|
+
this.checkInterval = setInterval(() => {
|
|
43
|
+
if (Date.now() - this.lastMessageTimestamp >= this.keepAliveTimeout) {
|
|
44
|
+
this.logger.warn(`No messages received for ${ms(this.keepAliveTimeout, { long: true })}. Reconnecting...`);
|
|
45
|
+
this.lastMessageTimestamp = Date.now();
|
|
46
|
+
this.stop()
|
|
47
|
+
.then(() => this.start())
|
|
48
|
+
.catch((err) => this.logger.error('Error during reconnection', err));
|
|
49
|
+
}
|
|
50
|
+
}, 5000);
|
|
51
|
+
await Promise.race([
|
|
52
|
+
new Promise((resolve, reject) => {
|
|
53
|
+
this.logger.debug(`Connecting to ${this.config.host}`);
|
|
54
|
+
this.eventSource = new EventSource(this.url, {
|
|
55
|
+
headers: {
|
|
56
|
+
['X-SDTD-API-TOKENNAME']: this.config.adminUser,
|
|
57
|
+
['X-SDTD-API-SECRET']: this.config.adminToken,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
this.eventSource.addEventListener('logLine', (data) => this.listener(data));
|
|
61
|
+
this.eventSource.onerror = (e) => {
|
|
62
|
+
this.logger.error('Event source error', e);
|
|
63
|
+
return reject(e);
|
|
64
|
+
};
|
|
65
|
+
this.eventSource.onopen = () => {
|
|
66
|
+
this.logger.debug('Opened a SSE channel for server');
|
|
67
|
+
return resolve();
|
|
68
|
+
};
|
|
69
|
+
}),
|
|
70
|
+
new Promise((_resolve, reject) => {
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
reject(new Error('Timed out'));
|
|
73
|
+
}, 10000);
|
|
74
|
+
}),
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
async stop() {
|
|
78
|
+
if (this.checkInterval) {
|
|
79
|
+
clearInterval(this.checkInterval);
|
|
80
|
+
}
|
|
81
|
+
this.eventSource.removeEventListener('logLine', this.listener);
|
|
82
|
+
this.eventSource.close();
|
|
83
|
+
}
|
|
84
|
+
async parseMessage(logLine) {
|
|
85
|
+
this.logger.silly(`Received message from game server: ${logLine.msg}`);
|
|
86
|
+
if (!logLine.msg || typeof logLine.msg !== 'string') {
|
|
87
|
+
throw new Error('Invalid logLine');
|
|
88
|
+
}
|
|
89
|
+
if (blackListedMessages.some((msg) => logLine.msg.includes(msg))) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (EventRegexMap[GameEvents.PLAYER_CONNECTED].test(logLine.msg)) {
|
|
93
|
+
const data = await this.handlePlayerConnected(logLine);
|
|
94
|
+
await this.emit(GameEvents.PLAYER_CONNECTED, data);
|
|
95
|
+
}
|
|
96
|
+
if (EventRegexMap[GameEvents.PLAYER_DISCONNECTED].test(logLine.msg)) {
|
|
97
|
+
const data = await this.handlePlayerDisconnected(logLine);
|
|
98
|
+
await this.emit(GameEvents.PLAYER_DISCONNECTED, data);
|
|
99
|
+
}
|
|
100
|
+
if (EventRegexMap[GameEvents.CHAT_MESSAGE].test(logLine.msg)) {
|
|
101
|
+
const data = await this.handleChatMessage(logLine);
|
|
102
|
+
if (data)
|
|
103
|
+
await this.emit(GameEvents.CHAT_MESSAGE, data);
|
|
104
|
+
}
|
|
105
|
+
if (EventRegexMap[GameEvents.PLAYER_DEATH].test(logLine.msg)) {
|
|
106
|
+
const data = await this.handlePlayerDeath(logLine);
|
|
107
|
+
if (data)
|
|
108
|
+
await this.emit(GameEvents.PLAYER_DEATH, data);
|
|
109
|
+
}
|
|
110
|
+
if (EventRegexMap[GameEvents.ENTITY_KILLED].test(logLine.msg)) {
|
|
111
|
+
const data = await this.handleEntityKilled(logLine);
|
|
112
|
+
if (data)
|
|
113
|
+
await this.emit(GameEvents.ENTITY_KILLED, data);
|
|
114
|
+
}
|
|
115
|
+
await this.emit(GameEvents.LOG_LINE, new EventLogLine({
|
|
116
|
+
msg: logLine.msg,
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
async handlePlayerConnected(logLine) {
|
|
120
|
+
const nameMatches = /PlayerName='([^']+)/.exec(logLine.msg);
|
|
121
|
+
const platformIdMatches = /PltfmId='(.+)', CrossId=/.exec(logLine.msg);
|
|
122
|
+
const crossIdMatches = /CrossId='(.+)', OwnerID/.exec(logLine.msg);
|
|
123
|
+
const name = nameMatches ? nameMatches[1] : 'Unknown name';
|
|
124
|
+
const platformId = platformIdMatches ? platformIdMatches[1] : null;
|
|
125
|
+
const epicOnlineServicesId = crossIdMatches ? crossIdMatches[1].replace('EOS_', '') : undefined;
|
|
126
|
+
const gameId = epicOnlineServicesId;
|
|
127
|
+
const steamId = platformId && platformId.startsWith('Steam_') ? platformId.replace('Steam_', '') : undefined;
|
|
128
|
+
const xboxLiveId = platformId && platformId.startsWith('XBL_') ? platformId.replace('XBL_', '') : undefined;
|
|
129
|
+
if (!gameId)
|
|
130
|
+
throw new Error('Could not find gameId');
|
|
131
|
+
return new EventPlayerConnected({
|
|
132
|
+
msg: logLine.msg,
|
|
133
|
+
player: new IGamePlayer({
|
|
134
|
+
name,
|
|
135
|
+
gameId,
|
|
136
|
+
steamId,
|
|
137
|
+
xboxLiveId,
|
|
138
|
+
epicOnlineServicesId,
|
|
139
|
+
}),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async handlePlayerDisconnected(logLine) {
|
|
143
|
+
const nameMatch = /PlayerName='([^']+)/.exec(logLine.msg);
|
|
144
|
+
const platformIdMatches = /PltfmId='(.+)', CrossId=/.exec(logLine.msg);
|
|
145
|
+
const crossIdMatches = /CrossId='(.+)', OwnerID/.exec(logLine.msg);
|
|
146
|
+
const name = nameMatch ? nameMatch[1] : 'Unknown name';
|
|
147
|
+
const platformId = platformIdMatches ? platformIdMatches[1] : null;
|
|
148
|
+
const steamId = platformId && platformId.startsWith('Steam_') ? platformId.replace('Steam_', '') : undefined;
|
|
149
|
+
const xboxLiveId = platformId && platformId.startsWith('XBL_') ? platformId.replace('XBL_', '') : undefined;
|
|
150
|
+
const epicOnlineServicesId = crossIdMatches ? crossIdMatches[1].replace('EOS_', '') : undefined;
|
|
151
|
+
const gameId = epicOnlineServicesId;
|
|
152
|
+
if (!gameId)
|
|
153
|
+
throw new Error('Could not find gameId');
|
|
154
|
+
return new EventPlayerDisconnected({
|
|
155
|
+
msg: logLine.msg,
|
|
156
|
+
player: new IGamePlayer({
|
|
157
|
+
name,
|
|
158
|
+
gameId,
|
|
159
|
+
steamId,
|
|
160
|
+
xboxLiveId,
|
|
161
|
+
}),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
async handleChatMessage(logLine) {
|
|
165
|
+
const match = EventRegexMap[GameEvents.CHAT_MESSAGE].exec(logLine.msg);
|
|
166
|
+
if (!match)
|
|
167
|
+
throw new Error('Could not parse chat message');
|
|
168
|
+
const { groups } = match;
|
|
169
|
+
if (!groups)
|
|
170
|
+
throw new Error('Could not parse chat message');
|
|
171
|
+
const { platformId, name, message, channel } = groups;
|
|
172
|
+
if (platformId === '-non-player-' && name !== 'Server') {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const trimmedMessage = message.trim();
|
|
176
|
+
if (this.recentMessages.has(trimmedMessage)) {
|
|
177
|
+
return; // Ignore if recently processed
|
|
178
|
+
}
|
|
179
|
+
this.recentMessages.add(trimmedMessage);
|
|
180
|
+
setTimeout(() => this.recentMessages.delete(trimmedMessage), 1000);
|
|
181
|
+
const xboxLiveId = platformId.startsWith('XBL_') ? platformId.replace('XBL_', '') : undefined;
|
|
182
|
+
const steamId = platformId.startsWith('Steam_') ? platformId.replace('Steam_', '') : undefined;
|
|
183
|
+
if (steamId || xboxLiveId) {
|
|
184
|
+
const id = steamId || xboxLiveId || '';
|
|
185
|
+
const player = await this.sdtd.steamIdOrXboxToGameId(id);
|
|
186
|
+
let detectedChannel = ChatChannel.GLOBAL;
|
|
187
|
+
switch (channel) {
|
|
188
|
+
case 'Global':
|
|
189
|
+
detectedChannel = ChatChannel.GLOBAL;
|
|
190
|
+
break;
|
|
191
|
+
case 'Party':
|
|
192
|
+
detectedChannel = ChatChannel.TEAM;
|
|
193
|
+
break;
|
|
194
|
+
default:
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
if (player) {
|
|
198
|
+
return new EventChatMessage({
|
|
199
|
+
player,
|
|
200
|
+
channel: detectedChannel,
|
|
201
|
+
msg: trimmedMessage.trim(),
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async handlePlayerDeath(logLine) {
|
|
207
|
+
if (logLine.msg.includes('[CSMM_Patrons]') && !this.config.useCPM)
|
|
208
|
+
return;
|
|
209
|
+
if (logLine.msg.includes('GMSG') && this.config.useCPM)
|
|
210
|
+
return;
|
|
211
|
+
const match = EventRegexMap[GameEvents.PLAYER_DEATH].exec(logLine.msg);
|
|
212
|
+
if (!match)
|
|
213
|
+
throw new Error('Could not parse player death message');
|
|
214
|
+
const { groups } = match;
|
|
215
|
+
if (!groups)
|
|
216
|
+
throw new Error('Could not parse player death message');
|
|
217
|
+
const { xCoord, yCoord, zCoord, steamOrXboxId } = groups;
|
|
218
|
+
const player = await this.sdtd.steamIdOrXboxToGameId(steamOrXboxId);
|
|
219
|
+
return new EventPlayerDeath({
|
|
220
|
+
msg: logLine.msg,
|
|
221
|
+
player,
|
|
222
|
+
position: {
|
|
223
|
+
x: parseFloat(xCoord),
|
|
224
|
+
y: parseFloat(yCoord),
|
|
225
|
+
z: parseFloat(zCoord),
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
async handleEntityKilled(logLine) {
|
|
230
|
+
if (logLine.msg.includes('[CSMM_Patrons]') && !this.config.useCPM)
|
|
231
|
+
return;
|
|
232
|
+
if (logLine.msg.includes('killed by') && this.config.useCPM)
|
|
233
|
+
return;
|
|
234
|
+
const match = EventRegexMap[GameEvents.ENTITY_KILLED].exec(logLine.msg);
|
|
235
|
+
if (!match)
|
|
236
|
+
throw new Error('Could not parse entity killed message');
|
|
237
|
+
const { groups } = match;
|
|
238
|
+
if (!groups)
|
|
239
|
+
throw new Error('Could not parse entity killed message');
|
|
240
|
+
// Extracting the relevant details from the named groups
|
|
241
|
+
const { entityName, entityName2, weapon, steamOrXboxId } = groups;
|
|
242
|
+
const player = await this.sdtd.steamIdOrXboxToGameId(steamOrXboxId);
|
|
243
|
+
// Constructing the EventEntityKilled object with the parsed data
|
|
244
|
+
return new EventEntityKilled({
|
|
245
|
+
msg: logLine.msg,
|
|
246
|
+
entity: entityName || entityName2,
|
|
247
|
+
player,
|
|
248
|
+
weapon: weapon || undefined, // Assuming that 'weapon' might not be present in some log lines
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
async listener(data) {
|
|
252
|
+
this.lastMessageTimestamp = Date.now();
|
|
253
|
+
const parsed = JSON.parse(data.data);
|
|
254
|
+
const messageMatch = this.SSERegex.exec(parsed.msg);
|
|
255
|
+
if (messageMatch && messageMatch[1]) {
|
|
256
|
+
parsed.msg = messageMatch[1];
|
|
257
|
+
}
|
|
258
|
+
await this.parseMessage(parsed);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=emitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../../src/gameservers/7d2d/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,aAAa,CAAC;AAEtC,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,UAAU,EACV,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;AAOpB;;;GAGG;AACH,MAAM,mBAAmB,GAAG;IAC1B,wBAAwB;IACxB,wBAAwB;IACxB,oGAAoG;IACpG,mBAAmB;IACnB,qEAAqE;IACrE,iBAAiB;IACjB,0CAA0C;CAC3C,CAAC;AAEF,MAAM,aAAa,GAAG;IACpB,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAC3B,gPAAgP;IAClP,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,yBAAyB;IAC3D,CAAC,UAAU,CAAC,YAAY,CAAC,EACvB,8HAA8H;IAChI,CAAC,UAAU,CAAC,YAAY,CAAC,EACvB,iKAAiK;IACnK,CAAC,UAAU,CAAC,aAAa,CAAC,EACxB,0MAA0M;CAC7M,CAAC;AAEF,MAAM,OAAO,qB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MAAM,IAAI,SAAS,EAAE,gEAAgE;SAC9F,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAkB;QAC/B,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpD,IAAI,YAAY,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;YACpC,MAAM,CAAC,GAAG,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;QAED,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IGamePlayer, IPosition } from '@takaro/modules';
|
|
2
|
+
import { BanDTO, CommandOutput, IGameServer, IItemDTO, IMessageOptsDTO, IPlayerReferenceDTO, TestReachabilityOutputDTO } from '../../interfaces/GameServer.js';
|
|
3
|
+
import { SevenDaysToDieEmitter } from './emitter.js';
|
|
4
|
+
import { Settings } from '@takaro/apiclient';
|
|
5
|
+
import { SdtdConnectionInfo } from './connectionInfo.js';
|
|
6
|
+
export declare class SevenDaysToDie implements IGameServer {
|
|
7
|
+
private settings;
|
|
8
|
+
private logger;
|
|
9
|
+
private apiClient;
|
|
10
|
+
connectionInfo: SdtdConnectionInfo;
|
|
11
|
+
constructor(config: SdtdConnectionInfo, settings?: Partial<Settings>);
|
|
12
|
+
getEventEmitter(): SevenDaysToDieEmitter;
|
|
13
|
+
getPlayer(player: IPlayerReferenceDTO): Promise<IGamePlayer | null>;
|
|
14
|
+
getPlayers(): Promise<IGamePlayer[]>;
|
|
15
|
+
steamIdOrXboxToGameId(id: string): Promise<IGamePlayer | undefined>;
|
|
16
|
+
getPlayerLocation(player: IPlayerReferenceDTO): Promise<IPosition | null>;
|
|
17
|
+
giveItem(player: IPlayerReferenceDTO, item: string, amount: number): Promise<void>;
|
|
18
|
+
testReachability(): Promise<TestReachabilityOutputDTO>;
|
|
19
|
+
executeConsoleCommand(rawCommand: string): Promise<CommandOutput>;
|
|
20
|
+
sendMessage(message: string, opts?: IMessageOptsDTO): Promise<void>;
|
|
21
|
+
teleportPlayer(player: IGamePlayer, x: number, y: number, z: number): Promise<void>;
|
|
22
|
+
kickPlayer(player: IPlayerReferenceDTO, reason: string): Promise<void>;
|
|
23
|
+
banPlayer(options: BanDTO): Promise<void>;
|
|
24
|
+
unbanPlayer(player: IPlayerReferenceDTO): Promise<void>;
|
|
25
|
+
listBans(): Promise<BanDTO[]>;
|
|
26
|
+
listItems(): Promise<IItemDTO[]>;
|
|
27
|
+
getPlayerInventory(player: IPlayerReferenceDTO): Promise<IItemDTO[]>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { logger, traceableClass } from '@takaro/util';
|
|
11
|
+
import { IGamePlayer } from '@takaro/modules';
|
|
12
|
+
import { BanDTO, CommandOutput, IItemDTO, IPlayerReferenceDTO, TestReachabilityOutputDTO, } from '../../interfaces/GameServer.js';
|
|
13
|
+
import { SevenDaysToDieEmitter } from './emitter.js';
|
|
14
|
+
import { SdtdApiClient } from './sdtdAPIClient.js';
|
|
15
|
+
import { SdtdConnectionInfo } from './connectionInfo.js';
|
|
16
|
+
import { Worker } from 'worker_threads';
|
|
17
|
+
import path from 'path';
|
|
18
|
+
import * as url from 'url';
|
|
19
|
+
import { DateTime, Duration } from 'luxon';
|
|
20
|
+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
21
|
+
let SevenDaysToDie = class SevenDaysToDie {
|
|
22
|
+
constructor(config, settings = {}) {
|
|
23
|
+
this.settings = settings;
|
|
24
|
+
this.logger = logger('7D2D');
|
|
25
|
+
this.connectionInfo = config;
|
|
26
|
+
this.apiClient = new SdtdApiClient(this.connectionInfo);
|
|
27
|
+
}
|
|
28
|
+
getEventEmitter() {
|
|
29
|
+
const emitter = new SevenDaysToDieEmitter(this.connectionInfo);
|
|
30
|
+
return emitter;
|
|
31
|
+
}
|
|
32
|
+
async getPlayer(player) {
|
|
33
|
+
const players = await this.getPlayers();
|
|
34
|
+
return players.find((p) => p.gameId === player.gameId) || null;
|
|
35
|
+
}
|
|
36
|
+
async getPlayers() {
|
|
37
|
+
const onlinePlayersRes = await this.apiClient.getOnlinePlayers();
|
|
38
|
+
const players = await Promise.all(onlinePlayersRes.data.map((p) => {
|
|
39
|
+
const data = {
|
|
40
|
+
gameId: p.crossplatformid.replace('EOS_', ''),
|
|
41
|
+
ip: p.ip,
|
|
42
|
+
name: p.name,
|
|
43
|
+
epicOnlineServicesId: p.crossplatformid.replace('EOS_', ''),
|
|
44
|
+
platformId: p.steamid.replace('Steam_', ''),
|
|
45
|
+
ping: p.ping,
|
|
46
|
+
};
|
|
47
|
+
if (p.steamid.startsWith('XBL_')) {
|
|
48
|
+
data.xboxLiveId = p.steamid.replace('XBL_', '');
|
|
49
|
+
}
|
|
50
|
+
if (p.steamid.startsWith('Steam_')) {
|
|
51
|
+
data.steamId = p.steamid.replace('Steam_', '');
|
|
52
|
+
}
|
|
53
|
+
return new IGamePlayer(data);
|
|
54
|
+
}));
|
|
55
|
+
return players;
|
|
56
|
+
}
|
|
57
|
+
async steamIdOrXboxToGameId(id) {
|
|
58
|
+
if (id.startsWith('Steam_'))
|
|
59
|
+
id = id.replace('Steam_', '');
|
|
60
|
+
if (id.startsWith('XBL_'))
|
|
61
|
+
id = id.replace('XBL_', '');
|
|
62
|
+
const players = await this.getPlayers();
|
|
63
|
+
const player = players.find((p) => p.steamId === id || p.epicOnlineServicesId === id || p.xboxLiveId === id);
|
|
64
|
+
return player;
|
|
65
|
+
}
|
|
66
|
+
async getPlayerLocation(player) {
|
|
67
|
+
const locations = await this.apiClient.getPlayersLocation();
|
|
68
|
+
const playerLocation = locations.data.find((location) => location.crossplatformid === `EOS_${player.gameId}`);
|
|
69
|
+
if (!playerLocation) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
x: playerLocation.position.x,
|
|
74
|
+
y: playerLocation.position.y,
|
|
75
|
+
z: playerLocation.position.z,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
async giveItem(player, item, amount) {
|
|
79
|
+
if (this.connectionInfo.useCPM) {
|
|
80
|
+
const command = `giveplus EOS_${player.gameId} ${item} ${amount}`;
|
|
81
|
+
await this.executeConsoleCommand(command);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const command = `give EOS_${player.gameId} ${item} ${amount}`;
|
|
85
|
+
await this.executeConsoleCommand(command);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async testReachability() {
|
|
89
|
+
try {
|
|
90
|
+
const timeout = new Promise((_, reject) => setTimeout(() => reject(new Error('Request timed out')), 10000));
|
|
91
|
+
await Promise.race([this.apiClient.getStats(), timeout]);
|
|
92
|
+
await Promise.race([this.executeConsoleCommand('version'), timeout]);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
let reason = 'Unexpected error, this might be a bug';
|
|
96
|
+
this.logger.warn('Reachability test requests failed', error);
|
|
97
|
+
if (error instanceof Object && 'details' in error) {
|
|
98
|
+
reason =
|
|
99
|
+
'Did not receive a response, please check that the server is running, the IP/port is correct and that it is not firewalled';
|
|
100
|
+
if (error.details instanceof Object) {
|
|
101
|
+
if ('status' in error.details) {
|
|
102
|
+
if (error.details.status === 403 || error.details.status === 401) {
|
|
103
|
+
reason = 'Unauthorized, please check that the admin user and token are correct';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else if (error instanceof Object && 'message' in error && error.message === 'Request timed out') {
|
|
109
|
+
reason = 'Request timed out, the server did not respond in the allocated time';
|
|
110
|
+
}
|
|
111
|
+
return new TestReachabilityOutputDTO({
|
|
112
|
+
connectable: false,
|
|
113
|
+
reason,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return new TestReachabilityOutputDTO({
|
|
117
|
+
connectable: true,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async executeConsoleCommand(rawCommand) {
|
|
121
|
+
const encodedCommand = encodeURIComponent(rawCommand);
|
|
122
|
+
const result = await this.apiClient.executeConsoleCommand(encodedCommand);
|
|
123
|
+
return new CommandOutput({
|
|
124
|
+
rawResult: result.data.result,
|
|
125
|
+
success: true,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async sendMessage(message, opts) {
|
|
129
|
+
// eslint-disable-next-line quotes
|
|
130
|
+
const escapedMessage = message.replaceAll(/"/g, "'");
|
|
131
|
+
let command = `say "${escapedMessage}"`;
|
|
132
|
+
if (opts?.recipient?.gameId) {
|
|
133
|
+
command = `sayplayer "EOS_${opts.recipient.gameId}" "${escapedMessage}"`;
|
|
134
|
+
}
|
|
135
|
+
if (this.connectionInfo.useCPM) {
|
|
136
|
+
const sender = this.settings.serverChatName || 'Takaro';
|
|
137
|
+
command = `say2 "${sender}" "${escapedMessage}"`;
|
|
138
|
+
if (opts?.recipient?.gameId) {
|
|
139
|
+
command = `pm2 "${sender}" "EOS_${opts.recipient.gameId}" "${escapedMessage}"`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
await this.executeConsoleCommand(command);
|
|
143
|
+
}
|
|
144
|
+
async teleportPlayer(player, x, y, z) {
|
|
145
|
+
const command = `teleportplayer EOS_${player.gameId} ${x} ${y} ${z}`;
|
|
146
|
+
await this.executeConsoleCommand(command);
|
|
147
|
+
}
|
|
148
|
+
async kickPlayer(player, reason) {
|
|
149
|
+
const command = `kick "EOS_${player.gameId}" "${reason}"`;
|
|
150
|
+
await this.executeConsoleCommand(command);
|
|
151
|
+
}
|
|
152
|
+
async banPlayer(options) {
|
|
153
|
+
// If no expiresAt is provided, assume 'permanent'. 500 years is pretty long ;)
|
|
154
|
+
const expiresAt = options.expiresAt ?? '2521-01-01 00:00:00';
|
|
155
|
+
const expiresAtDate = DateTime.fromISO(expiresAt);
|
|
156
|
+
const now = DateTime.local();
|
|
157
|
+
let duration = Duration.fromMillis(expiresAtDate.diff(now).milliseconds);
|
|
158
|
+
let unit = 'minute';
|
|
159
|
+
duration = duration.shiftTo('minutes'); // Convert to minutes
|
|
160
|
+
if (duration.minutes >= 60) {
|
|
161
|
+
unit = 'hour';
|
|
162
|
+
duration = duration.shiftTo('hours'); // Convert to hours
|
|
163
|
+
}
|
|
164
|
+
if (duration.hours >= 24) {
|
|
165
|
+
unit = 'day';
|
|
166
|
+
duration = duration.shiftTo('days'); // Convert to days
|
|
167
|
+
}
|
|
168
|
+
if (duration.days >= 7) {
|
|
169
|
+
unit = 'week';
|
|
170
|
+
duration = duration.shiftTo('weeks'); // Convert to weeks
|
|
171
|
+
}
|
|
172
|
+
if (duration.weeks >= 4) {
|
|
173
|
+
unit = 'month';
|
|
174
|
+
duration = duration.shiftTo('months'); // Convert to months
|
|
175
|
+
}
|
|
176
|
+
if (duration.months >= 12) {
|
|
177
|
+
unit = 'year';
|
|
178
|
+
duration = duration.shiftTo('years'); // Convert to years
|
|
179
|
+
}
|
|
180
|
+
const command = `ban add EOS_${options.player.gameId} ${Math.round(duration.as(unit))} ${unit} "${options.reason}"`;
|
|
181
|
+
await this.executeConsoleCommand(command);
|
|
182
|
+
}
|
|
183
|
+
async unbanPlayer(player) {
|
|
184
|
+
const command = `ban remove EOS_${player.gameId}`;
|
|
185
|
+
await this.executeConsoleCommand(command);
|
|
186
|
+
}
|
|
187
|
+
async listBans() {
|
|
188
|
+
// Execute the console command and get the raw result.
|
|
189
|
+
const bansRes = await this.executeConsoleCommand('ban list');
|
|
190
|
+
// Check if the command was successful and if there is a raw result.
|
|
191
|
+
if (!bansRes.success || !bansRes.rawResult) {
|
|
192
|
+
throw new Error('Failed to retrieve ban list.');
|
|
193
|
+
}
|
|
194
|
+
// Extract and parse the bans from the raw result.
|
|
195
|
+
const banEntries = bansRes.rawResult.split('\n').slice(1); // Skip the header line
|
|
196
|
+
const bans = [];
|
|
197
|
+
for (const entry of banEntries) {
|
|
198
|
+
const match = entry.match(/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) - (\S+) \(([^)]*)\) - (.*)/);
|
|
199
|
+
// If the entry is valid, extract the details and push to the bans array.
|
|
200
|
+
if (match) {
|
|
201
|
+
const [, date, gameId, _displayName, reason] = match;
|
|
202
|
+
const expiresAt = date.replace(' ', 'T') + '.000Z'; // Keep the time in its original form
|
|
203
|
+
bans.push(new BanDTO({
|
|
204
|
+
player: new IPlayerReferenceDTO({
|
|
205
|
+
gameId,
|
|
206
|
+
}),
|
|
207
|
+
reason,
|
|
208
|
+
expiresAt,
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return bans;
|
|
213
|
+
}
|
|
214
|
+
async listItems() {
|
|
215
|
+
const itemsRes = await this.executeConsoleCommand('li *');
|
|
216
|
+
const itemLines = itemsRes.rawResult.split('\n').slice(0, -2);
|
|
217
|
+
return new Promise((resolve, reject) => {
|
|
218
|
+
const workerPath = path.join(__dirname, 'itemWorker.js');
|
|
219
|
+
const worker = new Worker(workerPath);
|
|
220
|
+
worker.postMessage(itemLines);
|
|
221
|
+
worker.on('message', (parsedItems) => {
|
|
222
|
+
if (parsedItems.error) {
|
|
223
|
+
reject(parsedItems.error);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
resolve(parsedItems);
|
|
227
|
+
}
|
|
228
|
+
worker.terminate();
|
|
229
|
+
});
|
|
230
|
+
worker.on('error', reject);
|
|
231
|
+
worker.on('exit', (code) => {
|
|
232
|
+
if (code !== 0) {
|
|
233
|
+
reject(new Error(`Worker stopped with exit code ${code}`));
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
async getPlayerInventory(player) {
|
|
239
|
+
const inventoryRes = await this.apiClient.getPlayerInventory(`EOS_${player.gameId}`);
|
|
240
|
+
const resp = [];
|
|
241
|
+
const mapSdtdItemToDto = async (item) => {
|
|
242
|
+
if (!item)
|
|
243
|
+
return null;
|
|
244
|
+
return new IItemDTO({ code: item.name, amount: item.count });
|
|
245
|
+
};
|
|
246
|
+
const dtos = await Promise.all([
|
|
247
|
+
...inventoryRes.data.bag.map(mapSdtdItemToDto),
|
|
248
|
+
...inventoryRes.data.belt.map(mapSdtdItemToDto),
|
|
249
|
+
]);
|
|
250
|
+
const filteredDTOs = dtos.filter((item) => item !== null);
|
|
251
|
+
resp.push(...filteredDTOs);
|
|
252
|
+
for (const slot in inventoryRes.data.equipment) {
|
|
253
|
+
if (Object.prototype.hasOwnProperty.call(inventoryRes.data.equipment, slot)) {
|
|
254
|
+
const element = inventoryRes.data.equipment[slot];
|
|
255
|
+
if (element)
|
|
256
|
+
resp.push(new IItemDTO({ code: element.name, amount: element.count }));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return resp;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
SevenDaysToDie = __decorate([
|
|
263
|
+
traceableClass('game:7d2d'),
|
|
264
|
+
__metadata("design:paramtypes", [SdtdConnectionInfo, Object])
|
|
265
|
+
], SevenDaysToDie);
|
|
266
|
+
export { SevenDaysToDie };
|
|
267
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/gameservers/7d2d/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,WAAW,EAAa,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,MAAM,EACN,aAAa,EAEb,QAAQ,EAER,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AAC/D,MAAM,SAAS,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAG5D,IAAM,cAAc,GAApB,MAAM,cAAc;IAKzB,YAAY,MAA0B,EAAU,WAA8B,EAAE;QAAhC,aAAQ,GAAR,QAAQ,CAAwB;QAJxE,WAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAK9B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,C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CACF,CAAA;AArSY,cAAc;IAD1B,cAAc,CAAC,WAAW,CAAC;qCAMN,kBAAkB;GAL3B,cAAc,CAqS1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { parentPort } from 'worker_threads';
|
|
2
|
+
const vanillaItems = (await import('./items-7d2d.json', { assert: { type: 'json' } })).default;
|
|
3
|
+
if (!parentPort) {
|
|
4
|
+
throw new Error('This file must be run as a worker thread');
|
|
5
|
+
}
|
|
6
|
+
parentPort.on('message', async (itemLines) => {
|
|
7
|
+
if (!parentPort) {
|
|
8
|
+
throw new Error('This file must be run as a worker thread');
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const parsedItems = [];
|
|
12
|
+
for (const line of itemLines) {
|
|
13
|
+
const trimmed = line.trim();
|
|
14
|
+
const dto = { code: trimmed };
|
|
15
|
+
if (trimmed in vanillaItems) {
|
|
16
|
+
dto.name = vanillaItems[trimmed].name;
|
|
17
|
+
dto.description = vanillaItems[trimmed].description;
|
|
18
|
+
}
|
|
19
|
+
if (!dto.name)
|
|
20
|
+
dto.name = dto.code;
|
|
21
|
+
parsedItems.push(dto);
|
|
22
|
+
}
|
|
23
|
+
parentPort.postMessage(parsedItems);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (!error)
|
|
27
|
+
throw new Error('Error parsing items');
|
|
28
|
+
parentPort.postMessage({ error });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=itemWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itemWorker.js","sourceRoot":"","sources":["../../../src/gameservers/7d2d/itemWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,YAAY,GAAG,CAAC,MAAM,MAAM,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI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