@takaro/modules 0.0.1 → 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/BuiltinModule.js +0 -4
- package/dist/BuiltinModule.js.map +1 -1
- package/dist/community-modules.json +21 -0
- package/dist/dto/gameEvents.d.ts +3 -2
- package/dist/dto/gameEvents.js +1 -0
- package/dist/dto/gameEvents.js.map +1 -1
- package/dist/dto/index.d.ts +6 -0
- package/dist/dto/takaroEvents.d.ts +46 -0
- package/dist/dto/takaroEvents.js +129 -1
- package/dist/dto/takaroEvents.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/modules/chatBridge/hooks/GameToDiscord.js +1 -1
- package/dist/modules/chatBridge/hooks/GameToDiscord.js.map +1 -1
- package/dist/modules/chatBridge/hooks/PlayerConnected.js +2 -2
- package/dist/modules/chatBridge/hooks/PlayerConnected.js.map +1 -1
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js +1 -1
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js.map +1 -1
- package/dist/modules/economyUtils/commands/transfer.js +1 -1
- package/dist/modules/economyUtils/commands/transfer.js.map +1 -1
- package/dist/modules/geoBlock/hooks/IPDetected.js +3 -5
- package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -1
- package/dist/modules/geoBlock/index.js +1 -1
- package/dist/modules/geoBlock/index.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/lottery/commands/nextDraw.js +1 -1
- package/dist/modules/lottery/commands/nextDraw.js.map +1 -1
- package/dist/modules/playerOnboarding/index.js.map +1 -1
- package/dist/modules/teleports/commands/deletetp.js +1 -1
- package/dist/modules/teleports/commands/deletetp.js.map +1 -1
- package/dist/modules/teleports/commands/setprivate.js +4 -6
- package/dist/modules/teleports/commands/setprivate.js.map +1 -1
- package/dist/modules/teleports/commands/setpublic.js +8 -15
- package/dist/modules/teleports/commands/setpublic.js.map +1 -1
- package/dist/modules/teleports/commands/settp.js +2 -2
- package/dist/modules/teleports/commands/settp.js.map +1 -1
- package/dist/modules/teleports/commands/teleport.js +3 -8
- package/dist/modules/teleports/commands/teleport.js.map +1 -1
- package/dist/modules/teleports/commands/teleportwaypoint.js +9 -1
- package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -1
- package/dist/modules/teleports/commands/tplist.js +13 -12
- package/dist/modules/teleports/commands/tplist.js.map +1 -1
- package/dist/modules/teleports/functions/utils.d.ts +2 -2
- package/dist/modules/teleports/functions/utils.js +21 -3
- package/dist/modules/teleports/functions/utils.js.map +1 -1
- package/dist/modules.json +99 -79
- package/package.json +4 -8
- package/scripts/buildBuiltinJson.ts +20 -0
- package/src/BuiltinModule.ts +1 -1
- package/src/__tests__/aliases.integration.test.ts +6 -7
- package/src/__tests__/bugRepros.integration.test.ts +72 -0
- package/src/__tests__/commandArgs.integration.test.ts +24 -25
- package/src/__tests__/economyUtils.integration.test.ts +66 -60
- package/src/__tests__/geoblock.integration.test.ts +22 -65
- package/src/__tests__/gimme.integration.test.ts +35 -36
- package/src/__tests__/help.integration.test.ts +47 -35
- package/src/__tests__/lottery.integration.test.ts +32 -28
- package/src/__tests__/modulePermission.integration.test.ts +24 -18
- package/src/__tests__/onboarding.integration.test.ts +13 -14
- package/src/__tests__/ping.integration.test.ts +5 -6
- package/src/__tests__/roleExpiry.integration.test.ts +9 -10
- package/src/__tests__/serverMessages.integration.test.ts +14 -12
- package/src/__tests__/systemConfigCost.integration.test.ts +14 -15
- package/src/__tests__/teleports/listtp.integration.test.ts +98 -22
- package/src/__tests__/teleports/publicteleports.integration.test.ts +55 -48
- package/src/__tests__/teleports/teleport.integration.test.ts +17 -16
- package/src/__tests__/teleports/tpManagement.integration.test.ts +26 -27
- package/src/__tests__/teleports/waypoints.integration.test.ts +113 -82
- package/src/community-modules/README.md +5 -0
- package/src/community-modules/modules/vote.json +19 -0
- package/src/dto/gameEvents.ts +2 -2
- package/src/dto/takaroEvents.ts +79 -0
- package/src/main.ts +2 -3
- package/src/modules/chatBridge/hooks/GameToDiscord.js +1 -1
- package/src/modules/chatBridge/hooks/PlayerConnected.js +2 -2
- package/src/modules/chatBridge/hooks/PlayerDisconnected.js +1 -1
- package/src/modules/chatBridge/index.ts +1 -1
- package/src/modules/economyUtils/commands/transfer.js +4 -4
- package/src/modules/economyUtils/index.ts +1 -1
- package/src/modules/geoBlock/hooks/IPDetected.js +3 -4
- package/src/modules/geoBlock/index.ts +2 -2
- package/src/modules/gimme/commands/gimme.js +2 -1
- package/src/modules/gimme/index.ts +1 -1
- package/src/modules/highPingKicker/index.ts +1 -1
- package/src/modules/lottery/commands/nextDraw.js +3 -1
- package/src/modules/lottery/index.ts +1 -1
- package/src/modules/playerOnboarding/index.ts +2 -1
- package/src/modules/serverMessages/index.ts +1 -1
- package/src/modules/teleports/commands/deletetp.js +1 -1
- package/src/modules/teleports/commands/setprivate.js +6 -6
- package/src/modules/teleports/commands/setpublic.js +18 -25
- package/src/modules/teleports/commands/settp.js +2 -2
- package/src/modules/teleports/commands/teleport.js +3 -10
- package/src/modules/teleports/commands/teleportwaypoint.js +12 -1
- package/src/modules/teleports/commands/tplist.js +16 -15
- package/src/modules/teleports/functions/utils.js +19 -3
- package/src/modules/teleports/index.ts +1 -1
- package/src/modules/utils/index.ts +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import { IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
3
2
|
import { EventPlayerConnected, GameEvents } from '../dto/gameEvents.js';
|
|
4
3
|
import { HookEvents } from '../main.js';
|
|
5
4
|
|
|
@@ -15,9 +14,9 @@ const _tests = [
|
|
|
15
14
|
test: async function () {
|
|
16
15
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
17
16
|
this.setupData.gameserver.id,
|
|
18
|
-
this.setupData.onboardingModule.id
|
|
17
|
+
this.setupData.onboardingModule.id,
|
|
19
18
|
);
|
|
20
|
-
const events = this.
|
|
19
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
21
20
|
await this.client.hook.hookControllerTrigger({
|
|
22
21
|
gameServerId: this.setupData.gameserver.id,
|
|
23
22
|
playerId: this.setupData.players[0].id,
|
|
@@ -31,7 +30,7 @@ const _tests = [
|
|
|
31
30
|
});
|
|
32
31
|
|
|
33
32
|
expect((await events).length).to.be.eq(1);
|
|
34
|
-
expect((await events)[0].data.msg).to.match(/Welcome .+ to the server!/);
|
|
33
|
+
expect((await events)[0].data.meta.msg).to.match(/Welcome .+ to the server!/);
|
|
35
34
|
},
|
|
36
35
|
}),
|
|
37
36
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -47,9 +46,9 @@ const _tests = [
|
|
|
47
46
|
userConfig: JSON.stringify({
|
|
48
47
|
starterKitItems: ['cigar'],
|
|
49
48
|
}),
|
|
50
|
-
}
|
|
49
|
+
},
|
|
51
50
|
);
|
|
52
|
-
const events = this.
|
|
51
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.COMMAND_EXECUTED);
|
|
53
52
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
54
53
|
msg: '/starterkit',
|
|
55
54
|
playerId: this.setupData.players[0].id,
|
|
@@ -72,9 +71,9 @@ const _tests = [
|
|
|
72
71
|
userConfig: JSON.stringify({
|
|
73
72
|
starterKitItems: ['cigar'],
|
|
74
73
|
}),
|
|
75
|
-
}
|
|
74
|
+
},
|
|
76
75
|
);
|
|
77
|
-
const firstEvents = this.
|
|
76
|
+
const firstEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.COMMAND_EXECUTED);
|
|
78
77
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
79
78
|
msg: '/starterkit',
|
|
80
79
|
playerId: this.setupData.players[0].id,
|
|
@@ -83,14 +82,14 @@ const _tests = [
|
|
|
83
82
|
const resultLogs = (await firstEvents)[0].data.meta.result.logs;
|
|
84
83
|
expect(resultLogs.some((log: any) => log.msg.match(/giveItem 200 OK/))).to.be.true;
|
|
85
84
|
|
|
86
|
-
const secondEvents = this.
|
|
85
|
+
const secondEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
87
86
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
88
87
|
msg: '/starterkit',
|
|
89
88
|
playerId: this.setupData.players[0].id,
|
|
90
89
|
});
|
|
91
90
|
|
|
92
91
|
expect((await secondEvents).length).to.be.eq(1);
|
|
93
|
-
expect((await secondEvents)[0].data.msg).to.match(/ou already used starterkit on this server/);
|
|
92
|
+
expect((await secondEvents)[0].data.meta.msg).to.match(/ou already used starterkit on this server/);
|
|
94
93
|
},
|
|
95
94
|
}),
|
|
96
95
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -101,16 +100,16 @@ const _tests = [
|
|
|
101
100
|
test: async function () {
|
|
102
101
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
103
102
|
this.setupData.gameserver.id,
|
|
104
|
-
this.setupData.onboardingModule.id
|
|
103
|
+
this.setupData.onboardingModule.id,
|
|
105
104
|
);
|
|
106
|
-
const events = this.
|
|
105
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
107
106
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
108
107
|
msg: '/starterkit',
|
|
109
108
|
playerId: this.setupData.players[0].id,
|
|
110
109
|
});
|
|
111
110
|
|
|
112
111
|
expect((await events).length).to.be.eq(1);
|
|
113
|
-
expect((await events)[0].data.msg).to.match(/No starter kit items configured/);
|
|
112
|
+
expect((await events)[0].data.meta.msg).to.match(/No starter kit items configured/);
|
|
114
113
|
},
|
|
115
114
|
}),
|
|
116
115
|
];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import {
|
|
3
|
-
import { GameEvents } from '../dto/index.js';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
2
|
+
import { HookEvents } from '../dto/index.js';
|
|
4
3
|
|
|
5
4
|
const group = 'Ping command';
|
|
6
5
|
|
|
@@ -13,10 +12,10 @@ const tests = [
|
|
|
13
12
|
test: async function () {
|
|
14
13
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
15
14
|
this.setupData.gameserver.id,
|
|
16
|
-
this.setupData.utilsModule.id
|
|
15
|
+
this.setupData.utilsModule.id,
|
|
17
16
|
);
|
|
18
17
|
|
|
19
|
-
const events = this.
|
|
18
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE);
|
|
20
19
|
|
|
21
20
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
22
21
|
msg: '/ping',
|
|
@@ -24,7 +23,7 @@ const tests = [
|
|
|
24
23
|
});
|
|
25
24
|
|
|
26
25
|
expect((await events).length).to.be.eq(1);
|
|
27
|
-
expect((await events)[0].data.msg).to.be.eq('Pong!');
|
|
26
|
+
expect((await events)[0].data.meta.msg).to.be.eq('Pong!');
|
|
28
27
|
},
|
|
29
28
|
}),
|
|
30
29
|
];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import { IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
3
2
|
import { GameEvents } from '../dto/index.js';
|
|
4
3
|
|
|
5
4
|
const group = 'Role expiry';
|
|
@@ -13,15 +12,15 @@ const tests = [
|
|
|
13
12
|
test: async function () {
|
|
14
13
|
// First, ensure all players have no roles
|
|
15
14
|
await Promise.all(
|
|
16
|
-
this.setupData.players.map((p) => this.client.player.playerControllerRemoveRole(p.id, this.setupData.role.id))
|
|
15
|
+
this.setupData.players.map((p) => this.client.player.playerControllerRemoveRole(p.id, this.setupData.role.id)),
|
|
17
16
|
);
|
|
18
17
|
|
|
19
18
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
20
19
|
this.setupData.gameserver.id,
|
|
21
|
-
this.setupData.teleportsModule.id
|
|
20
|
+
this.setupData.teleportsModule.id,
|
|
22
21
|
);
|
|
23
22
|
|
|
24
|
-
const eventsBeforeRole = this.
|
|
23
|
+
const eventsBeforeRole = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
25
24
|
|
|
26
25
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
27
26
|
msg: '/settp test',
|
|
@@ -29,7 +28,7 @@ const tests = [
|
|
|
29
28
|
});
|
|
30
29
|
|
|
31
30
|
expect((await eventsBeforeRole).length).to.be.eq(1);
|
|
32
|
-
expect((await eventsBeforeRole)[0].data.msg).to.match(/You do not have permission to use teleports/);
|
|
31
|
+
expect((await eventsBeforeRole)[0].data.meta.msg).to.match(/You do not have permission to use teleports/);
|
|
33
32
|
|
|
34
33
|
// Assign the role with expiry 10 minutes from now
|
|
35
34
|
await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, this.setupData.role.id, {
|
|
@@ -37,7 +36,7 @@ const tests = [
|
|
|
37
36
|
});
|
|
38
37
|
|
|
39
38
|
// Execute the command again. Now it should work, since the role is assigned
|
|
40
|
-
const eventsWithRole = this.
|
|
39
|
+
const eventsWithRole = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
41
40
|
|
|
42
41
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
43
42
|
msg: '/settp test2',
|
|
@@ -45,7 +44,7 @@ const tests = [
|
|
|
45
44
|
});
|
|
46
45
|
|
|
47
46
|
expect((await eventsWithRole).length).to.be.eq(1);
|
|
48
|
-
expect((await eventsWithRole)[0].data.msg).to.match(/Teleport test2 set/);
|
|
47
|
+
expect((await eventsWithRole)[0].data.meta.msg).to.match(/Teleport test2 set/);
|
|
49
48
|
|
|
50
49
|
// Remove the role and reassign with expiry 1 ms from now
|
|
51
50
|
await this.client.player.playerControllerRemoveRole(this.setupData.players[0].id, this.setupData.role.id);
|
|
@@ -54,7 +53,7 @@ const tests = [
|
|
|
54
53
|
});
|
|
55
54
|
|
|
56
55
|
// Execute the command again. Now it should not work, since the role is expired
|
|
57
|
-
const eventsAfterExpire = this.
|
|
56
|
+
const eventsAfterExpire = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
58
57
|
|
|
59
58
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
60
59
|
msg: '/settp test3',
|
|
@@ -62,7 +61,7 @@ const tests = [
|
|
|
62
61
|
});
|
|
63
62
|
|
|
64
63
|
expect((await eventsAfterExpire).length).to.be.eq(1);
|
|
65
|
-
expect((await eventsAfterExpire)[0].data.msg).to.match(/You do not have permission to use teleports/);
|
|
64
|
+
expect((await eventsAfterExpire)[0].data.meta.msg).to.match(/You do not have permission to use teleports/);
|
|
66
65
|
},
|
|
67
66
|
}),
|
|
68
67
|
];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import { IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
3
2
|
import { GameEvents } from '../dto/index.js';
|
|
4
3
|
import { sleep } from '@takaro/util';
|
|
5
4
|
|
|
@@ -14,10 +13,10 @@ const tests = [
|
|
|
14
13
|
test: async function () {
|
|
15
14
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
16
15
|
this.setupData.gameserver.id,
|
|
17
|
-
this.setupData.serverMessagesModule.id
|
|
16
|
+
this.setupData.serverMessagesModule.id,
|
|
18
17
|
);
|
|
19
18
|
|
|
20
|
-
const events = this.
|
|
19
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
21
20
|
|
|
22
21
|
await this.client.cronjob.cronJobControllerTrigger({
|
|
23
22
|
cronjobId: this.setupData.serverMessagesModule.cronJobs[0].id,
|
|
@@ -26,9 +25,9 @@ const tests = [
|
|
|
26
25
|
});
|
|
27
26
|
|
|
28
27
|
expect((await events).length).to.be.eq(1);
|
|
29
|
-
expect((await events)[0].data.msg).to.be.eq(
|
|
28
|
+
expect((await events)[0].data.meta.msg).to.be.eq(
|
|
30
29
|
// eslint-disable-next-line
|
|
31
|
-
"This is an automated message, don't forget to read the server rules!"
|
|
30
|
+
"This is an automated message, don't forget to read the server rules!",
|
|
32
31
|
);
|
|
33
32
|
},
|
|
34
33
|
}),
|
|
@@ -45,10 +44,10 @@ const tests = [
|
|
|
45
44
|
userConfig: JSON.stringify({
|
|
46
45
|
messages: ['This is a custom message'],
|
|
47
46
|
}),
|
|
48
|
-
}
|
|
47
|
+
},
|
|
49
48
|
);
|
|
50
49
|
|
|
51
|
-
const events = this.
|
|
50
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE);
|
|
52
51
|
|
|
53
52
|
await this.client.cronjob.cronJobControllerTrigger({
|
|
54
53
|
cronjobId: this.setupData.serverMessagesModule.cronJobs[0].id,
|
|
@@ -57,7 +56,7 @@ const tests = [
|
|
|
57
56
|
});
|
|
58
57
|
|
|
59
58
|
expect((await events).length).to.be.eq(1);
|
|
60
|
-
expect((await events)[0].data.msg).to.be.eq('This is a custom message');
|
|
59
|
+
expect((await events)[0].data.meta.msg).to.be.eq('This is a custom message');
|
|
61
60
|
},
|
|
62
61
|
}),
|
|
63
62
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -73,13 +72,16 @@ const tests = [
|
|
|
73
72
|
userConfig: JSON.stringify({
|
|
74
73
|
messages: ['Test message 1', 'Test message 2'],
|
|
75
74
|
}),
|
|
76
|
-
}
|
|
75
|
+
},
|
|
77
76
|
);
|
|
78
77
|
|
|
79
78
|
// We should see each of our test messages at least once
|
|
80
79
|
|
|
81
80
|
const numberOfEvents = 10;
|
|
82
|
-
const events = this.
|
|
81
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(
|
|
82
|
+
GameEvents.CHAT_MESSAGE,
|
|
83
|
+
numberOfEvents,
|
|
84
|
+
);
|
|
83
85
|
|
|
84
86
|
for (let i = 0; i < numberOfEvents; i++) {
|
|
85
87
|
await sleep(Math.floor(Math.random() * 10) + 1);
|
|
@@ -90,7 +92,7 @@ const tests = [
|
|
|
90
92
|
});
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
const messages = (await events).map((e) => e.data.msg);
|
|
95
|
+
const messages = (await events).map((e) => e.data.meta.msg);
|
|
94
96
|
expect(messages).to.include('Test message 1');
|
|
95
97
|
expect(messages).to.include('Test message 2');
|
|
96
98
|
},
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import { IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
3
2
|
import { GameEvents } from '../dto/index.js';
|
|
4
3
|
import { sleep } from '@takaro/util';
|
|
5
4
|
|
|
@@ -28,17 +27,17 @@ const customSetup = async function (this: IntegrationTest<IModuleTestsSetupData>
|
|
|
28
27
|
},
|
|
29
28
|
},
|
|
30
29
|
}),
|
|
31
|
-
}
|
|
30
|
+
},
|
|
32
31
|
);
|
|
33
32
|
|
|
34
|
-
const setEvents =
|
|
33
|
+
const setEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
35
34
|
await this.client.command.commandControllerTrigger(setupData.gameserver.id, {
|
|
36
35
|
msg: '/settp test',
|
|
37
36
|
playerId: setupData.players[0].id,
|
|
38
37
|
});
|
|
39
38
|
|
|
40
39
|
expect((await setEvents).length).to.be.eq(1);
|
|
41
|
-
expect((await setEvents)[0].data.msg).to.be.eq('Teleport test set.');
|
|
40
|
+
expect((await setEvents)[0].data.meta.msg).to.be.eq('Teleport test set.');
|
|
42
41
|
|
|
43
42
|
const giveCurrencies = setupData.players.map(async (player) => {
|
|
44
43
|
const playerOnGameServer = (
|
|
@@ -52,7 +51,7 @@ const customSetup = async function (this: IntegrationTest<IModuleTestsSetupData>
|
|
|
52
51
|
playerOnGameServer[0].playerId,
|
|
53
52
|
{
|
|
54
53
|
currency: 100,
|
|
55
|
-
}
|
|
54
|
+
},
|
|
56
55
|
);
|
|
57
56
|
});
|
|
58
57
|
await Promise.all(giveCurrencies);
|
|
@@ -67,7 +66,7 @@ const tests = [
|
|
|
67
66
|
setup: customSetup,
|
|
68
67
|
name: 'Deducts money when cost is configured',
|
|
69
68
|
test: async function () {
|
|
70
|
-
const events = this.
|
|
69
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents('command-executed', 1);
|
|
71
70
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
72
71
|
msg: '/tp test',
|
|
73
72
|
playerId: this.setupData.players[0].id,
|
|
@@ -92,7 +91,7 @@ const tests = [
|
|
|
92
91
|
test: async function () {
|
|
93
92
|
const amount = 10;
|
|
94
93
|
|
|
95
|
-
const setEvents = this.
|
|
94
|
+
const setEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents('command-executed', amount);
|
|
96
95
|
|
|
97
96
|
await Promise.all(
|
|
98
97
|
Array.from({ length: amount }).map(async (_, index) => {
|
|
@@ -101,12 +100,12 @@ const tests = [
|
|
|
101
100
|
msg: `/settp test${index}`,
|
|
102
101
|
playerId: this.setupData.players[0].id,
|
|
103
102
|
});
|
|
104
|
-
})
|
|
103
|
+
}),
|
|
105
104
|
);
|
|
106
105
|
|
|
107
106
|
expect((await setEvents).length).to.be.eq(amount);
|
|
108
107
|
|
|
109
|
-
const events = this.
|
|
108
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents('command-executed', amount);
|
|
110
109
|
await Promise.all(
|
|
111
110
|
Array.from({ length: amount }).map(async (_, index) => {
|
|
112
111
|
await sleep(1);
|
|
@@ -114,7 +113,7 @@ const tests = [
|
|
|
114
113
|
msg: `/tp test${index}`,
|
|
115
114
|
playerId: this.setupData.players[0].id,
|
|
116
115
|
});
|
|
117
|
-
})
|
|
116
|
+
}),
|
|
118
117
|
);
|
|
119
118
|
|
|
120
119
|
expect((await events).length).to.be.eq(amount);
|
|
@@ -137,7 +136,7 @@ const tests = [
|
|
|
137
136
|
setup: customSetup,
|
|
138
137
|
name: 'Does not deduct currency when command unsuccessful',
|
|
139
138
|
test: async function () {
|
|
140
|
-
const events = this.
|
|
139
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents('command-executed', 1);
|
|
141
140
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
142
141
|
msg: '/tp doesntexist',
|
|
143
142
|
playerId: this.setupData.players[0].id,
|
|
@@ -174,17 +173,17 @@ const tests = [
|
|
|
174
173
|
playerOnGameServer[0].playerId,
|
|
175
174
|
{
|
|
176
175
|
currency: 5,
|
|
177
|
-
}
|
|
176
|
+
},
|
|
178
177
|
);
|
|
179
178
|
|
|
180
|
-
const events = this.
|
|
179
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
181
180
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
182
181
|
msg: '/tp test',
|
|
183
182
|
playerId: this.setupData.players[1].id,
|
|
184
183
|
});
|
|
185
184
|
|
|
186
185
|
expect((await events).length).to.be.eq(1);
|
|
187
|
-
expect((await events)[0].data.msg).to.be.eq('You do not have enough currency to execute this command.');
|
|
186
|
+
expect((await events)[0].data.meta.msg).to.be.eq('You do not have enough currency to execute this command.');
|
|
188
187
|
},
|
|
189
188
|
}),
|
|
190
189
|
];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntegrationTest, expect } from '@takaro/test';
|
|
2
|
-
import { IModuleTestsSetupData, modulesTestSetup } from '@takaro/test';
|
|
1
|
+
import { IntegrationTest, expect, IModuleTestsSetupData, modulesTestSetup, EventsAwaiter } from '@takaro/test';
|
|
3
2
|
import { GameEvents } from '../../dto/index.js';
|
|
4
3
|
|
|
5
4
|
const group = 'Teleports suite';
|
|
@@ -13,10 +12,10 @@ const tests = [
|
|
|
13
12
|
test: async function () {
|
|
14
13
|
await this.client.gameserver.gameServerControllerInstallModule(
|
|
15
14
|
this.setupData.gameserver.id,
|
|
16
|
-
this.setupData.teleportsModule.id
|
|
15
|
+
this.setupData.teleportsModule.id,
|
|
17
16
|
);
|
|
18
17
|
|
|
19
|
-
const setEvents = this.
|
|
18
|
+
const setEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 3);
|
|
20
19
|
|
|
21
20
|
await Promise.all(
|
|
22
21
|
Array.from({ length: 3 }).map(async (_, i) => {
|
|
@@ -24,16 +23,16 @@ const tests = [
|
|
|
24
23
|
msg: `/settp test${i}`,
|
|
25
24
|
playerId: this.setupData.players[0].id,
|
|
26
25
|
});
|
|
27
|
-
})
|
|
26
|
+
}),
|
|
28
27
|
);
|
|
29
28
|
|
|
30
29
|
expect((await setEvents).length).to.be.eq(3);
|
|
31
30
|
|
|
32
31
|
for (const event of await setEvents) {
|
|
33
|
-
expect(event.data.msg).to.match(/Teleport test\d set\./);
|
|
32
|
+
expect(event.data.meta.msg).to.match(/Teleport test\d set\./);
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
const events = this.
|
|
35
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 4);
|
|
37
36
|
|
|
38
37
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
39
38
|
msg: '/tplist',
|
|
@@ -41,11 +40,10 @@ const tests = [
|
|
|
41
40
|
});
|
|
42
41
|
|
|
43
42
|
expect((await events).length).to.be.eq(4);
|
|
44
|
-
expect((await events)[0].data.msg).to.be.eq('You have 3 teleports available');
|
|
45
|
-
|
|
46
|
-
expect((await events)[
|
|
47
|
-
expect((await events)[
|
|
48
|
-
expect((await events)[3].data.msg).to.match(/ - test2: [-\d]+, [-\d]+, [-\d]+/);
|
|
43
|
+
expect((await events)[0].data.meta.msg).to.be.eq('You have 3 teleports available');
|
|
44
|
+
expect((await events)[1].data.meta.msg).to.match(/test0: \([-\d]+,[-\d]+,[-\d]+\)/);
|
|
45
|
+
expect((await events)[2].data.meta.msg).to.match(/test1: \([-\d]+,[-\d]+,[-\d]+\)/);
|
|
46
|
+
expect((await events)[3].data.meta.msg).to.match(/test2: \([-\d]+,[-\d]+,[-\d]+\)/);
|
|
49
47
|
},
|
|
50
48
|
}),
|
|
51
49
|
new IntegrationTest<IModuleTestsSetupData>({
|
|
@@ -61,10 +59,10 @@ const tests = [
|
|
|
61
59
|
userConfig: JSON.stringify({
|
|
62
60
|
allowPublicTeleports: true,
|
|
63
61
|
}),
|
|
64
|
-
}
|
|
62
|
+
},
|
|
65
63
|
);
|
|
66
64
|
|
|
67
|
-
const setTpEvent = this.
|
|
65
|
+
const setTpEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
68
66
|
|
|
69
67
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
70
68
|
msg: '/settp test',
|
|
@@ -72,9 +70,9 @@ const tests = [
|
|
|
72
70
|
});
|
|
73
71
|
|
|
74
72
|
expect((await setTpEvent).length).to.be.eq(1);
|
|
75
|
-
expect((await setTpEvent)[0].data.msg).to.be.eq('Teleport test set.');
|
|
73
|
+
expect((await setTpEvent)[0].data.meta.msg).to.be.eq('Teleport test set.');
|
|
76
74
|
|
|
77
|
-
const setPublicEvent = this.
|
|
75
|
+
const setPublicEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
78
76
|
|
|
79
77
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
80
78
|
msg: '/setpublic test',
|
|
@@ -82,9 +80,9 @@ const tests = [
|
|
|
82
80
|
});
|
|
83
81
|
|
|
84
82
|
expect((await setPublicEvent).length).to.be.eq(1);
|
|
85
|
-
expect((await setPublicEvent)[0].data.msg).to.be.eq('Teleport test is now public.');
|
|
83
|
+
expect((await setPublicEvent)[0].data.meta.msg).to.be.eq('Teleport test is now public.');
|
|
86
84
|
|
|
87
|
-
const setTpEvent2 = this.
|
|
85
|
+
const setTpEvent2 = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
88
86
|
|
|
89
87
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
90
88
|
msg: '/settp test2',
|
|
@@ -92,9 +90,87 @@ const tests = [
|
|
|
92
90
|
});
|
|
93
91
|
|
|
94
92
|
expect((await setTpEvent2).length).to.be.eq(1);
|
|
95
|
-
expect((await setTpEvent2)[0].data.msg).to.be.eq('Teleport test2 set.');
|
|
93
|
+
expect((await setTpEvent2)[0].data.meta.msg).to.be.eq('Teleport test2 set.');
|
|
94
|
+
|
|
95
|
+
const tpEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
96
|
+
|
|
97
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
98
|
+
msg: '/tplist',
|
|
99
|
+
playerId: this.setupData.players[1].id,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
expect((await tpEvent).length).to.be.eq(2);
|
|
103
|
+
expect((await tpEvent)[0].data.meta.msg).to.be.eq('You have 1 teleport available');
|
|
104
|
+
expect((await tpEvent)[1].data.meta.msg).to.match(/test: \([-\d]+,[-\d]+,[-\d]+\) \(public\)/);
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
new IntegrationTest<IModuleTestsSetupData>({
|
|
108
|
+
group,
|
|
109
|
+
snapshot: false,
|
|
110
|
+
setup: modulesTestSetup,
|
|
111
|
+
name: 'Teleports set by player A cannot be seen by player B with /tplist',
|
|
112
|
+
test: async function () {
|
|
113
|
+
await this.client.gameserver.gameServerControllerInstallModule(
|
|
114
|
+
this.setupData.gameserver.id,
|
|
115
|
+
this.setupData.teleportsModule.id,
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const setTpEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
119
|
+
|
|
120
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
121
|
+
msg: '/settp test',
|
|
122
|
+
playerId: this.setupData.players[0].id,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
expect((await setTpEvent).length).to.be.eq(1);
|
|
126
|
+
expect((await setTpEvent)[0].data.meta.msg).to.be.eq('Teleport test set.');
|
|
127
|
+
|
|
128
|
+
const tpEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
129
|
+
|
|
130
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
131
|
+
msg: '/tplist',
|
|
132
|
+
playerId: this.setupData.players[1].id,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
expect((await tpEvent).length).to.be.eq(1);
|
|
136
|
+
expect((await tpEvent)[0].data.meta.msg).to.be.eq(
|
|
137
|
+
'You have no teleports available, use /settp <name> to set one.',
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
new IntegrationTest<IModuleTestsSetupData>({
|
|
142
|
+
group,
|
|
143
|
+
snapshot: false,
|
|
144
|
+
setup: modulesTestSetup,
|
|
145
|
+
// eslint-disable-next-line quotes
|
|
146
|
+
name: "bug repro /tplist: Player A and B have teleports set but B cannot see A's teleports",
|
|
147
|
+
test: async function () {
|
|
148
|
+
await this.client.gameserver.gameServerControllerInstallModule(
|
|
149
|
+
this.setupData.gameserver.id,
|
|
150
|
+
this.setupData.teleportsModule.id,
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
const setTpEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
154
|
+
|
|
155
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
156
|
+
msg: '/settp test',
|
|
157
|
+
playerId: this.setupData.players[0].id,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
expect((await setTpEvent).length).to.be.eq(1);
|
|
161
|
+
expect((await setTpEvent)[0].data.meta.msg).to.be.eq('Teleport test set.');
|
|
162
|
+
|
|
163
|
+
const setTpEvent2 = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
164
|
+
|
|
165
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
166
|
+
msg: '/settp test2',
|
|
167
|
+
playerId: this.setupData.players[1].id,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
expect((await setTpEvent2).length).to.be.eq(1);
|
|
171
|
+
expect((await setTpEvent2)[0].data.meta.msg).to.be.eq('Teleport test2 set.');
|
|
96
172
|
|
|
97
|
-
const tpEvent = this.
|
|
173
|
+
const tpEvent = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 2);
|
|
98
174
|
|
|
99
175
|
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
100
176
|
msg: '/tplist',
|
|
@@ -102,8 +178,8 @@ const tests = [
|
|
|
102
178
|
});
|
|
103
179
|
|
|
104
180
|
expect((await tpEvent).length).to.be.eq(2);
|
|
105
|
-
expect((await tpEvent)[0].data.msg).to.be.eq('You have 1 teleport available');
|
|
106
|
-
expect((await tpEvent)[1].data.msg).to.match(/
|
|
181
|
+
expect((await tpEvent)[0].data.meta.msg).to.be.eq('You have 1 teleport available');
|
|
182
|
+
expect((await tpEvent)[1].data.meta.msg).to.match(/test2: \([-\d]+,[-\d]+,[-\d]+\)/);
|
|
107
183
|
},
|
|
108
184
|
}),
|
|
109
185
|
];
|