@takaro/modules 0.0.1 → 0.0.4

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.
Files changed (96) hide show
  1. package/dist/BuiltinModule.js +0 -4
  2. package/dist/BuiltinModule.js.map +1 -1
  3. package/dist/community-modules.json +21 -0
  4. package/dist/dto/gameEvents.d.ts +3 -2
  5. package/dist/dto/gameEvents.js +1 -0
  6. package/dist/dto/gameEvents.js.map +1 -1
  7. package/dist/dto/index.d.ts +6 -0
  8. package/dist/dto/takaroEvents.d.ts +46 -0
  9. package/dist/dto/takaroEvents.js +129 -1
  10. package/dist/dto/takaroEvents.js.map +1 -1
  11. package/dist/main.js +1 -1
  12. package/dist/main.js.map +1 -1
  13. package/dist/modules/chatBridge/hooks/GameToDiscord.js +1 -1
  14. package/dist/modules/chatBridge/hooks/GameToDiscord.js.map +1 -1
  15. package/dist/modules/chatBridge/hooks/PlayerConnected.js +2 -2
  16. package/dist/modules/chatBridge/hooks/PlayerConnected.js.map +1 -1
  17. package/dist/modules/chatBridge/hooks/PlayerDisconnected.js +1 -1
  18. package/dist/modules/chatBridge/hooks/PlayerDisconnected.js.map +1 -1
  19. package/dist/modules/economyUtils/commands/transfer.js +1 -1
  20. package/dist/modules/economyUtils/commands/transfer.js.map +1 -1
  21. package/dist/modules/geoBlock/hooks/IPDetected.js +13 -15
  22. package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -1
  23. package/dist/modules/geoBlock/index.js +1 -1
  24. package/dist/modules/geoBlock/index.js.map +1 -1
  25. package/dist/modules/lottery/commands/nextDraw.js +1 -1
  26. package/dist/modules/lottery/commands/nextDraw.js.map +1 -1
  27. package/dist/modules/playerOnboarding/index.js.map +1 -1
  28. package/dist/modules/teleports/commands/deletetp.js +1 -1
  29. package/dist/modules/teleports/commands/deletetp.js.map +1 -1
  30. package/dist/modules/teleports/commands/setprivate.js +4 -6
  31. package/dist/modules/teleports/commands/setprivate.js.map +1 -1
  32. package/dist/modules/teleports/commands/setpublic.js +8 -15
  33. package/dist/modules/teleports/commands/setpublic.js.map +1 -1
  34. package/dist/modules/teleports/commands/settp.js +2 -2
  35. package/dist/modules/teleports/commands/settp.js.map +1 -1
  36. package/dist/modules/teleports/commands/teleport.js +3 -8
  37. package/dist/modules/teleports/commands/teleport.js.map +1 -1
  38. package/dist/modules/teleports/commands/teleportwaypoint.js +9 -1
  39. package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -1
  40. package/dist/modules/teleports/commands/tplist.js +13 -12
  41. package/dist/modules/teleports/commands/tplist.js.map +1 -1
  42. package/dist/modules/teleports/functions/utils.d.ts +2 -2
  43. package/dist/modules/teleports/functions/utils.js +21 -3
  44. package/dist/modules/teleports/functions/utils.js.map +1 -1
  45. package/dist/modules.json +98 -78
  46. package/package.json +4 -8
  47. package/scripts/buildBuiltinJson.ts +20 -0
  48. package/src/BuiltinModule.ts +1 -1
  49. package/src/__tests__/aliases.integration.test.ts +2 -3
  50. package/src/__tests__/bugRepros.integration.test.ts +72 -0
  51. package/src/__tests__/commandArgs.integration.test.ts +2 -3
  52. package/src/__tests__/economyUtils.integration.test.ts +38 -39
  53. package/src/__tests__/geoblock.integration.test.ts +11 -12
  54. package/src/__tests__/gimme.integration.test.ts +4 -5
  55. package/src/__tests__/help.integration.test.ts +12 -13
  56. package/src/__tests__/lottery.integration.test.ts +6 -7
  57. package/src/__tests__/modulePermission.integration.test.ts +5 -6
  58. package/src/__tests__/onboarding.integration.test.ts +5 -6
  59. package/src/__tests__/ping.integration.test.ts +2 -3
  60. package/src/__tests__/roleExpiry.integration.test.ts +3 -4
  61. package/src/__tests__/serverMessages.integration.test.ts +5 -6
  62. package/src/__tests__/systemConfigCost.integration.test.ts +6 -7
  63. package/src/__tests__/teleports/listtp.integration.test.ts +84 -10
  64. package/src/__tests__/teleports/publicteleports.integration.test.ts +11 -12
  65. package/src/__tests__/teleports/teleport.integration.test.ts +4 -5
  66. package/src/__tests__/teleports/tpManagement.integration.test.ts +10 -11
  67. package/src/__tests__/teleports/waypoints.integration.test.ts +5 -6
  68. package/src/community-modules/README.md +5 -0
  69. package/src/community-modules/modules/vote.json +19 -0
  70. package/src/dto/gameEvents.ts +2 -2
  71. package/src/dto/takaroEvents.ts +79 -0
  72. package/src/main.ts +2 -3
  73. package/src/modules/chatBridge/hooks/GameToDiscord.js +1 -1
  74. package/src/modules/chatBridge/hooks/PlayerConnected.js +2 -2
  75. package/src/modules/chatBridge/hooks/PlayerDisconnected.js +1 -1
  76. package/src/modules/chatBridge/index.ts +1 -1
  77. package/src/modules/economyUtils/commands/transfer.js +4 -4
  78. package/src/modules/economyUtils/index.ts +1 -1
  79. package/src/modules/geoBlock/hooks/IPDetected.js +12 -13
  80. package/src/modules/geoBlock/index.ts +2 -2
  81. package/src/modules/gimme/index.ts +1 -1
  82. package/src/modules/highPingKicker/index.ts +1 -1
  83. package/src/modules/lottery/commands/nextDraw.js +3 -1
  84. package/src/modules/lottery/index.ts +1 -1
  85. package/src/modules/playerOnboarding/index.ts +2 -1
  86. package/src/modules/serverMessages/index.ts +1 -1
  87. package/src/modules/teleports/commands/deletetp.js +1 -1
  88. package/src/modules/teleports/commands/setprivate.js +6 -6
  89. package/src/modules/teleports/commands/setpublic.js +18 -25
  90. package/src/modules/teleports/commands/settp.js +2 -2
  91. package/src/modules/teleports/commands/teleport.js +3 -10
  92. package/src/modules/teleports/commands/teleportwaypoint.js +12 -1
  93. package/src/modules/teleports/commands/tplist.js +16 -15
  94. package/src/modules/teleports/functions/utils.js +19 -3
  95. package/src/modules/teleports/index.ts +1 -1
  96. package/src/modules/utils/index.ts +1 -1
@@ -0,0 +1,19 @@
1
+ {
2
+ "commands": [
3
+ {
4
+ "function": "\nimport { takaro, data, axios } from '@takaro/helpers';\nasync function main() {\n const { pog } = data;\n const playerRes = await takaro.player.playerControllerGetOne(data.player.id);\n const steamId = playerRes.data.data.steamId;\n const xboxLiveId = playerRes.data.data.xboxLiveId;\n const name = playerRes.data.data.name;\n const key = data.module.userConfig.votekey;\n\n let voteId = `username=${name}`;\n if (steamId.startsWith(\"7656\")) { voteId = `steamid=${steamId}`; }\n\n\n const res = await axios.get(`https://7daystodie-servers.com/api/?object=votes&element=claim&key=${key}&${voteId}`);\n if (res.data == 0) { data.player.pm(data.module.userConfig.didntvote); }\n if (res.data == 2) { data.player.pm(data.module.userConfig.alreadyvoted); }\n if (res.data == 1) {\n\n const claimresponse = await axios.post(`https://7daystodie-servers.com/api/?action=post&object=votes&element=claim&key=${key}&${voteId}`);\n if (claimresponse.data == 1) {\n if (data.module.userConfig.votednow.toLowerCase() !== 'none' && data.module.userConfig.votednow.toLowerCase() !== '\"none\"') { data.player.pm(data.module.userConfig.votednow); }\n if (data.module.userConfig.publicMessage.toLowerCase() !== 'none' && data.module.userConfig.publicMessage.toLowerCase() !== '\"none\"') {\n const originalMessage = data.module.userConfig.publicMessage;\n const modifiedMessage = originalMessage.replace(/\\{name\\}/g, name);\n await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: `say \"${modifiedMessage}\"` });\n }\n await takaro.playerOnGameserver.playerOnGameServerControllerAddCurrency(data.gameServerId, pog.playerId, { currency: data.module.userConfig.currency });\n for (const stuff of data.module.userConfig.giveStuff) {\n if (voteId.startsWith(`steamid`)) {\n await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: `giveplus Steam_${steamId} ${stuff}` });\n } else {\n await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: `giveplus ${xboxLiveId} ${stuff}` });\n }\n }\n }\n }\n}\n\n\n\nawait main();",
5
+ "name": "vote",
6
+ "trigger": "vote",
7
+ "helpText": "Vote for the server and give players rewards.",
8
+ "arguments": []
9
+ }
10
+ ],
11
+ "hooks": [],
12
+ "cronJobs": [],
13
+ "functions": [],
14
+ "permissions": [],
15
+ "name": "Vote",
16
+ "description": "Takaro Vote Module",
17
+ "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"required\":[\"votekey\",\"didntvote\",\"alreadyvoted\"],\"additionalProperties\":false,\"properties\":{\"votekey\":{\"title\":\"votekey\",\"description\":\"Votekey from website\",\"default\":\"\",\"type\":\"string\"},\"didntvote\":{\"title\":\"didntvote\",\"description\":\"Message to send to the player when voting site reports no vote was cast.\",\"default\":\"You haven't voted yet.\",\"type\":\"string\"},\"alreadyvoted\":{\"title\":\"alreadyvoted\",\"description\":\"Message to send to the player when voting site reports the vote was already claimed.\",\"default\":\"You have already claimed your last vote.\",\"type\":\"string\"},\"votednow\":{\"title\":\"votednow\",\"description\":\"Optional message to send to the player when vote is successful. \\nUse \\\"none\\\" as the message if you want nothing to be sent instead.\",\"default\":\"Thanks for voting.\",\"type\":\"string\"},\"publicMessage\":{\"title\":\"publicMessage\",\"description\":\"Optional message to broadcast to all players online when vote is successful. Use {name} in the message to refer to the player name.\\nUse \\\"none\\\" as the message if you want nothing to be sent instead.\",\"default\":\"[FF0000]{name}[-] voted at 7daystodie-servers.com and was rewarded Takaro Coins!\",\"type\":\"string\"},\"giveStuff\":{\"title\":\"giveStuff\",\"description\":\"Items to give to the player thru giveplus command. Must indicate quantities and, if applies, quality:\\n<item name> <amount> [<quality> <usedTimes>]\\n\\nItem name has to be the exact name of an item as listed by \\\"listitems\\\".\\n\\nQuality is the quality of the dropped items for items that have a quality.\\n\\nusedTimes is the % that the item was used.\\n\\nThe default value is giving 2 waters and a tier 6 stone axe with no use. If you are going to copy/paste, include the arguments. \",\"default\":[\"drinkJarBoiledWater 2\",\"meleeToolRepairT0StoneAxe 1 6 0\"],\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"currency\":{\"title\":\"currency\",\"description\":\"How much currency to add to the player in Takaro\",\"default\":0,\"type\":\"number\"}}}",
18
+ "uiSchema": "{}"
19
+ }
@@ -61,7 +61,7 @@ export class BaseGameEvent<T> extends BaseEvent<T> {
61
61
  msg: string;
62
62
  }
63
63
 
64
- export interface IPosition {
64
+ export interface IPositionInterface {
65
65
  x: number;
66
66
  y: number;
67
67
  z: number;
@@ -105,7 +105,7 @@ export class EventChatMessage extends BaseGameEvent<EventChatMessage> {
105
105
  declare msg: string;
106
106
  }
107
107
 
108
- export class IPosition {
108
+ export class IPosition implements IPositionInterface {
109
109
  @IsNumber()
110
110
  x: number;
111
111
  @IsNumber()
@@ -9,6 +9,7 @@ import {
9
9
  IsObject,
10
10
  IsOptional,
11
11
  IsString,
12
+ IsUUID,
12
13
  ValidateNested,
13
14
  } from 'class-validator';
14
15
  import { BaseEvent } from './base.js';
@@ -36,6 +37,12 @@ export const TakaroEvents = {
36
37
  MODULE_INSTALLED: 'module-installed',
37
38
  MODULE_UNINSTALLED: 'module-uninstalled',
38
39
  PLAYER_CREATED: 'player-created',
40
+ SHOP_LISTING_CREATED: 'shop-listing-created',
41
+ SHOP_LISTING_UPDATED: 'shop-listing-updated',
42
+ SHOP_LISTING_DELETED: 'shop-listing-deleted',
43
+ SHOP_ORDER_CREATED: 'shop-order-created',
44
+ SHOP_ORDER_STATUS_CHANGED: 'shop-order-status-changed',
45
+ PLAYER_LINKED: 'player-linked',
39
46
  } as const;
40
47
 
41
48
  export class BaseTakaroEvent<T> extends BaseEvent<T> {
@@ -116,6 +123,20 @@ export class TakaroEventCommandDetails extends TakaroDTO<TakaroEventCommandDetai
116
123
  arguments: Record<string, unknown>;
117
124
  }
118
125
 
126
+ export class TakaroEventHookDetails extends TakaroDTO<TakaroEventHookDetails> {
127
+ @IsString()
128
+ id: string;
129
+ @IsString()
130
+ name: string;
131
+ }
132
+
133
+ export class TakaroEventCronjobDetails extends TakaroDTO<TakaroEventCronjobDetails> {
134
+ @IsString()
135
+ id: string;
136
+ @IsString()
137
+ name: string;
138
+ }
139
+
119
140
  export class TakaroEventCommandExecuted extends BaseEvent<TakaroEventCommandExecuted> {
120
141
  @IsString()
121
142
  type = TakaroEvents.COMMAND_EXECUTED;
@@ -143,6 +164,11 @@ export class TakaroEventHookExecuted extends BaseEvent<TakaroEventHookExecuted>
143
164
  @ValidateNested({ each: true })
144
165
  @Type(() => TakaroEventFunctionResult)
145
166
  result: TakaroEventFunctionResult;
167
+
168
+ @IsOptional()
169
+ @ValidateNested()
170
+ @Type(() => TakaroEventHookDetails)
171
+ hook: TakaroEventHookDetails;
146
172
  }
147
173
 
148
174
  export class TakaroEventCronjobExecuted extends BaseEvent<TakaroEventCronjobExecuted> {
@@ -155,6 +181,11 @@ export class TakaroEventCronjobExecuted extends BaseEvent<TakaroEventCronjobExec
155
181
  @ValidateNested({ each: true })
156
182
  @Type(() => TakaroEventFunctionResult)
157
183
  result: TakaroEventFunctionResult;
184
+
185
+ @IsOptional()
186
+ @ValidateNested()
187
+ @Type(() => TakaroEventCronjobDetails)
188
+ cronjob: TakaroEventCronjobDetails;
158
189
  }
159
190
 
160
191
  export class TakaroEventRoleMeta extends TakaroDTO<TakaroEventRoleMeta> {
@@ -267,6 +298,48 @@ export class TakaroEventPlayerCreated extends BaseEvent<TakaroEventPlayerCreated
267
298
  type = TakaroEvents.PLAYER_CREATED;
268
299
  }
269
300
 
301
+ export class TakaroEventShopListingCreated extends BaseEvent<TakaroEventShopListingCreated> {
302
+ @IsString()
303
+ type = TakaroEvents.SHOP_LISTING_CREATED;
304
+ @IsUUID()
305
+ id: string;
306
+ }
307
+
308
+ export class TakaroEventShopListingUpdated extends BaseEvent<TakaroEventShopListingUpdated> {
309
+ @IsString()
310
+ type = TakaroEvents.SHOP_LISTING_UPDATED;
311
+ @IsUUID()
312
+ id: string;
313
+ }
314
+
315
+ export class TakaroEventShopListingDeleted extends BaseEvent<TakaroEventShopListingDeleted> {
316
+ @IsString()
317
+ type = TakaroEvents.SHOP_LISTING_DELETED;
318
+ @IsUUID()
319
+ id: string;
320
+ }
321
+
322
+ export class TakaroEventShopOrderCreated extends BaseEvent<TakaroEventShopOrderCreated> {
323
+ @IsString()
324
+ type = TakaroEvents.SHOP_ORDER_CREATED;
325
+ @IsUUID()
326
+ id: string;
327
+ }
328
+
329
+ export class TakaroEventShopOrderStatusChanged extends BaseEvent<TakaroEventShopOrderStatusChanged> {
330
+ @IsString()
331
+ type = TakaroEvents.SHOP_ORDER_STATUS_CHANGED;
332
+ @IsUUID()
333
+ id: string;
334
+ @IsString()
335
+ status: string;
336
+ }
337
+
338
+ export class TakaroEventPlayerLinked extends BaseEvent<TakaroEventPlayerLinked> {
339
+ @IsString()
340
+ type = TakaroEvents.PLAYER_LINKED;
341
+ }
342
+
270
343
  export const TakaroEventsMapping = {
271
344
  [TakaroEvents.ROLE_ASSIGNED]: TakaroEventRoleAssigned,
272
345
  [TakaroEvents.PLAYER_NEW_IP_DETECTED]: TakaroEventPlayerNewIpDetected,
@@ -287,4 +360,10 @@ export const TakaroEventsMapping = {
287
360
  [TakaroEvents.MODULE_INSTALLED]: TakaroEventModuleInstalled,
288
361
  [TakaroEvents.MODULE_UNINSTALLED]: TakaroEventModuleUninstalled,
289
362
  [TakaroEvents.PLAYER_CREATED]: TakaroEventPlayerCreated,
363
+ [TakaroEvents.SHOP_LISTING_CREATED]: TakaroEventShopListingCreated,
364
+ [TakaroEvents.SHOP_LISTING_UPDATED]: TakaroEventShopListingUpdated,
365
+ [TakaroEvents.SHOP_LISTING_DELETED]: TakaroEventShopListingDeleted,
366
+ [TakaroEvents.SHOP_ORDER_CREATED]: TakaroEventShopOrderCreated,
367
+ [TakaroEvents.SHOP_ORDER_STATUS_CHANGED]: TakaroEventShopOrderStatusChanged,
368
+ [TakaroEvents.PLAYER_LINKED]: TakaroEventPlayerLinked,
290
369
  } as const;
package/src/main.ts CHANGED
@@ -8,12 +8,11 @@ import { Lottery } from './modules/lottery/index.js';
8
8
  import { PlayerOnboarding } from './modules/playerOnboarding/index.js';
9
9
  import { ServerMessages } from './modules/serverMessages/index.js';
10
10
  import { Teleports } from './modules/teleports/index.js';
11
- export { BuiltinModule, ICommand, ICommandArgument, ICronJob, IHook, IFunction } from './BuiltinModule.js';
11
+ import { Utils } from './modules/utils/index.js';
12
12
 
13
+ export { BuiltinModule, ICommand, ICommandArgument, ICronJob, IHook, IFunction } from './BuiltinModule.js';
13
14
  export * from './dto/index.js';
14
15
 
15
- import { Utils } from './modules/utils/index.js';
16
-
17
16
  let cached: Array<BuiltinModule<unknown>> | null = null;
18
17
 
19
18
  export function getModules(): Array<BuiltinModule<unknown>> {
@@ -5,7 +5,7 @@ async function main() {
5
5
 
6
6
  if (onlyGlobal && data.eventData.channel !== 'global') return;
7
7
 
8
- const discordChannel = data.module.systemConfig.hooks['DiscordToGame Discord channel ID'];
8
+ const discordChannel = data.module.systemConfig.hooks['DiscordToGame'].discordChannelId;
9
9
 
10
10
  const sender = data.player ? data.player.name : 'Non-player';
11
11
  const message = `**${sender}**: ${data.eventData.msg}`;
@@ -1,10 +1,10 @@
1
1
  import { takaro, data } from '@takaro/helpers';
2
2
 
3
3
  async function main() {
4
- const discordChannel = data.module.systemConfig.hooks['DiscordToGame Discord channel ID'];
4
+ const discordChannel = data.module.systemConfig.hooks['DiscordToGame'].discordChannelId;
5
5
 
6
6
  await takaro.discord.discordControllerSendMessage(discordChannel, {
7
- message: `[🔌 Connected]: ${data.player.name}`,
7
+ message: `[ Connected]: ${data.player.name}`,
8
8
  });
9
9
  }
10
10
 
@@ -1,7 +1,7 @@
1
1
  import { takaro, data } from '@takaro/helpers';
2
2
 
3
3
  async function main() {
4
- const discordChannel = data.module.systemConfig.hooks['DiscordToGame Discord channel ID'];
4
+ const discordChannel = data.module.systemConfig.hooks['DiscordToGame'].discordChannelId;
5
5
 
6
6
  await takaro.discord.discordControllerSendMessage(discordChannel, {
7
7
  message: `[👋 Disconnected]: ${data.player.name}`,
@@ -30,7 +30,7 @@ export class ChatBridge extends BuiltinModule<ChatBridge> {
30
30
  },
31
31
  },
32
32
  additionalProperties: false,
33
- })
33
+ }),
34
34
  );
35
35
 
36
36
  this.hooks = [
@@ -33,7 +33,7 @@ async function main() {
33
33
 
34
34
  // NOTE: we should maybe check if the player has enough balance to send the amount since this is only checked when the transaction is executed.
35
35
  await sender.pm(
36
- `You are about to send ${args.amount} ${currencyName} to ${receiverName}. (Please confirm by typing ${prefix}confirmtransfer)`
36
+ `You are about to send ${args.amount} ${currencyName} to ${receiverName}. (Please confirm by typing ${prefix}confirmtransfer)`,
37
37
  );
38
38
  return;
39
39
  }
@@ -45,11 +45,11 @@ async function main() {
45
45
  receiver.id,
46
46
  {
47
47
  currency: args.amount,
48
- }
48
+ },
49
49
  );
50
- } catch (e) {
50
+ } catch (_e) {
51
51
  throw new TakaroUserError(
52
- `Failed to transfer ${args.amount} ${currencyName} to ${receiverName}. Are you sure you have enough balance?`
52
+ `Failed to transfer ${args.amount} ${currencyName} to ${receiverName}. Are you sure you have enough balance?`,
53
53
  );
54
54
  }
55
55
 
@@ -19,7 +19,7 @@ export class EconomyUtils extends BuiltinModule<EconomyUtils> {
19
19
  },
20
20
  required: [],
21
21
  additionalProperties: false,
22
- })
22
+ }),
23
23
  );
24
24
 
25
25
  this.permissions = [
@@ -30,22 +30,21 @@ async function main() {
30
30
  if (countries.includes(country)) {
31
31
  console.log('Allowed country detected, no action');
32
32
  return;
33
- } else {
34
- console.log('Blocked country detected, performing actions');
35
- await handleAction();
36
- return;
37
33
  }
34
+ console.log('Blocked country detected, performing actions');
35
+ await handleAction();
36
+ return;
38
37
  }
38
+ }
39
39
 
40
- if (mode === 'deny') {
41
- if (countries.includes(country)) {
42
- console.log('Blocked country detected, performing actions');
43
- await handleAction();
44
- return;
45
- } else {
46
- console.log('Allowed country detected, no action');
47
- return;
48
- }
40
+ if (mode === 'deny') {
41
+ if (countries.includes(country)) {
42
+ console.log('Blocked country detected, performing actions');
43
+ await handleAction();
44
+ return;
45
+ } else {
46
+ console.log('Allowed country detected, no action');
47
+ return;
49
48
  }
50
49
  }
51
50
 
@@ -271,7 +271,7 @@ export class GeoBlock extends BuiltinModule<GeoBlock> {
271
271
  },
272
272
  countries: {
273
273
  title: 'Countries',
274
- description: 'List of country',
274
+ description: 'List of countries',
275
275
  type: 'array',
276
276
  uniqueItems: true,
277
277
  'x-component': 'country',
@@ -307,7 +307,7 @@ export class GeoBlock extends BuiltinModule<GeoBlock> {
307
307
  }),
308
308
  JSON.stringify({
309
309
  banDuration: { 'ui:widget': 'duration' },
310
- })
310
+ }),
311
311
  );
312
312
 
313
313
  this.permissions = [
@@ -33,7 +33,7 @@ export class Gimme extends BuiltinModule<Gimme> {
33
33
  }),
34
34
  JSON.stringify({
35
35
  items: { 'ui:widget': 'item' },
36
- })
36
+ }),
37
37
  );
38
38
 
39
39
  this.commands = [
@@ -25,7 +25,7 @@ export class HighPingKicker extends BuiltinModule<HighPingKicker> {
25
25
  },
26
26
  },
27
27
  required: [],
28
- })
28
+ }),
29
29
  );
30
30
 
31
31
  this.cronJobs = [
@@ -39,7 +39,9 @@ function formatTimeToReach(cronJob) {
39
39
 
40
40
  async function main() {
41
41
  const { player, module: mod } = data;
42
- await player.pm(`The next lottery draw is in about ${formatTimeToReach(mod.systemConfig.cronJobs.drawLottery)}`);
42
+ await player.pm(
43
+ `The next lottery draw is in about ${formatTimeToReach(mod.systemConfig.cronJobs.drawLottery.temporalValue)}`
44
+ );
43
45
  }
44
46
 
45
47
  await main();
@@ -19,7 +19,7 @@ export class Lottery extends BuiltinModule<Lottery> {
19
19
  },
20
20
  required: [],
21
21
  additionalProperties: false,
22
- })
22
+ }),
23
23
  );
24
24
 
25
25
  this.permissions = [
@@ -1,5 +1,6 @@
1
1
  import { BuiltinModule, ICommand, IHook } from '../../BuiltinModule.js';
2
2
  import { HookEvents } from '../../dto/index.js';
3
+
3
4
  export class PlayerOnboarding extends BuiltinModule<PlayerOnboarding> {
4
5
  constructor() {
5
6
  super(
@@ -34,7 +35,7 @@ export class PlayerOnboarding extends BuiltinModule<PlayerOnboarding> {
34
35
  }),
35
36
  JSON.stringify({
36
37
  starterKitItems: { 'ui:widget': 'item' },
37
- })
38
+ }),
38
39
  );
39
40
 
40
41
  this.hooks = [
@@ -26,7 +26,7 @@ export class ServerMessages extends BuiltinModule<ServerMessages> {
26
26
  },
27
27
  },
28
28
  required: ['messages'],
29
- })
29
+ }),
30
30
  );
31
31
 
32
32
  this.cronJobs = [
@@ -6,7 +6,7 @@ async function main() {
6
6
 
7
7
  const existingVariable = await takaro.variable.variableControllerSearch({
8
8
  filters: {
9
- key: [getVariableKey(args.tp)],
9
+ key: [getVariableKey(args.tp), getVariableKey(args.tp, true)],
10
10
  gameServerId: [gameServerId],
11
11
  playerId: [pog.playerId],
12
12
  moduleId: [mod.moduleId],
@@ -10,7 +10,7 @@ async function main() {
10
10
  filters: {
11
11
  gameServerId: [gameServerId],
12
12
  playerId: [pog.playerId],
13
- key: [getVariableKey(args.tp)],
13
+ key: [getVariableKey(args.tp, true)],
14
14
  moduleId: [mod.moduleId],
15
15
  },
16
16
  sortBy: 'key',
@@ -20,17 +20,17 @@ async function main() {
20
20
  const teleports = teleportRes.data.data;
21
21
 
22
22
  if (teleports.length === 0) {
23
- throw new TakaroUserError(`No teleport with name ${args.tp} found, use ${prefix}settp <name> to set one first.`);
23
+ throw new TakaroUserError(
24
+ `No public teleport with name ${args.tp} found, use ${prefix}settp <name> to set one first.`
25
+ );
24
26
  }
25
27
 
26
28
  const teleportRecord = teleports[0];
27
29
  const teleport = JSON.parse(teleportRecord.value);
28
30
 
29
31
  await takaro.variable.variableControllerUpdate(teleportRecord.id, {
30
- value: JSON.stringify({
31
- ...teleport,
32
- public: false,
33
- }),
32
+ key: getVariableKey(args.tp),
33
+ value: JSON.stringify(teleport),
34
34
  });
35
35
 
36
36
  await data.player.pm(`Teleport ${args.tp} is now private.`);
@@ -4,7 +4,7 @@ import { getVariableKey } from './utils.js';
4
4
  async function main() {
5
5
  const { pog, gameServerId, module: mod, arguments: args } = data;
6
6
 
7
- const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data;
7
+ const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value;
8
8
 
9
9
  if (!mod.userConfig.allowPublicTeleports) {
10
10
  throw new TakaroUserError('Public teleports are disabled.');
@@ -16,9 +16,9 @@ async function main() {
16
16
  throw new TakaroUserError('You do not have permission to create public teleports.');
17
17
  }
18
18
 
19
- const existingTeleportsForPlayerRes = await takaro.variable.variableControllerSearch({
19
+ const existingPublicTeleportsForPlayerRes = await takaro.variable.variableControllerSearch({
20
20
  search: {
21
- key: 'tp_',
21
+ key: ['pubtp_'],
22
22
  },
23
23
  filters: {
24
24
  gameServerId: [gameServerId],
@@ -27,29 +27,24 @@ async function main() {
27
27
  },
28
28
  });
29
29
 
30
- const existingPublicTeleportsForPlayer = existingTeleportsForPlayerRes.data.data.filter((tp) => {
31
- const teleport = JSON.parse(tp.value);
32
- return teleport.public;
33
- });
34
-
35
- if (existingPublicTeleportsForPlayer.length >= hasPermission.count) {
30
+ if (existingPublicTeleportsForPlayerRes.data.data.length >= hasPermission.count) {
36
31
  throw new TakaroUserError(
37
32
  `You have reached the maximum number of public teleports for your role, maximum allowed is ${hasPermission.count}`
38
33
  );
39
34
  }
40
35
 
41
- const teleportRes = await takaro.variable.variableControllerSearch({
42
- filters: {
43
- gameServerId: [gameServerId],
44
- playerId: [pog.playerId],
45
- moduleId: [mod.moduleId],
46
- key: [getVariableKey(args.tp)],
47
- },
48
- sortBy: 'key',
49
- sortDirection: 'asc',
50
- });
51
-
52
- const teleports = teleportRes.data.data;
36
+ const teleports = (
37
+ await takaro.variable.variableControllerSearch({
38
+ filters: {
39
+ gameServerId: [gameServerId],
40
+ playerId: [pog.playerId],
41
+ moduleId: [mod.moduleId],
42
+ key: [getVariableKey(args.tp)],
43
+ },
44
+ sortBy: 'key',
45
+ sortDirection: 'asc',
46
+ })
47
+ ).data.data;
53
48
 
54
49
  if (teleports.length === 0) {
55
50
  throw new TakaroUserError(`No teleport with name ${args.tp} found, use ${prefix}settp <name> to set one first.`);
@@ -59,10 +54,8 @@ async function main() {
59
54
  const teleport = JSON.parse(teleportRecord.value);
60
55
 
61
56
  await takaro.variable.variableControllerUpdate(teleportRecord.id, {
62
- value: JSON.stringify({
63
- ...teleport,
64
- public: true,
65
- }),
57
+ key: getVariableKey(args.tp, true),
58
+ value: JSON.stringify(teleport),
66
59
  });
67
60
 
68
61
  await data.player.pm(`Teleport ${args.tp} is now public.`);
@@ -12,7 +12,7 @@ async function main() {
12
12
 
13
13
  const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value;
14
14
 
15
- const existingVariable = await findTp(args.tp);
15
+ const existingVariable = await findTp(args.tp, pog.playerId);
16
16
 
17
17
  if (existingVariable.data.data.length > 0) {
18
18
  throw new TakaroUserError(`Teleport ${args.tp} already exists, use ${prefix}deletetp ${args.tp} to delete it.`);
@@ -20,7 +20,7 @@ async function main() {
20
20
 
21
21
  const allPlayerTeleports = await takaro.variable.variableControllerSearch({
22
22
  search: {
23
- key: getVariableKey(''),
23
+ key: [getVariableKey(undefined), getVariableKey(undefined, true)],
24
24
  },
25
25
  filters: {
26
26
  gameServerId: [gameServerId],
@@ -13,14 +13,8 @@ async function main() {
13
13
  let teleports = ownedTeleportRes.data.data;
14
14
 
15
15
  if (mod.userConfig.allowPublicTeleports) {
16
- const maybePublicTeleportRes = await findTp(args.tp);
17
-
18
- const publicTeleports = maybePublicTeleportRes.data.data.filter((tele) => {
19
- const teleport = JSON.parse(tele.value);
20
- return teleport.public;
21
- });
22
-
23
- teleports = teleports.concat(publicTeleports);
16
+ const publicTeleportRes = await findTp(args.tp, null, true);
17
+ teleports = teleports.concat(publicTeleportRes.data.data);
24
18
  }
25
19
 
26
20
  if (teleports.length === 0) {
@@ -29,7 +23,7 @@ async function main() {
29
23
 
30
24
  const timeout = mod.userConfig.timeout;
31
25
 
32
- if (timeout !== 0) {
26
+ if (timeout > 0) {
33
27
  const lastExecuted = await takaro.variable.variableControllerSearch({
34
28
  filters: {
35
29
  key: ['lastExecuted'],
@@ -48,7 +42,6 @@ async function main() {
48
42
  moduleId: mod.moduleId,
49
43
  value: new Date().toISOString(),
50
44
  });
51
- console.log(createRes);
52
45
  lastExecutedRecord = createRes.data.data;
53
46
  } else {
54
47
  const lastExecutedTime = new Date(lastExecutedRecord.value);
@@ -5,7 +5,18 @@ function getWaypointName(name) {
5
5
  }
6
6
 
7
7
  async function main() {
8
- const { pog, gameServerId, trigger } = data;
8
+ const { pog, gameServerId, trigger, module, itemId } = data;
9
+
10
+ const triggeredCommand = module.module.commands.find((command) => command.id === itemId);
11
+
12
+ if (!triggeredCommand) {
13
+ throw new Error('Waypoint not found.');
14
+ }
15
+
16
+ if (!triggeredCommand.name.includes(`server ${gameServerId}`)) {
17
+ console.log(`Waypoint ${trigger} is not for this server.`);
18
+ return;
19
+ }
9
20
 
10
21
  if (!checkPermission(pog, `WAYPOINTS_USE_${trigger.toUpperCase()}_${gameServerId}`)) {
11
22
  throw new TakaroUserError(`You are not allowed to use the waypoint ${trigger}.`);
@@ -1,9 +1,10 @@
1
1
  import { takaro, data } from '@takaro/helpers';
2
+ import { getVariableKey } from './utils.js';
2
3
 
3
4
  async function main() {
4
5
  const { pog, gameServerId, module: mod } = data;
5
6
 
6
- const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data;
7
+ const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value;
7
8
 
8
9
  const ownedTeleports = (
9
10
  await takaro.variable.variableControllerSearch({
@@ -13,38 +14,36 @@ async function main() {
13
14
  moduleId: [mod.moduleId],
14
15
  },
15
16
  search: {
16
- key: 'tp',
17
+ key: [getVariableKey(undefined, false)],
17
18
  },
18
19
  sortBy: 'key',
19
20
  sortDirection: 'asc',
20
21
  })
21
22
  ).data.data;
22
23
 
23
- const maybePublicTeleports = (
24
+ const publicTeleports = (
24
25
  await takaro.variable.variableControllerSearch({
25
26
  filters: {
26
27
  gameServerId: [gameServerId],
27
28
  moduleId: [mod.moduleId],
28
29
  },
29
30
  search: {
30
- key: ['tp'],
31
+ key: [getVariableKey(undefined, true)],
31
32
  },
32
33
  sortBy: 'key',
33
34
  sortDirection: 'asc',
34
35
  })
35
- ).data.data;
36
-
37
- const teleports = maybePublicTeleports.filter((tele) => {
38
- const teleport = JSON.parse(tele.value);
39
-
40
- const isPublic = teleport.public && teleport.playerId !== pog.playerId;
41
- const isOwned = ownedTeleports.find((t) => t.playerId === pog.playerId);
36
+ ).data.data
37
+ // Filter out public teleports that are owned by the player
38
+ // Since we'll be showing them in the owned teleports list
39
+ .filter((teleport) => {
40
+ return teleport.playerId !== pog.playerId;
41
+ });
42
42
 
43
- return isPublic || isOwned;
44
- });
43
+ const teleports = [...ownedTeleports, ...publicTeleports];
45
44
 
46
45
  if (teleports.length === 0) {
47
- await data.player.pm(`You have no teleports set, use ${prefix}settp <name> to set one.`);
46
+ await data.player.pm(`You have no teleports available, use ${prefix}settp <name> to set one.`);
48
47
  return;
49
48
  }
50
49
 
@@ -53,7 +52,9 @@ async function main() {
53
52
  for (const rawTeleport of teleports) {
54
53
  const teleport = JSON.parse(rawTeleport.value);
55
54
  await data.player.pm(
56
- ` - ${teleport.name}: ${teleport.x}, ${teleport.y}, ${teleport.z} ${teleport.public ? '(public)' : ''}`
55
+ `${teleport.name}: (${teleport.x},${teleport.y},${teleport.z}) ${
56
+ rawTeleport.key.startsWith('pub') ? '(public)' : ''
57
+ }`
57
58
  );
58
59
  }
59
60
  }