@takaro/modules 0.0.4 → 0.0.5
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/dist/modules/geoBlock/hooks/IPDetected.js +10 -10
- package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -1
- package/dist/modules/gimme/commands/gimme.js +1 -0
- package/dist/modules/gimme/commands/gimme.js.map +1 -1
- package/dist/modules.json +2 -2
- package/package.json +1 -1
- package/src/__tests__/aliases.integration.test.ts +5 -5
- package/src/__tests__/bugRepros.integration.test.ts +3 -3
- package/src/__tests__/commandArgs.integration.test.ts +23 -23
- package/src/__tests__/economyUtils.integration.test.ts +29 -22
- package/src/__tests__/geoblock.integration.test.ts +13 -55
- package/src/__tests__/gimme.integration.test.ts +33 -33
- package/src/__tests__/help.integration.test.ts +36 -23
- package/src/__tests__/lottery.integration.test.ts +27 -22
- package/src/__tests__/modulePermission.integration.test.ts +20 -13
- package/src/__tests__/onboarding.integration.test.ts +9 -9
- package/src/__tests__/ping.integration.test.ts +4 -4
- package/src/__tests__/roleExpiry.integration.test.ts +7 -7
- package/src/__tests__/serverMessages.integration.test.ts +10 -7
- package/src/__tests__/systemConfigCost.integration.test.ts +9 -9
- package/src/__tests__/teleports/listtp.integration.test.ts +30 -28
- package/src/__tests__/teleports/publicteleports.integration.test.ts +45 -37
- package/src/__tests__/teleports/teleport.integration.test.ts +14 -12
- package/src/__tests__/teleports/tpManagement.integration.test.ts +17 -17
- package/src/__tests__/teleports/waypoints.integration.test.ts +109 -77
- package/src/modules/geoBlock/hooks/IPDetected.js +9 -9
- package/src/modules/gimme/commands/gimme.js +2 -1
|
@@ -32,16 +32,16 @@ async function main() {
|
|
|
32
32
|
await handleAction();
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
if (mode === 'deny') {
|
|
36
|
+
if (countries.includes(country)) {
|
|
37
|
+
console.log('Blocked country detected, performing actions');
|
|
38
|
+
await handleAction();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.log('Allowed country detected, no action');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
await main();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IPDetected.js","sourceRoot":"","sources":["../../../../src/modules/geoBlock/hooks/IPDetected.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEhE,KAAK,UAAU,IAAI;IACjB,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC3C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;IACnC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;IAE9E,KAAK,UAAU,YAAY;QACzB,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,WAAW,GAAG,IAAI,CAAC,CAAC;YAC/D,MAAM,MAAM,CAAC,UAAU,CAAC,6BAA6B,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,EAAE;gBAC7E,MAAM,EAAE,OAAO;gBACf,SAAS;aACV,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,EAAE;gBAC9E,MAAM,EAAE,OAAO;aAChB,CAAC,CAAC;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oF;IACpF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACjF,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC;IAEzD,IAAI,WAAW,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC/B,MAAM,MAAM,CAAC,UAAU,CAAC,4BAA4B,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;YACtF,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;SACX,CAAC,CAAC;QACH,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,YAAY,GAAG,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;IAC3G,CAAC;AACH,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
|
package/dist/modules.json
CHANGED
|
@@ -272,7 +272,7 @@
|
|
|
272
272
|
{
|
|
273
273
|
"commands": [
|
|
274
274
|
{
|
|
275
|
-
"function": "import { takaro, data, TakaroUserError } from '@takaro/helpers';\nasync function main() {\n const items = data.module.userConfig.items;\n const commands = data.module.userConfig.commands;\n if (items.length + commands.length === 0) {\n throw new TakaroUserError('No items or commands configured, please ask your server administrator to configure this module.');\n }\n // pick a random item between 0 and the length of both the items and commands arrays\n const randomIndex = Math.floor(Math.random() * (items.length + commands.length));\n const randomOption = items.concat(commands)[randomIndex];\n if (randomIndex < items.length) {\n await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {\n name: randomOption,\n amount: 1,\n });\n await data.player.pm(`You received ${randomOption}!`);\n }\n else {\n await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: randomOption });\n }\n}\nawait main();\n//# sourceMappingURL=gimme.js.map",
|
|
275
|
+
"function": "import { takaro, data, TakaroUserError } from '@takaro/helpers';\nasync function main() {\n const items = data.module.userConfig.items;\n const commands = data.module.userConfig.commands;\n if (items.length + commands.length === 0) {\n throw new TakaroUserError('No items or commands configured, please ask your server administrator to configure this module.');\n }\n // pick a random item between 0 and the length of both the items and commands arrays\n const randomIndex = Math.floor(Math.random() * (items.length + commands.length));\n const randomOption = items.concat(commands)[randomIndex];\n if (randomIndex < items.length) {\n await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {\n name: randomOption,\n amount: 1,\n quality: 0,\n });\n await data.player.pm(`You received ${randomOption}!`);\n }\n else {\n await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: randomOption });\n }\n}\nawait main();\n//# sourceMappingURL=gimme.js.map",
|
|
276
276
|
"name": "gimme",
|
|
277
277
|
"trigger": "gimme",
|
|
278
278
|
"helpText": "Randomly selects item from a list of items and entities.",
|
|
@@ -477,7 +477,7 @@
|
|
|
477
477
|
{
|
|
478
478
|
"eventType": "player-new-ip-detected",
|
|
479
479
|
"name": "IPDetected",
|
|
480
|
-
"function": "import { takaro, data, checkPermission } from '@takaro/helpers';\nasync function main() {\n const { gameServerId, player, pog } = data;\n const { country } = data.eventData;\n const { ban, banDuration, countries, message, mode } = data.module.userConfig;\n async function handleAction() {\n if (ban) {\n const now = new Date();\n const expiresAt = new Date(now.getTime() + banDuration * 1000);\n await takaro.gameserver.gameServerControllerBanPlayer(gameServerId, player.id, {\n reason: message,\n expiresAt,\n });\n }\n else {\n await takaro.gameserver.gameServerControllerKickPlayer(gameServerId, player.id, {\n reason: message,\n });\n }\n }\n const isImmune = checkPermission(pog, 'GEOBLOCK_IMMUNITY');\n if (isImmune) {\n console.log('Player has immunity, no action');\n return;\n }\n if (mode === 'allow') {\n if (countries.includes(country)) {\n console.log('Allowed country detected, no action');\n return;\n }\n console.log('Blocked country detected, performing actions');\n await handleAction();\n return;\n }\n
|
|
480
|
+
"function": "import { takaro, data, checkPermission } from '@takaro/helpers';\nasync function main() {\n const { gameServerId, player, pog } = data;\n const { country } = data.eventData;\n const { ban, banDuration, countries, message, mode } = data.module.userConfig;\n async function handleAction() {\n if (ban) {\n const now = new Date();\n const expiresAt = new Date(now.getTime() + banDuration * 1000);\n await takaro.gameserver.gameServerControllerBanPlayer(gameServerId, player.id, {\n reason: message,\n expiresAt,\n });\n }\n else {\n await takaro.gameserver.gameServerControllerKickPlayer(gameServerId, player.id, {\n reason: message,\n });\n }\n }\n const isImmune = checkPermission(pog, 'GEOBLOCK_IMMUNITY');\n if (isImmune) {\n console.log('Player has immunity, no action');\n return;\n }\n if (mode === 'allow') {\n if (countries.includes(country)) {\n console.log('Allowed country detected, no action');\n return;\n }\n console.log('Blocked country detected, performing actions');\n await handleAction();\n return;\n }\n if (mode === 'deny') {\n if (countries.includes(country)) {\n console.log('Blocked country detected, performing actions');\n await handleAction();\n return;\n }\n else {\n console.log('Allowed country detected, no action');\n return;\n }\n }\n}\nawait main();\n//# sourceMappingURL=IPDetected.js.map"
|
|
481
481
|
}
|
|
482
482
|
],
|
|
483
483
|
"cronJobs": [],
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
2
2
|
import { GameEvents } from '../dto/index.js';
|
|
3
3
|
|
|
4
4
|
const group = 'Aliases';
|
|
@@ -25,23 +25,23 @@ const tests = [
|
|
|
25
25
|
},
|
|
26
26
|
);
|
|
27
27
|
|
|
28
|
-
const setEvents = this.
|
|
28
|
+
const setEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
29
29
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
30
30
|
msg: '/settp test',
|
|
31
31
|
playerId: this.setupData.players[0].id,
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
expect((await setEvents).length).to.be.eq(1);
|
|
35
|
-
expect((await setEvents)[0].data.msg).to.be.eq('Teleport test set.');
|
|
35
|
+
expect((await setEvents)[0].data.meta.msg).to.be.eq('Teleport test set.');
|
|
36
36
|
|
|
37
|
-
const events = this.
|
|
37
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
38
38
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
39
39
|
msg: '/tellyport test',
|
|
40
40
|
playerId: this.setupData.players[0].id,
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
expect((await events).length).to.be.eq(1);
|
|
44
|
-
expect((await events)[0].data.msg).to.be.eq('Teleported to test.');
|
|
44
|
+
expect((await events)[0].data.meta.msg).to.be.eq('Teleported to test.');
|
|
45
45
|
},
|
|
46
46
|
}),
|
|
47
47
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
2
2
|
import { GameEvents } from '../dto/index.js';
|
|
3
3
|
import { EventChatMessageChannelEnum } from '@takaro/apiclient';
|
|
4
4
|
|
|
@@ -46,7 +46,7 @@ const tests = [
|
|
|
46
46
|
|
|
47
47
|
await this.client.gameserver.gameServerControllerInstallModule(this.setupData.gameserver.id, mod.id);
|
|
48
48
|
|
|
49
|
-
const events = this.
|
|
49
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
50
50
|
|
|
51
51
|
await this.client.hook.hookControllerTrigger({
|
|
52
52
|
eventType: 'chat-message',
|
|
@@ -60,7 +60,7 @@ const tests = [
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
expect((await events).length).to.be.eq(2);
|
|
63
|
-
expect((await events).map((e) => e.data.msg)).to.include.members(['First hook', 'Second hook']);
|
|
63
|
+
expect((await events).map((e) => e.data.meta.msg)).to.include.members(['First hook', 'Second hook']);
|
|
64
64
|
},
|
|
65
65
|
}),
|
|
66
66
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
2
2
|
import { GameEvents } from '../dto/gameEvents.js';
|
|
3
3
|
import { CommandArgumentCreateDTO } from '@takaro/apiclient';
|
|
4
4
|
|
|
@@ -76,7 +76,7 @@ const tests = [
|
|
|
76
76
|
},
|
|
77
77
|
]),
|
|
78
78
|
test: async function () {
|
|
79
|
-
const events = this.
|
|
79
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
80
80
|
|
|
81
81
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
82
82
|
msg: '/test "test"',
|
|
@@ -84,7 +84,7 @@ const tests = [
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
expect((await events).length).to.be.eq(1);
|
|
87
|
-
expect((await events)[0].data.msg).to.be.eq(
|
|
87
|
+
expect((await events)[0].data.meta.msg).to.be.eq(
|
|
88
88
|
'The value for "test" should be a number. Please correct it and try again.',
|
|
89
89
|
);
|
|
90
90
|
},
|
|
@@ -99,7 +99,7 @@ const tests = [
|
|
|
99
99
|
{ name: 'number', type: 'number', position: 2, defaultValue: '42' },
|
|
100
100
|
]),
|
|
101
101
|
test: async function () {
|
|
102
|
-
const events = this.
|
|
102
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
103
103
|
|
|
104
104
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
105
105
|
msg: '/test "test"',
|
|
@@ -107,7 +107,7 @@ const tests = [
|
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
expect((await events).length).to.be.eq(1);
|
|
110
|
-
expect((await events)[0].data.msg).to.be.eq('{"name":"test","public":false,"number":42}');
|
|
110
|
+
expect((await events)[0].data.meta.msg).to.be.eq('{"name":"test","public":false,"number":42}');
|
|
111
111
|
},
|
|
112
112
|
}),
|
|
113
113
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -119,7 +119,7 @@ const tests = [
|
|
|
119
119
|
{ name: 'public', type: 'boolean', position: 1 },
|
|
120
120
|
]),
|
|
121
121
|
test: async function () {
|
|
122
|
-
const events = this.
|
|
122
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
123
123
|
|
|
124
124
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
125
125
|
msg: '/test "test test" true',
|
|
@@ -127,7 +127,7 @@ const tests = [
|
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
expect((await events).length).to.be.eq(1);
|
|
130
|
-
expect((await events)[0].data.msg).to.be.eq('{"name":"test test","public":true}');
|
|
130
|
+
expect((await events)[0].data.meta.msg).to.be.eq('{"name":"test test","public":true}');
|
|
131
131
|
},
|
|
132
132
|
}),
|
|
133
133
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -136,7 +136,7 @@ const tests = [
|
|
|
136
136
|
snapshot: false,
|
|
137
137
|
setup: playerArgSetup,
|
|
138
138
|
test: async function () {
|
|
139
|
-
const events = this.
|
|
139
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
140
140
|
|
|
141
141
|
const pogRes = await this.client.playerOnGameserver.playerOnGameServerControllerSearch({
|
|
142
142
|
filters: {
|
|
@@ -152,8 +152,8 @@ const tests = [
|
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
expect((await events).length).to.be.eq(2);
|
|
155
|
-
expect((await events)[0].data.msg).to.be.eq(pog.gameId);
|
|
156
|
-
expect((await events)[1].data.msg).to.be.eq(pog.positionX?.toString());
|
|
155
|
+
expect((await events)[0].data.meta.msg).to.be.eq(pog.gameId);
|
|
156
|
+
expect((await events)[1].data.meta.msg).to.be.eq(pog.positionX?.toString());
|
|
157
157
|
},
|
|
158
158
|
}),
|
|
159
159
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -162,7 +162,7 @@ const tests = [
|
|
|
162
162
|
snapshot: false,
|
|
163
163
|
setup: playerArgSetup,
|
|
164
164
|
test: async function () {
|
|
165
|
-
const events = this.
|
|
165
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
166
166
|
|
|
167
167
|
const pogRes = await this.client.playerOnGameserver.playerOnGameServerControllerSearch({
|
|
168
168
|
filters: {
|
|
@@ -178,8 +178,8 @@ const tests = [
|
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
expect((await events).length).to.be.eq(2);
|
|
181
|
-
expect((await events)[0].data.msg).to.be.eq(pog.gameId);
|
|
182
|
-
expect((await events)[1].data.msg).to.be.eq(pog.positionX?.toString());
|
|
181
|
+
expect((await events)[0].data.meta.msg).to.be.eq(pog.gameId);
|
|
182
|
+
expect((await events)[1].data.meta.msg).to.be.eq(pog.positionX?.toString());
|
|
183
183
|
},
|
|
184
184
|
}),
|
|
185
185
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -188,7 +188,7 @@ const tests = [
|
|
|
188
188
|
snapshot: false,
|
|
189
189
|
setup: playerArgSetup,
|
|
190
190
|
test: async function () {
|
|
191
|
-
const events = this.
|
|
191
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
192
192
|
|
|
193
193
|
const pogRes = await this.client.playerOnGameserver.playerOnGameServerControllerSearch({
|
|
194
194
|
filters: {
|
|
@@ -204,8 +204,8 @@ const tests = [
|
|
|
204
204
|
});
|
|
205
205
|
|
|
206
206
|
expect((await events).length).to.be.eq(2);
|
|
207
|
-
expect((await events)[0].data.msg).to.be.eq(pog.gameId);
|
|
208
|
-
expect((await events)[1].data.msg).to.be.eq(pog.positionX?.toString());
|
|
207
|
+
expect((await events)[0].data.meta.msg).to.be.eq(pog.gameId);
|
|
208
|
+
expect((await events)[1].data.meta.msg).to.be.eq(pog.positionX?.toString());
|
|
209
209
|
},
|
|
210
210
|
}),
|
|
211
211
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -214,7 +214,7 @@ const tests = [
|
|
|
214
214
|
snapshot: false,
|
|
215
215
|
setup: playerArgSetup,
|
|
216
216
|
test: async function () {
|
|
217
|
-
const events = this.
|
|
217
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
218
218
|
|
|
219
219
|
const pogRes = await this.client.playerOnGameserver.playerOnGameServerControllerSearch({
|
|
220
220
|
filters: {
|
|
@@ -230,8 +230,8 @@ const tests = [
|
|
|
230
230
|
});
|
|
231
231
|
|
|
232
232
|
expect((await events).length).to.be.eq(2);
|
|
233
|
-
expect((await events)[0].data.msg).to.be.eq(pog.gameId);
|
|
234
|
-
expect((await events)[1].data.msg).to.be.eq(pog.positionX?.toString());
|
|
233
|
+
expect((await events)[0].data.meta.msg).to.be.eq(pog.gameId);
|
|
234
|
+
expect((await events)[1].data.meta.msg).to.be.eq(pog.positionX?.toString());
|
|
235
235
|
},
|
|
236
236
|
}),
|
|
237
237
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -240,7 +240,7 @@ const tests = [
|
|
|
240
240
|
snapshot: false,
|
|
241
241
|
setup: playerArgSetup,
|
|
242
242
|
test: async function () {
|
|
243
|
-
const events = this.
|
|
243
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
244
244
|
|
|
245
245
|
// Find a letter contained in one of the players' names
|
|
246
246
|
const letterToSearch = ['e', 'a'].find((letter) => {
|
|
@@ -255,7 +255,7 @@ const tests = [
|
|
|
255
255
|
});
|
|
256
256
|
|
|
257
257
|
expect((await events).length).to.be.eq(1);
|
|
258
|
-
expect((await events)[0].data.msg).to.match(/Multiple players found/);
|
|
258
|
+
expect((await events)[0].data.meta.msg).to.match(/Multiple players found/);
|
|
259
259
|
},
|
|
260
260
|
}),
|
|
261
261
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -264,7 +264,7 @@ const tests = [
|
|
|
264
264
|
snapshot: false,
|
|
265
265
|
setup: playerArgSetup,
|
|
266
266
|
test: async function () {
|
|
267
|
-
const events = this.
|
|
267
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
268
268
|
|
|
269
269
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
270
270
|
msg: '/test itsimpossiblethatwewilleverfindaplayerwiththisnameright',
|
|
@@ -272,7 +272,7 @@ const tests = [
|
|
|
272
272
|
});
|
|
273
273
|
|
|
274
274
|
expect((await events).length).to.be.eq(1);
|
|
275
|
-
expect((await events)[0].data.msg).to.match(/No player found with the name or ID/);
|
|
275
|
+
expect((await events)[0].data.meta.msg).to.match(/No player found with the name or ID/);
|
|
276
276
|
},
|
|
277
277
|
}),
|
|
278
278
|
];
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
IntegrationTest,
|
|
3
|
+
expect,
|
|
4
|
+
IModuleTestsSetupData,
|
|
5
|
+
modulesTestSetup,
|
|
6
|
+
chatMessageSorter,
|
|
7
|
+
EventsAwaiter,
|
|
8
|
+
} from '@takaro/test';
|
|
2
9
|
import { GameEvents } from '../dto/index.js';
|
|
3
10
|
|
|
4
11
|
const group = 'Economy utils suite';
|
|
@@ -33,7 +40,7 @@ const tests = [
|
|
|
33
40
|
this.setupData.economyUtilsModule.id,
|
|
34
41
|
);
|
|
35
42
|
|
|
36
|
-
const events = this.
|
|
43
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
37
44
|
|
|
38
45
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
39
46
|
msg: '/balance',
|
|
@@ -61,8 +68,8 @@ const tests = [
|
|
|
61
68
|
});
|
|
62
69
|
|
|
63
70
|
expect((await events).length).to.be.eq(2);
|
|
64
|
-
expect((await events)[0].data.msg).to.be.eq('balance: 0 test coin');
|
|
65
|
-
expect((await events)[1].data.msg).to.be.eq('balance: 1000 test coin');
|
|
71
|
+
expect((await events)[0].data.meta.msg).to.be.eq('balance: 0 test coin');
|
|
72
|
+
expect((await events)[1].data.meta.msg).to.be.eq('balance: 1000 test coin');
|
|
66
73
|
},
|
|
67
74
|
}),
|
|
68
75
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -95,14 +102,14 @@ const tests = [
|
|
|
95
102
|
await Promise.all(giveCurrencies);
|
|
96
103
|
|
|
97
104
|
// title message (1) + balance of player messages (5)
|
|
98
|
-
const events = this.
|
|
105
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 6);
|
|
99
106
|
|
|
100
107
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
101
108
|
msg: '/topcurrency',
|
|
102
109
|
playerId: this.setupData.players[0].id,
|
|
103
110
|
});
|
|
104
111
|
|
|
105
|
-
const messages = (await events).map((e) => e.data.msg as string);
|
|
112
|
+
const messages = (await events).map((e) => e.data.meta.msg as string);
|
|
106
113
|
expect((await events).length).to.be.eq(6);
|
|
107
114
|
for (const message of messages) {
|
|
108
115
|
expect(message).to.match(
|
|
@@ -142,14 +149,14 @@ const tests = [
|
|
|
142
149
|
if (!receiverPog) throw new Error('Receiver playerOnGameServer does not exist');
|
|
143
150
|
expect(receiverPog.currency).to.be.eq(0);
|
|
144
151
|
|
|
145
|
-
const events = this.
|
|
152
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
146
153
|
|
|
147
154
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
148
155
|
msg: `/transfer ${receiver.name} ${transferAmount}`,
|
|
149
156
|
playerId: sender.id,
|
|
150
157
|
});
|
|
151
158
|
|
|
152
|
-
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.msg as string);
|
|
159
|
+
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
|
|
153
160
|
expect((await events).length).to.be.eq(2);
|
|
154
161
|
|
|
155
162
|
// check if balances are correct
|
|
@@ -184,14 +191,14 @@ const tests = [
|
|
|
184
191
|
const receiver = this.setupData.players[1];
|
|
185
192
|
const transferAmount = 500;
|
|
186
193
|
|
|
187
|
-
const events = this.
|
|
194
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
188
195
|
|
|
189
196
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
190
197
|
msg: `/transfer ${receiver.name} ${transferAmount}`,
|
|
191
198
|
playerId: sender.id,
|
|
192
199
|
});
|
|
193
200
|
|
|
194
|
-
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.msg as string);
|
|
201
|
+
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
|
|
195
202
|
expect((await events).length).to.be.eq(1);
|
|
196
203
|
expect(messages[0]).to.be.eq(
|
|
197
204
|
`Failed to transfer ${transferAmount} test coin to ${receiver.name}. Are you sure you have enough balance?`,
|
|
@@ -237,14 +244,14 @@ const tests = [
|
|
|
237
244
|
if (!receiverPog) throw new Error('Receiver playerOnGameServer does not exist');
|
|
238
245
|
expect(receiverPog.currency).to.be.eq(0);
|
|
239
246
|
|
|
240
|
-
let events = this.
|
|
247
|
+
let events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
241
248
|
|
|
242
249
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
243
250
|
msg: `/transfer ${receiver.name} ${transferAmount}`,
|
|
244
251
|
playerId: sender.id,
|
|
245
252
|
});
|
|
246
253
|
|
|
247
|
-
let messages = (await events).sort(chatMessageSorter).map((e) => e.data.msg as string);
|
|
254
|
+
let messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
|
|
248
255
|
|
|
249
256
|
// check if balances have not changed yet
|
|
250
257
|
expect(
|
|
@@ -271,13 +278,13 @@ const tests = [
|
|
|
271
278
|
// =================================================
|
|
272
279
|
// transfer confirmed
|
|
273
280
|
// =================================================
|
|
274
|
-
events = this.
|
|
281
|
+
events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
275
282
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
276
283
|
msg: `${prefix}confirmtransfer`,
|
|
277
284
|
playerId: sender.id,
|
|
278
285
|
});
|
|
279
286
|
|
|
280
|
-
messages = (await events).sort(chatMessageSorter).map((e) => e.data.msg as string);
|
|
287
|
+
messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
|
|
281
288
|
expect((await events).length).to.be.eq(2);
|
|
282
289
|
expect(
|
|
283
290
|
(
|
|
@@ -315,13 +322,13 @@ const tests = [
|
|
|
315
322
|
}),
|
|
316
323
|
},
|
|
317
324
|
);
|
|
318
|
-
const events = this.
|
|
325
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
319
326
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
320
327
|
msg: '/confirmtransfer',
|
|
321
328
|
playerId: this.setupData.players[0].id,
|
|
322
329
|
});
|
|
323
330
|
|
|
324
|
-
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.msg as string);
|
|
331
|
+
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
|
|
325
332
|
expect(messages[0]).to.be.eq('You have no pending transfer.');
|
|
326
333
|
},
|
|
327
334
|
}),
|
|
@@ -356,13 +363,13 @@ const tests = [
|
|
|
356
363
|
if (!receiverPog) throw new Error('Receiver playerOnGameServer does not exist');
|
|
357
364
|
expect(receiverPog.currency).to.be.eq(0);
|
|
358
365
|
|
|
359
|
-
const events = this.
|
|
366
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
360
367
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
361
368
|
msg: `/grantcurrency ${receiver.name} ${grantAmount}`,
|
|
362
369
|
playerId: granter.id,
|
|
363
370
|
});
|
|
364
371
|
|
|
365
|
-
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.msg as string);
|
|
372
|
+
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
|
|
366
373
|
expect(
|
|
367
374
|
(
|
|
368
375
|
await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
|
|
@@ -418,13 +425,13 @@ const tests = [
|
|
|
418
425
|
receiver.playerOnGameServers?.find((pog) => pog.gameServerId === this.setupData.gameserver.id)?.currency,
|
|
419
426
|
).to.be.eq(0);
|
|
420
427
|
|
|
421
|
-
const events = this.
|
|
428
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
422
429
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
423
430
|
msg: `/revokecurrency ${receiver.name} ${revokeAmount}`,
|
|
424
431
|
playerId: revoker.id,
|
|
425
432
|
});
|
|
426
433
|
|
|
427
|
-
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.msg as string);
|
|
434
|
+
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
|
|
428
435
|
expect(
|
|
429
436
|
(
|
|
430
437
|
await this.client.playerOnGameserver.playerOnGameServerControllerGetOne(
|
|
@@ -462,7 +469,7 @@ const tests = [
|
|
|
462
469
|
receiver.playerOnGameServers?.find((pog) => pog.gameServerId === this.setupData.gameserver.id)?.currency,
|
|
463
470
|
).to.be.eq(0);
|
|
464
471
|
|
|
465
|
-
const events = this.
|
|
472
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
466
473
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
467
474
|
msg: `/grantcurrency ${receiver.name} ${amount}`,
|
|
468
475
|
playerId: sender.id,
|
|
@@ -473,7 +480,7 @@ const tests = [
|
|
|
473
480
|
playerId: sender.id,
|
|
474
481
|
});
|
|
475
482
|
|
|
476
|
-
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.msg as string);
|
|
483
|
+
const messages = (await events).sort(chatMessageSorter).map((e) => e.data.meta.msg as string);
|
|
477
484
|
expect(messages[0]).to.be.eq('You do not have permission to use grant currency command.');
|
|
478
485
|
expect(messages[1]).to.be.eq('You do not have permission to use revoke currency command.');
|
|
479
486
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
2
2
|
import { HookEvents } from '../dto/index.js';
|
|
3
3
|
import { TakaroEventPlayerNewIpDetected } from '@takaro/modules';
|
|
4
4
|
import { faker } from '@faker-js/faker';
|
|
@@ -35,7 +35,7 @@ const tests = [
|
|
|
35
35
|
}),
|
|
36
36
|
},
|
|
37
37
|
);
|
|
38
|
-
const events = this.
|
|
38
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.PLAYER_DISCONNECTED);
|
|
39
39
|
await this.client.hook.hookControllerTrigger({
|
|
40
40
|
gameServerId: this.setupData.gameserver.id,
|
|
41
41
|
playerId: this.setupData.players[0].id,
|
|
@@ -50,8 +50,7 @@ const tests = [
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
expect((await events).length).to.be.eq(1);
|
|
53
|
-
expect((await events)[0].data.
|
|
54
|
-
expect((await events)[0].data.player.name).to.be.eq(this.setupData.players[0].name);
|
|
53
|
+
expect((await events)[0].data.playerId).to.be.eq(this.setupData.players[0].id);
|
|
55
54
|
},
|
|
56
55
|
}),
|
|
57
56
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -71,7 +70,7 @@ const tests = [
|
|
|
71
70
|
}),
|
|
72
71
|
},
|
|
73
72
|
);
|
|
74
|
-
const events = this.
|
|
73
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.HOOK_EXECUTED);
|
|
75
74
|
|
|
76
75
|
await this.client.hook.hookControllerTrigger({
|
|
77
76
|
gameServerId: this.setupData.gameserver.id,
|
|
@@ -110,7 +109,7 @@ const tests = [
|
|
|
110
109
|
}),
|
|
111
110
|
},
|
|
112
111
|
);
|
|
113
|
-
const events = this.
|
|
112
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.HOOK_EXECUTED);
|
|
114
113
|
|
|
115
114
|
await this.client.hook.hookControllerTrigger({
|
|
116
115
|
gameServerId: this.setupData.gameserver.id,
|
|
@@ -149,7 +148,7 @@ const tests = [
|
|
|
149
148
|
}),
|
|
150
149
|
},
|
|
151
150
|
);
|
|
152
|
-
const events = this.
|
|
151
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.PLAYER_DISCONNECTED);
|
|
153
152
|
|
|
154
153
|
await this.client.hook.hookControllerTrigger({
|
|
155
154
|
gameServerId: this.setupData.gameserver.id,
|
|
@@ -165,8 +164,7 @@ const tests = [
|
|
|
165
164
|
});
|
|
166
165
|
|
|
167
166
|
expect((await events).length).to.be.eq(1);
|
|
168
|
-
expect((await events)[0].data.
|
|
169
|
-
expect((await events)[0].data.player.name).to.be.eq(this.setupData.players[0].name);
|
|
167
|
+
expect((await events)[0].data.playerId).to.be.eq(this.setupData.players[0].id);
|
|
170
168
|
},
|
|
171
169
|
}),
|
|
172
170
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -186,7 +184,7 @@ const tests = [
|
|
|
186
184
|
}),
|
|
187
185
|
},
|
|
188
186
|
);
|
|
189
|
-
const events = this.
|
|
187
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.PLAYER_DISCONNECTED);
|
|
190
188
|
|
|
191
189
|
await this.client.hook.hookControllerTrigger({
|
|
192
190
|
gameServerId: this.setupData.gameserver.id,
|
|
@@ -202,46 +200,7 @@ const tests = [
|
|
|
202
200
|
});
|
|
203
201
|
|
|
204
202
|
expect((await events).length).to.be.eq(1);
|
|
205
|
-
expect((await events)[0].data.
|
|
206
|
-
expect((await events)[0].data.player.name).to.be.eq(this.setupData.players[0].name);
|
|
207
|
-
},
|
|
208
|
-
}),
|
|
209
|
-
new IntegrationTest<IModuleTestsSetupData>({
|
|
210
|
-
group,
|
|
211
|
-
snapshot: false,
|
|
212
|
-
setup: customSetup,
|
|
213
|
-
name: 'MESSAGE CONFIGURATION: Custom message displayed to player on kick/ban',
|
|
214
|
-
test: async function () {
|
|
215
|
-
await this.client.gameserver.gameServerControllerInstallModule(
|
|
216
|
-
this.setupData.gameserver.id,
|
|
217
|
-
this.setupData.geoBlockModule.id,
|
|
218
|
-
{
|
|
219
|
-
userConfig: JSON.stringify({
|
|
220
|
-
mode: 'allow',
|
|
221
|
-
countries: ['RU'],
|
|
222
|
-
ban: true,
|
|
223
|
-
message: 'Custom message',
|
|
224
|
-
}),
|
|
225
|
-
},
|
|
226
|
-
);
|
|
227
|
-
const events = this.setupData.eventAwaiter.waitForEvents(HookEvents.PLAYER_DISCONNECTED);
|
|
228
|
-
|
|
229
|
-
await this.client.hook.hookControllerTrigger({
|
|
230
|
-
gameServerId: this.setupData.gameserver.id,
|
|
231
|
-
playerId: this.setupData.players[0].id,
|
|
232
|
-
eventType: HookEvents.PLAYER_NEW_IP_DETECTED,
|
|
233
|
-
eventMeta: new TakaroEventPlayerNewIpDetected({
|
|
234
|
-
city: 'nowhere',
|
|
235
|
-
country: 'BE',
|
|
236
|
-
latitude: '0',
|
|
237
|
-
longitude: '0',
|
|
238
|
-
ip: faker.internet.ip(),
|
|
239
|
-
}),
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
expect((await events).length).to.be.eq(1);
|
|
243
|
-
expect((await events)[0].data.msg).to.match(/Banned Custom message/);
|
|
244
|
-
expect((await events)[0].data.player.name).to.be.eq(this.setupData.players[0].name);
|
|
203
|
+
expect((await events)[0].data.playerId).to.be.eq(this.setupData.players[0].id);
|
|
245
204
|
},
|
|
246
205
|
}),
|
|
247
206
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -262,7 +221,7 @@ const tests = [
|
|
|
262
221
|
}),
|
|
263
222
|
},
|
|
264
223
|
);
|
|
265
|
-
const events = this.
|
|
224
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.PLAYER_DISCONNECTED);
|
|
266
225
|
|
|
267
226
|
await this.client.hook.hookControllerTrigger({
|
|
268
227
|
gameServerId: this.setupData.gameserver.id,
|
|
@@ -278,8 +237,7 @@ const tests = [
|
|
|
278
237
|
});
|
|
279
238
|
|
|
280
239
|
expect((await events).length).to.be.eq(1);
|
|
281
|
-
expect((await events)[0].data.
|
|
282
|
-
expect((await events)[0].data.player.name).to.be.eq(this.setupData.players[0].name);
|
|
240
|
+
expect((await events)[0].data.playerId).to.be.eq(this.setupData.players[0].id);
|
|
283
241
|
},
|
|
284
242
|
}),
|
|
285
243
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -308,7 +266,7 @@ const tests = [
|
|
|
308
266
|
|
|
309
267
|
await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, roleRes.data.data.id);
|
|
310
268
|
|
|
311
|
-
const events = this.
|
|
269
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.HOOK_EXECUTED);
|
|
312
270
|
|
|
313
271
|
await this.client.hook.hookControllerTrigger({
|
|
314
272
|
gameServerId: this.setupData.gameserver.id,
|
|
@@ -348,7 +306,7 @@ const tests = [
|
|
|
348
306
|
}),
|
|
349
307
|
},
|
|
350
308
|
);
|
|
351
|
-
const events = this.
|
|
309
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.HOOK_EXECUTED);
|
|
352
310
|
|
|
353
311
|
await this.client.hook.hookControllerTrigger({
|
|
354
312
|
gameServerId: this.setupData.gameserver.id,
|