@takaro/modules 0.0.15 → 0.0.19
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.d.ts +13 -8
- package/dist/BuiltinModule.d.ts.map +1 -0
- package/dist/BuiltinModule.js +48 -31
- package/dist/BuiltinModule.js.map +1 -1
- package/dist/dto/base.d.ts +1 -0
- package/dist/dto/base.d.ts.map +1 -0
- package/dist/dto/discordEvents.d.ts +1 -0
- package/dist/dto/discordEvents.d.ts.map +1 -0
- package/dist/dto/gameEvents.d.ts +1 -0
- package/dist/dto/gameEvents.d.ts.map +1 -0
- package/dist/dto/index.d.ts +4 -0
- package/dist/dto/index.d.ts.map +1 -0
- package/dist/dto/takaroEvents.d.ts +16 -0
- package/dist/dto/takaroEvents.d.ts.map +1 -0
- package/dist/dto/takaroEvents.js +36 -0
- package/dist/dto/takaroEvents.js.map +1 -1
- package/dist/main.d.ts +4 -3
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts.map +1 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts.map +1 -0
- package/dist/modules/chatBridge/index.d.ts +3 -2
- package/dist/modules/chatBridge/index.d.ts.map +1 -0
- package/dist/modules/chatBridge/index.js +55 -47
- package/dist/modules/chatBridge/index.js.map +1 -1
- package/dist/modules/dailyRewards/commands/daily.d.ts +1 -0
- package/dist/modules/dailyRewards/commands/daily.d.ts.map +1 -0
- package/dist/modules/dailyRewards/commands/streak.d.ts +1 -0
- package/dist/modules/dailyRewards/commands/streak.d.ts.map +1 -0
- package/dist/modules/dailyRewards/commands/topstreak.d.ts +1 -0
- package/dist/modules/dailyRewards/commands/topstreak.d.ts.map +1 -0
- package/dist/modules/dailyRewards/functions/utils.d.ts +1 -0
- package/dist/modules/dailyRewards/functions/utils.d.ts.map +1 -0
- package/dist/modules/dailyRewards/hooks/dailyLoginCheck.d.ts +1 -0
- package/dist/modules/dailyRewards/hooks/dailyLoginCheck.d.ts.map +1 -0
- package/dist/modules/dailyRewards/index.d.ts +3 -2
- package/dist/modules/dailyRewards/index.d.ts.map +1 -0
- package/dist/modules/dailyRewards/index.js +114 -106
- package/dist/modules/dailyRewards/index.js.map +1 -1
- package/dist/modules/economyUtils/commands/balance.d.ts +1 -0
- package/dist/modules/economyUtils/commands/balance.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/claim.d.ts +1 -0
- package/dist/modules/economyUtils/commands/claim.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.d.ts +1 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/grantCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/grantCurrency.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/shop.d.ts +1 -0
- package/dist/modules/economyUtils/commands/shop.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/topCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/topCurrency.d.ts.map +1 -0
- package/dist/modules/economyUtils/commands/transfer.d.ts +1 -0
- package/dist/modules/economyUtils/commands/transfer.d.ts.map +1 -0
- package/dist/modules/economyUtils/cronJobs/zombieKillReward.d.ts +1 -0
- package/dist/modules/economyUtils/cronJobs/zombieKillReward.d.ts.map +1 -0
- package/dist/modules/economyUtils/index.d.ts +3 -2
- package/dist/modules/economyUtils/index.d.ts.map +1 -0
- package/dist/modules/economyUtils/index.js +178 -170
- package/dist/modules/economyUtils/index.js.map +1 -1
- package/dist/modules/geoBlock/hooks/IPDetected.d.ts +1 -0
- package/dist/modules/geoBlock/hooks/IPDetected.d.ts.map +1 -0
- package/dist/modules/geoBlock/index.d.ts +3 -2
- package/dist/modules/geoBlock/index.d.ts.map +1 -0
- package/dist/modules/geoBlock/index.js +71 -63
- package/dist/modules/geoBlock/index.js.map +1 -1
- package/dist/modules/gimme/commands/gimme.d.ts +1 -0
- package/dist/modules/gimme/commands/gimme.d.ts.map +1 -0
- package/dist/modules/gimme/index.d.ts +3 -2
- package/dist/modules/gimme/index.d.ts.map +1 -0
- package/dist/modules/gimme/index.js +59 -50
- package/dist/modules/gimme/index.js.map +1 -1
- package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts +1 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts.map +1 -0
- package/dist/modules/highPingKicker/index.d.ts +3 -2
- package/dist/modules/highPingKicker/index.d.ts.map +1 -0
- package/dist/modules/highPingKicker/index.js +36 -28
- package/dist/modules/highPingKicker/index.js.map +1 -1
- package/dist/modules/lottery/commands/buyTicket.d.ts +1 -0
- package/dist/modules/lottery/commands/buyTicket.d.ts.map +1 -0
- package/dist/modules/lottery/commands/nextDraw.d.ts +1 -0
- package/dist/modules/lottery/commands/nextDraw.d.ts.map +1 -0
- package/dist/modules/lottery/commands/viewTickets.d.ts +1 -0
- package/dist/modules/lottery/commands/viewTickets.d.ts.map +1 -0
- package/dist/modules/lottery/cronJobs/drawLottery.d.ts +1 -0
- package/dist/modules/lottery/cronJobs/drawLottery.d.ts.map +1 -0
- package/dist/modules/lottery/index.d.ts +3 -2
- package/dist/modules/lottery/index.d.ts.map +1 -0
- package/dist/modules/lottery/index.js +73 -65
- package/dist/modules/lottery/index.js.map +1 -1
- package/dist/modules/playerOnboarding/commands/starterkit.d.ts +1 -0
- package/dist/modules/playerOnboarding/commands/starterkit.d.ts.map +1 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts +1 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts.map +1 -0
- package/dist/modules/playerOnboarding/index.d.ts +3 -2
- package/dist/modules/playerOnboarding/index.d.ts.map +1 -0
- package/dist/modules/playerOnboarding/index.js +69 -60
- package/dist/modules/playerOnboarding/index.js.map +1 -1
- package/dist/modules/serverMessages/cronJobs/Automated message.d.ts +1 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.d.ts.map +1 -0
- package/dist/modules/serverMessages/index.d.ts +3 -2
- package/dist/modules/serverMessages/index.d.ts.map +1 -0
- package/dist/modules/serverMessages/index.js +36 -28
- package/dist/modules/serverMessages/index.js.map +1 -1
- package/dist/modules/teleports/commands/deletetp.d.ts +1 -0
- package/dist/modules/teleports/commands/deletetp.d.ts.map +1 -0
- package/dist/modules/teleports/commands/deletewaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/deletewaypoint.d.ts.map +1 -0
- package/dist/modules/teleports/commands/deletewaypoint.js +4 -35
- package/dist/modules/teleports/commands/deletewaypoint.js.map +1 -1
- package/dist/modules/teleports/commands/listwaypoints.d.ts +1 -0
- package/dist/modules/teleports/commands/listwaypoints.d.ts.map +1 -0
- package/dist/modules/teleports/commands/listwaypoints.js +3 -22
- package/dist/modules/teleports/commands/listwaypoints.js.map +1 -1
- package/dist/modules/teleports/commands/setprivate.d.ts +1 -0
- package/dist/modules/teleports/commands/setprivate.d.ts.map +1 -0
- package/dist/modules/teleports/commands/setpublic.d.ts +1 -0
- package/dist/modules/teleports/commands/setpublic.d.ts.map +1 -0
- package/dist/modules/teleports/commands/settp.d.ts +1 -0
- package/dist/modules/teleports/commands/settp.d.ts.map +1 -0
- package/dist/modules/teleports/commands/setwaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/setwaypoint.d.ts.map +1 -0
- package/dist/modules/teleports/commands/setwaypoint.js +5 -63
- package/dist/modules/teleports/commands/setwaypoint.js.map +1 -1
- package/dist/modules/teleports/commands/teleport.d.ts +1 -0
- package/dist/modules/teleports/commands/teleport.d.ts.map +1 -0
- package/dist/modules/teleports/commands/teleportwaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/teleportwaypoint.d.ts.map +1 -0
- package/dist/modules/teleports/commands/teleportwaypoint.js +7 -23
- package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -1
- package/dist/modules/teleports/commands/tplist.d.ts +1 -0
- package/dist/modules/teleports/commands/tplist.d.ts.map +1 -0
- package/dist/modules/teleports/cronJobs/Waypoint reconciler.d.ts +2 -0
- package/dist/modules/teleports/cronJobs/Waypoint reconciler.d.ts.map +1 -0
- package/dist/modules/teleports/cronJobs/Waypoint reconciler.js +6 -0
- package/dist/modules/teleports/cronJobs/Waypoint reconciler.js.map +1 -0
- package/dist/modules/teleports/functions/utils.d.ts +12 -0
- package/dist/modules/teleports/functions/utils.d.ts.map +1 -0
- package/dist/modules/teleports/functions/utils.js +117 -0
- package/dist/modules/teleports/functions/utils.js.map +1 -1
- package/dist/modules/teleports/index.d.ts +3 -2
- package/dist/modules/teleports/index.d.ts.map +1 -0
- package/dist/modules/teleports/index.js +188 -172
- package/dist/modules/teleports/index.js.map +1 -1
- package/dist/modules/timedShutdown/cronJobs/Shutdown.d.ts +1 -0
- package/dist/modules/timedShutdown/cronJobs/Shutdown.d.ts.map +1 -0
- package/dist/modules/timedShutdown/cronJobs/warning.d.ts +1 -0
- package/dist/modules/timedShutdown/cronJobs/warning.d.ts.map +1 -0
- package/dist/modules/timedShutdown/index.d.ts +3 -2
- package/dist/modules/timedShutdown/index.d.ts.map +1 -0
- package/dist/modules/timedShutdown/index.js +35 -27
- package/dist/modules/timedShutdown/index.js.map +1 -1
- package/dist/modules/utils/commands/help.d.ts +1 -0
- package/dist/modules/utils/commands/help.d.ts.map +1 -0
- package/dist/modules/utils/commands/help.js +10 -9
- package/dist/modules/utils/commands/help.js.map +1 -1
- package/dist/modules/utils/commands/ping.d.ts +1 -0
- package/dist/modules/utils/commands/ping.d.ts.map +1 -0
- package/dist/modules/utils/index.d.ts +3 -2
- package/dist/modules/utils/index.d.ts.map +1 -0
- package/dist/modules/utils/index.js +36 -28
- package/dist/modules/utils/index.js.map +1 -1
- package/dist/modules.json +600 -570
- package/package.json +3 -8
- package/scripts/buildBuiltinJson.ts +12 -8
- package/src/BuiltinModule.ts +25 -17
- package/src/__tests__/aliases.integration.test.ts +23 -26
- package/src/__tests__/bugRepros.integration.test.ts +261 -10
- package/src/__tests__/builtinmodule.unit.test.ts +3 -1
- package/src/__tests__/commandArgs.integration.test.ts +13 -6
- package/src/__tests__/economy/claim.integration.test.ts +1 -0
- package/src/__tests__/economy/economyUtils.integration.test.ts +43 -46
- package/src/__tests__/economy/shop.integration.test.ts +5 -4
- package/src/__tests__/economy/zombieKillReward.integration.test.ts +28 -31
- package/src/__tests__/geoblock.integration.test.ts +76 -91
- package/src/__tests__/gimme.integration.test.ts +22 -25
- package/src/__tests__/help.integration.test.ts +21 -20
- package/src/__tests__/lottery.integration.test.ts +15 -11
- package/src/__tests__/modulePermission.integration.test.ts +17 -13
- package/src/__tests__/onboarding.integration.test.ts +31 -34
- package/src/__tests__/ping.integration.test.ts +5 -4
- package/src/__tests__/roleExpiry.integration.test.ts +5 -4
- package/src/__tests__/serverMessages.integration.test.ts +24 -27
- package/src/__tests__/systemConfigCooldown.integration.test.ts +5 -1
- package/src/__tests__/systemConfigCost.integration.test.ts +16 -17
- package/src/__tests__/teleports/listtp.integration.test.ts +20 -21
- package/src/__tests__/teleports/publicteleports.integration.test.ts +58 -70
- package/src/__tests__/teleports/teleport.integration.test.ts +16 -17
- package/src/__tests__/teleports/tpManagement.integration.test.ts +21 -20
- package/src/__tests__/teleports/waypoints.integration.test.ts +52 -6
- package/src/dto/takaroEvents.ts +21 -0
- package/src/main.ts +12 -4
- package/src/modules/chatBridge/index.ts +54 -51
- package/src/modules/dailyRewards/index.ts +121 -111
- package/src/modules/economyUtils/index.ts +182 -179
- package/src/modules/geoBlock/index.ts +72 -70
- package/src/modules/gimme/index.ts +59 -55
- package/src/modules/highPingKicker/index.ts +35 -32
- package/src/modules/lottery/index.ts +73 -71
- package/src/modules/playerOnboarding/index.ts +71 -67
- package/src/modules/serverMessages/index.ts +36 -32
- package/src/modules/teleports/commands/deletewaypoint.js +4 -53
- package/src/modules/teleports/commands/listwaypoints.js +3 -35
- package/src/modules/teleports/commands/setwaypoint.js +5 -83
- package/src/modules/teleports/commands/teleportwaypoint.js +9 -36
- package/src/modules/teleports/cronJobs/Waypoint reconciler.js +7 -0
- package/src/modules/teleports/functions/utils.js +150 -0
- package/src/modules/teleports/index.ts +196 -180
- package/src/modules/timedShutdown/index.ts +35 -30
- package/src/modules/utils/commands/help.js +14 -14
- package/src/modules/utils/index.ts +36 -32
- package/tsconfig.json +1 -1
|
@@ -1,39 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleTransferDTO, ICronJob, ModuleTransferVersionDTO } from '../../BuiltinModule.js';
|
|
2
2
|
|
|
3
|
-
export class ServerMessages extends
|
|
3
|
+
export class ServerMessages extends ModuleTransferDTO<ServerMessages> {
|
|
4
4
|
constructor() {
|
|
5
|
-
super(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
super();
|
|
6
|
+
|
|
7
|
+
this.name = 'serverMessages';
|
|
8
|
+
this.versions = [
|
|
9
|
+
new ModuleTransferVersionDTO({
|
|
10
|
+
tag: '0.0.1',
|
|
11
|
+
description: 'Send automated, rotated, configurable messages to players on the server.',
|
|
12
|
+
configSchema: JSON.stringify({
|
|
13
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
messages: {
|
|
17
|
+
type: 'array',
|
|
18
|
+
title: 'Messages',
|
|
19
|
+
description: 'List of messages that will be sent to players on the server.',
|
|
20
|
+
default: [
|
|
21
|
+
// prettier-ignore
|
|
22
|
+
'This is an automated message, don\'t forget to read the server rules!',
|
|
23
|
+
],
|
|
24
|
+
items: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
minLength: 5,
|
|
27
|
+
maxLength: 1024,
|
|
28
|
+
},
|
|
29
|
+
minItems: 1,
|
|
24
30
|
},
|
|
25
|
-
minItems: 1,
|
|
26
31
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function: this.loadFn('cronJobs', 'Automated message'),
|
|
32
|
+
required: ['messages'],
|
|
33
|
+
}),
|
|
34
|
+
cronJobs: [
|
|
35
|
+
new ICronJob({
|
|
36
|
+
name: 'Automated message',
|
|
37
|
+
temporalValue: '*/30 * * * *',
|
|
38
|
+
function: this.loadFn('cronJobs', 'Automated message'),
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
37
41
|
}),
|
|
38
42
|
];
|
|
39
43
|
}
|
|
@@ -1,56 +1,18 @@
|
|
|
1
1
|
import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';
|
|
2
|
-
|
|
3
|
-
function getWaypointName(name) {
|
|
4
|
-
return `waypoint ${name}`;
|
|
5
|
-
}
|
|
2
|
+
import { getWaypointName, waypointReconciler } from './utils.js';
|
|
6
3
|
|
|
7
4
|
async function main() {
|
|
8
|
-
const { pog, gameServerId, arguments: args } = data;
|
|
5
|
+
const { pog, gameServerId, arguments: args, module: mod } = data;
|
|
9
6
|
|
|
10
7
|
if (!checkPermission(pog, 'TELEPORTS_MANAGE_WAYPOINTS')) {
|
|
11
8
|
throw new TakaroUserError('You do not have permission to manage waypoints.');
|
|
12
9
|
}
|
|
13
10
|
|
|
14
|
-
async function ensureWaypointsModule() {
|
|
15
|
-
let waypointsDefinition = (
|
|
16
|
-
await takaro.module.moduleControllerSearch({
|
|
17
|
-
filters: {
|
|
18
|
-
name: ['Waypoints'],
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
).data.data[0];
|
|
22
|
-
|
|
23
|
-
if (!waypointsDefinition) {
|
|
24
|
-
console.log('Waypoints module definition not found, creating it.');
|
|
25
|
-
waypointsDefinition = (
|
|
26
|
-
await takaro.module.moduleControllerCreate({
|
|
27
|
-
name: 'Waypoints',
|
|
28
|
-
description: 'Waypoints module for the teleport system.',
|
|
29
|
-
})
|
|
30
|
-
).data.data;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let waypointsInstallation = (
|
|
34
|
-
await takaro.gameserver.gameServerControllerGetInstalledModules(gameServerId)
|
|
35
|
-
).data.data.find((module) => module.name === 'Waypoints');
|
|
36
|
-
|
|
37
|
-
if (!waypointsInstallation) {
|
|
38
|
-
console.log('Waypoints module not found, installing it.');
|
|
39
|
-
waypointsInstallation = (
|
|
40
|
-
await takaro.gameserver.gameServerControllerInstallModule(gameServerId, waypointsDefinition.id)
|
|
41
|
-
).data.data;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return { waypointsInstallation, waypointsDefinition };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const { waypointsInstallation } = await ensureWaypointsModule();
|
|
48
|
-
|
|
49
11
|
const variable = await takaro.variable.variableControllerSearch({
|
|
50
12
|
filters: {
|
|
51
13
|
key: [getWaypointName(args.waypoint)],
|
|
52
14
|
gameServerId: [gameServerId],
|
|
53
|
-
moduleId: [
|
|
15
|
+
moduleId: [mod.moduleId],
|
|
54
16
|
},
|
|
55
17
|
});
|
|
56
18
|
|
|
@@ -59,18 +21,7 @@ async function main() {
|
|
|
59
21
|
}
|
|
60
22
|
|
|
61
23
|
await takaro.variable.variableControllerDelete(variable.data.data[0].id);
|
|
62
|
-
|
|
63
|
-
const teleportCommand = await takaro.command.commandControllerSearch({
|
|
64
|
-
filters: {
|
|
65
|
-
moduleId: [waypointsInstallation.moduleId],
|
|
66
|
-
name: [`waypoint ${args.waypoint} server ${gameServerId}`],
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
if (teleportCommand.data.data.length) {
|
|
71
|
-
await takaro.command.commandControllerRemove(teleportCommand.data.data[0].id);
|
|
72
|
-
}
|
|
73
|
-
|
|
24
|
+
await waypointReconciler();
|
|
74
25
|
await pog.pm(`Waypoint ${args.waypoint} deleted.`);
|
|
75
26
|
}
|
|
76
27
|
|
|
@@ -1,44 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { data, checkPermission } from '@takaro/helpers';
|
|
2
|
+
import { ensureWaypointsModule } from './utils.js';
|
|
2
3
|
|
|
3
4
|
async function main() {
|
|
4
5
|
const { pog, gameServerId } = data;
|
|
5
6
|
|
|
6
|
-
async function ensureWaypointsModule() {
|
|
7
|
-
let waypointsDefinition = (
|
|
8
|
-
await takaro.module.moduleControllerSearch({
|
|
9
|
-
filters: {
|
|
10
|
-
name: ['Waypoints'],
|
|
11
|
-
},
|
|
12
|
-
})
|
|
13
|
-
).data.data[0];
|
|
14
|
-
|
|
15
|
-
if (!waypointsDefinition) {
|
|
16
|
-
console.log('Waypoints module definition not found, creating it.');
|
|
17
|
-
waypointsDefinition = (
|
|
18
|
-
await takaro.module.moduleControllerCreate({
|
|
19
|
-
name: 'Waypoints',
|
|
20
|
-
description: 'Waypoints module for the teleport system.',
|
|
21
|
-
})
|
|
22
|
-
).data.data;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let waypointsInstallation = (
|
|
26
|
-
await takaro.gameserver.gameServerControllerGetInstalledModules(gameServerId)
|
|
27
|
-
).data.data.find((module) => module.name === 'Waypoints');
|
|
28
|
-
|
|
29
|
-
if (!waypointsInstallation) {
|
|
30
|
-
console.log('Waypoints module not found, installing it.');
|
|
31
|
-
waypointsInstallation = (
|
|
32
|
-
await takaro.gameserver.gameServerControllerInstallModule(gameServerId, waypointsDefinition.id)
|
|
33
|
-
).data.data;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return { waypointsInstallation, waypointsDefinition };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
7
|
const { waypointsDefinition } = await ensureWaypointsModule();
|
|
40
8
|
|
|
41
|
-
const allWaypoints = waypointsDefinition.commands;
|
|
9
|
+
const allWaypoints = waypointsDefinition.latestVersion.commands;
|
|
42
10
|
|
|
43
11
|
const waypointsWithPermission = allWaypoints
|
|
44
12
|
.filter((waypoint) => checkPermission(pog, `WAYPOINTS_USE_${waypoint.trigger.toUpperCase()}_${gameServerId}`))
|
|
@@ -1,54 +1,16 @@
|
|
|
1
1
|
import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';
|
|
2
|
-
|
|
3
|
-
function getWaypointName(name) {
|
|
4
|
-
return `waypoint ${name}`;
|
|
5
|
-
}
|
|
2
|
+
import { getWaypointName, waypointReconciler } from './utils.js';
|
|
6
3
|
|
|
7
4
|
async function main() {
|
|
8
|
-
const { pog, gameServerId,
|
|
5
|
+
const { pog, gameServerId, arguments: args, module: mod } = data;
|
|
9
6
|
|
|
10
7
|
if (!checkPermission(pog, 'TELEPORTS_MANAGE_WAYPOINTS')) {
|
|
11
8
|
throw new TakaroUserError('You do not have permission to manage waypoints.');
|
|
12
9
|
}
|
|
13
10
|
|
|
14
|
-
async function ensureWaypointsModule() {
|
|
15
|
-
let waypointsDefinition = (
|
|
16
|
-
await takaro.module.moduleControllerSearch({
|
|
17
|
-
filters: {
|
|
18
|
-
name: ['Waypoints'],
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
).data.data[0];
|
|
22
|
-
|
|
23
|
-
if (!waypointsDefinition) {
|
|
24
|
-
console.log('Waypoints module definition not found, creating it.');
|
|
25
|
-
waypointsDefinition = (
|
|
26
|
-
await takaro.module.moduleControllerCreate({
|
|
27
|
-
name: 'Waypoints',
|
|
28
|
-
description: 'Waypoints module for the teleport system.',
|
|
29
|
-
})
|
|
30
|
-
).data.data;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let waypointsInstallation = (
|
|
34
|
-
await takaro.gameserver.gameServerControllerGetInstalledModules(gameServerId)
|
|
35
|
-
).data.data.find((module) => module.name === 'Waypoints');
|
|
36
|
-
|
|
37
|
-
if (!waypointsInstallation) {
|
|
38
|
-
console.log('Waypoints module not found, installing it.');
|
|
39
|
-
waypointsInstallation = (
|
|
40
|
-
await takaro.gameserver.gameServerControllerInstallModule(gameServerId, waypointsDefinition.id)
|
|
41
|
-
).data.data;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return { waypointsInstallation, waypointsDefinition };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const { waypointsInstallation, waypointsDefinition } = await ensureWaypointsModule();
|
|
48
|
-
|
|
49
11
|
try {
|
|
50
12
|
await takaro.variable.variableControllerCreate({
|
|
51
|
-
moduleId:
|
|
13
|
+
moduleId: mod.moduleId,
|
|
52
14
|
gameServerId,
|
|
53
15
|
key: getWaypointName(args.waypoint),
|
|
54
16
|
value: JSON.stringify({
|
|
@@ -61,50 +23,10 @@ async function main() {
|
|
|
61
23
|
if (error.message === 'Request failed with status code 409') {
|
|
62
24
|
throw new TakaroUserError(`Waypoint ${args.waypoint} already exists.`);
|
|
63
25
|
}
|
|
26
|
+
throw error;
|
|
64
27
|
}
|
|
65
28
|
|
|
66
|
-
|
|
67
|
-
filters: {
|
|
68
|
-
moduleId: [mod.moduleId],
|
|
69
|
-
name: ['teleportwaypoint'],
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
await takaro.command.commandControllerCreate({
|
|
74
|
-
moduleId: waypointsInstallation.moduleId,
|
|
75
|
-
name: `waypoint ${args.waypoint} server ${gameServerId}`,
|
|
76
|
-
trigger: args.waypoint,
|
|
77
|
-
helpText: `Teleport to waypoint ${args.waypoint}.`,
|
|
78
|
-
function: teleportCommand.data.data[0].function.code,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const existingPermissions = waypointsDefinition.permissions || [];
|
|
82
|
-
const permissionInputDTOs = existingPermissions.map((permission) => ({
|
|
83
|
-
permission: permission.permission,
|
|
84
|
-
description: permission.description,
|
|
85
|
-
friendlyName: permission.friendlyName,
|
|
86
|
-
canHaveCount: permission.canHaveCount,
|
|
87
|
-
}));
|
|
88
|
-
|
|
89
|
-
const gameServer = (await takaro.gameserver.gameServerControllerGetOne(gameServerId)).data.data;
|
|
90
|
-
|
|
91
|
-
await takaro.module.moduleControllerUpdate(waypointsInstallation.moduleId, {
|
|
92
|
-
permissions: [
|
|
93
|
-
{
|
|
94
|
-
permission: `WAYPOINTS_USE_${args.waypoint.toUpperCase()}_${gameServerId}`,
|
|
95
|
-
description: `Use the waypoint ${args.waypoint} on ${gameServer.name}.`,
|
|
96
|
-
friendlyName: `Use waypoint ${args.waypoint} on ${gameServer.name}`,
|
|
97
|
-
canHaveCount: false,
|
|
98
|
-
},
|
|
99
|
-
...permissionInputDTOs,
|
|
100
|
-
],
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// Need to reinstall the module to ensure the new commands systemconfig and permissions are properly in place
|
|
104
|
-
await takaro.gameserver.gameServerControllerInstallModule(gameServerId, waypointsInstallation.moduleId, {
|
|
105
|
-
systemConfig: JSON.stringify(waypointsInstallation.systemConfig),
|
|
106
|
-
userConfig: JSON.stringify(waypointsInstallation.userConfig),
|
|
107
|
-
});
|
|
29
|
+
await waypointReconciler();
|
|
108
30
|
|
|
109
31
|
await pog.pm(`Waypoint ${args.waypoint} set.`);
|
|
110
32
|
}
|
|
@@ -7,7 +7,7 @@ function getWaypointName(name) {
|
|
|
7
7
|
async function main() {
|
|
8
8
|
const { pog, gameServerId, trigger, module, itemId } = data;
|
|
9
9
|
|
|
10
|
-
const triggeredCommand = module.
|
|
10
|
+
const triggeredCommand = module.version.commands.find((command) => command.id === itemId);
|
|
11
11
|
|
|
12
12
|
if (!triggeredCommand) {
|
|
13
13
|
throw new Error('Waypoint not found.');
|
|
@@ -22,46 +22,19 @@ async function main() {
|
|
|
22
22
|
throw new TakaroUserError(`You are not allowed to use the waypoint ${trigger}.`);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
).data.data[0];
|
|
33
|
-
|
|
34
|
-
if (!waypointsDefinition) {
|
|
35
|
-
console.log('Waypoints module definition not found, creating it.');
|
|
36
|
-
waypointsDefinition = (
|
|
37
|
-
await takaro.module.moduleControllerCreate({
|
|
38
|
-
name: 'Waypoints',
|
|
39
|
-
description: 'Waypoints module for the teleport system.',
|
|
40
|
-
})
|
|
41
|
-
).data.data;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let waypointsInstallation = (
|
|
45
|
-
await takaro.gameserver.gameServerControllerGetInstalledModules(gameServerId)
|
|
46
|
-
).data.data.find((module) => module.name === 'Waypoints');
|
|
47
|
-
|
|
48
|
-
if (!waypointsInstallation) {
|
|
49
|
-
console.log('Waypoints module not found, installing it.');
|
|
50
|
-
waypointsInstallation = (
|
|
51
|
-
await takaro.gameserver.gameServerControllerInstallModule(gameServerId, waypointsDefinition.id)
|
|
52
|
-
).data.data;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return { waypointsInstallation, waypointsDefinition };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const { waypointsInstallation } = await ensureWaypointsModule();
|
|
25
|
+
const teleportsModule = (
|
|
26
|
+
await takaro.module.moduleControllerSearch({
|
|
27
|
+
filters: {
|
|
28
|
+
builtin: ['teleports'],
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
).data.data[0];
|
|
59
32
|
|
|
60
33
|
const variable = await takaro.variable.variableControllerSearch({
|
|
61
34
|
filters: {
|
|
62
35
|
key: [getWaypointName(trigger)],
|
|
63
36
|
gameServerId: [gameServerId],
|
|
64
|
-
moduleId: [
|
|
37
|
+
moduleId: [teleportsModule.id],
|
|
65
38
|
},
|
|
66
39
|
});
|
|
67
40
|
|
|
@@ -34,3 +34,153 @@ export async function findTp(tpName, playerId, pub = false) {
|
|
|
34
34
|
sortDirection: 'asc',
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
export async function ensureWaypointsModule() {
|
|
39
|
+
const { gameServerId } = data;
|
|
40
|
+
let waypointsDefinition = (
|
|
41
|
+
await takaro.module.moduleControllerSearch({
|
|
42
|
+
filters: {
|
|
43
|
+
name: ['Waypoints'],
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
).data.data[0];
|
|
47
|
+
|
|
48
|
+
if (!waypointsDefinition) {
|
|
49
|
+
console.log('Waypoints module definition not found, creating it.');
|
|
50
|
+
waypointsDefinition = (
|
|
51
|
+
await takaro.module.moduleControllerCreate({
|
|
52
|
+
name: 'Waypoints',
|
|
53
|
+
})
|
|
54
|
+
).data.data;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let waypointsInstallation = (
|
|
58
|
+
await takaro.module.moduleInstallationsControllerGetInstalledModules({
|
|
59
|
+
filters: { gameserverId: [gameServerId] },
|
|
60
|
+
})
|
|
61
|
+
).data.data.find((module) => module.module.name === 'Waypoints');
|
|
62
|
+
|
|
63
|
+
if (!waypointsInstallation) {
|
|
64
|
+
console.log('Waypoints installation not found, installing it.');
|
|
65
|
+
waypointsInstallation = (
|
|
66
|
+
await takaro.module.moduleInstallationsControllerInstallModule({
|
|
67
|
+
gameServerId,
|
|
68
|
+
versionId: waypointsDefinition.latestVersion.id,
|
|
69
|
+
})
|
|
70
|
+
).data.data;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return { waypointsInstallation, waypointsDefinition };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function getWaypointName(name) {
|
|
77
|
+
return `waypoint ${name}`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function getWaypointId(varName) {
|
|
81
|
+
const split = varName.split(' ')[1];
|
|
82
|
+
if (split) return split;
|
|
83
|
+
return varName;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* This function is responsible to read all the configured waypoints (vars)
|
|
88
|
+
* and then ensuring that the waypoints module has the correct config
|
|
89
|
+
*/
|
|
90
|
+
export async function waypointReconciler() {
|
|
91
|
+
console.log('Reconciling waypoints');
|
|
92
|
+
const { waypointsInstallation, waypointsDefinition } = await ensureWaypointsModule();
|
|
93
|
+
const { gameServerId, module: mod } = data;
|
|
94
|
+
|
|
95
|
+
// Get all the installed waypoints
|
|
96
|
+
const waypointVars = (
|
|
97
|
+
await takaro.variable.variableControllerSearch({
|
|
98
|
+
filters: {
|
|
99
|
+
moduleId: [mod.moduleId],
|
|
100
|
+
gameServerId: [gameServerId],
|
|
101
|
+
},
|
|
102
|
+
})
|
|
103
|
+
).data.data;
|
|
104
|
+
|
|
105
|
+
const waypointsInModule = waypointsDefinition.latestVersion.commands;
|
|
106
|
+
|
|
107
|
+
// Check if any waypoints are missing in module
|
|
108
|
+
const missingWaypoints = waypointVars.filter((waypointVar) => {
|
|
109
|
+
const existingWaypointsForServer = waypointsInModule.filter((waypoint) => waypoint.name.includes(gameServerId));
|
|
110
|
+
return !existingWaypointsForServer.some((waypoint) => waypoint.trigger === getWaypointId(waypointVar.key));
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// Check if there are waypoints too many in module compared to our vars
|
|
114
|
+
const toDeleteWaypoints = waypointsInModule.filter((waypoint) => {
|
|
115
|
+
// We ignore any commands that are not for this game server
|
|
116
|
+
if (!waypoint.name.includes(gameServerId)) return false;
|
|
117
|
+
return !waypointVars.some((waypointVar) => getWaypointId(waypointVar.key) === waypoint.trigger);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
if (!missingWaypoints.length && !toDeleteWaypoints.length) {
|
|
121
|
+
// No changes in waypoints, exit
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
console.log(
|
|
126
|
+
'Missing waypoints:',
|
|
127
|
+
missingWaypoints.map((waypoint) => waypoint.key),
|
|
128
|
+
);
|
|
129
|
+
console.log(
|
|
130
|
+
'To delete waypoints:',
|
|
131
|
+
toDeleteWaypoints.map((waypoint) => waypoint.trigger),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
// Fetch the teleporting code template
|
|
135
|
+
const teleportCommand = await takaro.command.commandControllerSearch({
|
|
136
|
+
filters: {
|
|
137
|
+
moduleId: [mod.moduleId],
|
|
138
|
+
name: ['teleportwaypoint'],
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Edit the module accordingly
|
|
143
|
+
await Promise.all([
|
|
144
|
+
...missingWaypoints.map((waypoint) => {
|
|
145
|
+
return takaro.command.commandControllerCreate({
|
|
146
|
+
name: `waypoint ${getWaypointId(waypoint.key)} server ${gameServerId}`,
|
|
147
|
+
trigger: getWaypointId(waypoint.key),
|
|
148
|
+
helpText: `Teleport to waypoint ${getWaypointId(waypoint.key)}.`,
|
|
149
|
+
function: teleportCommand.data.data[0].function.code,
|
|
150
|
+
versionId: waypointsInstallation.versionId,
|
|
151
|
+
});
|
|
152
|
+
}),
|
|
153
|
+
...toDeleteWaypoints.map((waypointVar) => {
|
|
154
|
+
return takaro.command.commandControllerRemove(waypointVar.id);
|
|
155
|
+
}),
|
|
156
|
+
]);
|
|
157
|
+
|
|
158
|
+
// Update permissions
|
|
159
|
+
const existingPermissions = waypointsDefinition.latestVersion.permissions || [];
|
|
160
|
+
const permissionInputDTOs = existingPermissions.map((permission) => ({
|
|
161
|
+
permission: permission.permission,
|
|
162
|
+
description: permission.description,
|
|
163
|
+
friendlyName: permission.friendlyName,
|
|
164
|
+
canHaveCount: permission.canHaveCount,
|
|
165
|
+
}));
|
|
166
|
+
// We need to filter out the permissions we deleted in the above lines
|
|
167
|
+
const filteredPermissionsInputs = permissionInputDTOs.filter((permission) => {
|
|
168
|
+
return !toDeleteWaypoints.some(
|
|
169
|
+
(waypoint) => permission.permission === `WAYPOINTS_USE_${waypoint.trigger.toUpperCase()}_${gameServerId}`,
|
|
170
|
+
);
|
|
171
|
+
});
|
|
172
|
+
const gameServer = (await takaro.gameserver.gameServerControllerGetOne(gameServerId)).data.data;
|
|
173
|
+
await takaro.module.moduleControllerUpdate(waypointsInstallation.moduleId, {
|
|
174
|
+
latestVersion: {
|
|
175
|
+
permissions: [
|
|
176
|
+
...filteredPermissionsInputs,
|
|
177
|
+
...missingWaypoints.map((waypoint) => ({
|
|
178
|
+
permission: `WAYPOINTS_USE_${getWaypointId(waypoint.key).toUpperCase()}_${gameServerId}`,
|
|
179
|
+
description: `Use the waypoint ${getWaypointId(waypoint.key)} on ${gameServer.name}.`,
|
|
180
|
+
friendlyName: `Use waypoint ${getWaypointId(waypoint.key)} on ${gameServer.name}`,
|
|
181
|
+
canHaveCount: false,
|
|
182
|
+
})),
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
}
|