@takaro/modules 0.0.14 → 0.0.18

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 (244) hide show
  1. package/dist/BuiltinModule.d.ts +13 -8
  2. package/dist/BuiltinModule.d.ts.map +1 -0
  3. package/dist/BuiltinModule.js +48 -31
  4. package/dist/BuiltinModule.js.map +1 -1
  5. package/dist/dto/base.d.ts +1 -0
  6. package/dist/dto/base.d.ts.map +1 -0
  7. package/dist/dto/discordEvents.d.ts +1 -0
  8. package/dist/dto/discordEvents.d.ts.map +1 -0
  9. package/dist/dto/gameEvents.d.ts +1 -0
  10. package/dist/dto/gameEvents.d.ts.map +1 -0
  11. package/dist/dto/index.d.ts +4 -0
  12. package/dist/dto/index.d.ts.map +1 -0
  13. package/dist/dto/takaroEvents.d.ts +16 -0
  14. package/dist/dto/takaroEvents.d.ts.map +1 -0
  15. package/dist/dto/takaroEvents.js +36 -0
  16. package/dist/dto/takaroEvents.js.map +1 -1
  17. package/dist/main.d.ts +4 -3
  18. package/dist/main.d.ts.map +1 -0
  19. package/dist/main.js +3 -1
  20. package/dist/main.js.map +1 -1
  21. package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts +1 -0
  22. package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts.map +1 -0
  23. package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts +1 -0
  24. package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts.map +1 -0
  25. package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts +1 -0
  26. package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts.map +1 -0
  27. package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts +1 -0
  28. package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts.map +1 -0
  29. package/dist/modules/chatBridge/index.d.ts +3 -2
  30. package/dist/modules/chatBridge/index.d.ts.map +1 -0
  31. package/dist/modules/chatBridge/index.js +55 -47
  32. package/dist/modules/chatBridge/index.js.map +1 -1
  33. package/dist/modules/dailyRewards/commands/daily.d.ts +2 -0
  34. package/dist/modules/dailyRewards/commands/daily.d.ts.map +1 -0
  35. package/dist/modules/dailyRewards/commands/daily.js +106 -0
  36. package/dist/modules/dailyRewards/commands/daily.js.map +1 -0
  37. package/dist/modules/dailyRewards/commands/streak.d.ts +2 -0
  38. package/dist/modules/dailyRewards/commands/streak.d.ts.map +1 -0
  39. package/dist/modules/dailyRewards/commands/streak.js +34 -0
  40. package/dist/modules/dailyRewards/commands/streak.js.map +1 -0
  41. package/dist/modules/dailyRewards/commands/topstreak.d.ts +2 -0
  42. package/dist/modules/dailyRewards/commands/topstreak.d.ts.map +1 -0
  43. package/dist/modules/dailyRewards/commands/topstreak.js +44 -0
  44. package/dist/modules/dailyRewards/commands/topstreak.js.map +1 -0
  45. package/dist/modules/dailyRewards/functions/utils.d.ts +6 -0
  46. package/dist/modules/dailyRewards/functions/utils.d.ts.map +1 -0
  47. package/dist/modules/dailyRewards/functions/utils.js +32 -0
  48. package/dist/modules/dailyRewards/functions/utils.js.map +1 -0
  49. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.d.ts +2 -0
  50. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.d.ts.map +1 -0
  51. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.js +19 -0
  52. package/dist/modules/dailyRewards/hooks/dailyLoginCheck.js.map +1 -0
  53. package/dist/modules/dailyRewards/index.d.ts +5 -0
  54. package/dist/modules/dailyRewards/index.d.ts.map +1 -0
  55. package/dist/modules/dailyRewards/index.js +125 -0
  56. package/dist/modules/dailyRewards/index.js.map +1 -0
  57. package/dist/modules/economyUtils/commands/balance.d.ts +1 -0
  58. package/dist/modules/economyUtils/commands/balance.d.ts.map +1 -0
  59. package/dist/modules/economyUtils/commands/claim.d.ts +1 -0
  60. package/dist/modules/economyUtils/commands/claim.d.ts.map +1 -0
  61. package/dist/modules/economyUtils/commands/confirmTransfer.d.ts +1 -0
  62. package/dist/modules/economyUtils/commands/confirmTransfer.d.ts.map +1 -0
  63. package/dist/modules/economyUtils/commands/grantCurrency.d.ts +1 -0
  64. package/dist/modules/economyUtils/commands/grantCurrency.d.ts.map +1 -0
  65. package/dist/modules/economyUtils/commands/revokeCurrency.d.ts +1 -0
  66. package/dist/modules/economyUtils/commands/revokeCurrency.d.ts.map +1 -0
  67. package/dist/modules/economyUtils/commands/shop.d.ts +1 -0
  68. package/dist/modules/economyUtils/commands/shop.d.ts.map +1 -0
  69. package/dist/modules/economyUtils/commands/topCurrency.d.ts +1 -0
  70. package/dist/modules/economyUtils/commands/topCurrency.d.ts.map +1 -0
  71. package/dist/modules/economyUtils/commands/transfer.d.ts +1 -0
  72. package/dist/modules/economyUtils/commands/transfer.d.ts.map +1 -0
  73. package/dist/modules/economyUtils/cronJobs/zombieKillReward.d.ts +1 -0
  74. package/dist/modules/economyUtils/cronJobs/zombieKillReward.d.ts.map +1 -0
  75. package/dist/modules/economyUtils/index.d.ts +3 -2
  76. package/dist/modules/economyUtils/index.d.ts.map +1 -0
  77. package/dist/modules/economyUtils/index.js +178 -170
  78. package/dist/modules/economyUtils/index.js.map +1 -1
  79. package/dist/modules/geoBlock/hooks/IPDetected.d.ts +1 -0
  80. package/dist/modules/geoBlock/hooks/IPDetected.d.ts.map +1 -0
  81. package/dist/modules/geoBlock/hooks/IPDetected.js +4 -2
  82. package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -1
  83. package/dist/modules/geoBlock/index.d.ts +3 -2
  84. package/dist/modules/geoBlock/index.d.ts.map +1 -0
  85. package/dist/modules/geoBlock/index.js +71 -63
  86. package/dist/modules/geoBlock/index.js.map +1 -1
  87. package/dist/modules/gimme/commands/gimme.d.ts +1 -0
  88. package/dist/modules/gimme/commands/gimme.d.ts.map +1 -0
  89. package/dist/modules/gimme/commands/gimme.js +17 -6
  90. package/dist/modules/gimme/commands/gimme.js.map +1 -1
  91. package/dist/modules/gimme/index.d.ts +3 -2
  92. package/dist/modules/gimme/index.d.ts.map +1 -0
  93. package/dist/modules/gimme/index.js +64 -34
  94. package/dist/modules/gimme/index.js.map +1 -1
  95. package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts +1 -0
  96. package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts.map +1 -0
  97. package/dist/modules/highPingKicker/index.d.ts +3 -2
  98. package/dist/modules/highPingKicker/index.d.ts.map +1 -0
  99. package/dist/modules/highPingKicker/index.js +36 -28
  100. package/dist/modules/highPingKicker/index.js.map +1 -1
  101. package/dist/modules/lottery/commands/buyTicket.d.ts +1 -0
  102. package/dist/modules/lottery/commands/buyTicket.d.ts.map +1 -0
  103. package/dist/modules/lottery/commands/nextDraw.d.ts +1 -0
  104. package/dist/modules/lottery/commands/nextDraw.d.ts.map +1 -0
  105. package/dist/modules/lottery/commands/viewTickets.d.ts +1 -0
  106. package/dist/modules/lottery/commands/viewTickets.d.ts.map +1 -0
  107. package/dist/modules/lottery/cronJobs/drawLottery.d.ts +1 -0
  108. package/dist/modules/lottery/cronJobs/drawLottery.d.ts.map +1 -0
  109. package/dist/modules/lottery/index.d.ts +3 -2
  110. package/dist/modules/lottery/index.d.ts.map +1 -0
  111. package/dist/modules/lottery/index.js +73 -65
  112. package/dist/modules/lottery/index.js.map +1 -1
  113. package/dist/modules/playerOnboarding/commands/starterkit.d.ts +1 -0
  114. package/dist/modules/playerOnboarding/commands/starterkit.d.ts.map +1 -0
  115. package/dist/modules/playerOnboarding/commands/starterkit.js +16 -3
  116. package/dist/modules/playerOnboarding/commands/starterkit.js.map +1 -1
  117. package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts +1 -0
  118. package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts.map +1 -0
  119. package/dist/modules/playerOnboarding/index.d.ts +3 -2
  120. package/dist/modules/playerOnboarding/index.d.ts.map +1 -0
  121. package/dist/modules/playerOnboarding/index.js +73 -43
  122. package/dist/modules/playerOnboarding/index.js.map +1 -1
  123. package/dist/modules/serverMessages/cronJobs/Automated message.d.ts +1 -0
  124. package/dist/modules/serverMessages/cronJobs/Automated message.d.ts.map +1 -0
  125. package/dist/modules/serverMessages/index.d.ts +3 -2
  126. package/dist/modules/serverMessages/index.d.ts.map +1 -0
  127. package/dist/modules/serverMessages/index.js +36 -28
  128. package/dist/modules/serverMessages/index.js.map +1 -1
  129. package/dist/modules/teleports/commands/deletetp.d.ts +1 -0
  130. package/dist/modules/teleports/commands/deletetp.d.ts.map +1 -0
  131. package/dist/modules/teleports/commands/deletewaypoint.d.ts +1 -0
  132. package/dist/modules/teleports/commands/deletewaypoint.d.ts.map +1 -0
  133. package/dist/modules/teleports/commands/deletewaypoint.js +4 -35
  134. package/dist/modules/teleports/commands/deletewaypoint.js.map +1 -1
  135. package/dist/modules/teleports/commands/listwaypoints.d.ts +1 -0
  136. package/dist/modules/teleports/commands/listwaypoints.d.ts.map +1 -0
  137. package/dist/modules/teleports/commands/listwaypoints.js +3 -22
  138. package/dist/modules/teleports/commands/listwaypoints.js.map +1 -1
  139. package/dist/modules/teleports/commands/setprivate.d.ts +1 -0
  140. package/dist/modules/teleports/commands/setprivate.d.ts.map +1 -0
  141. package/dist/modules/teleports/commands/setpublic.d.ts +1 -0
  142. package/dist/modules/teleports/commands/setpublic.d.ts.map +1 -0
  143. package/dist/modules/teleports/commands/settp.d.ts +1 -0
  144. package/dist/modules/teleports/commands/settp.d.ts.map +1 -0
  145. package/dist/modules/teleports/commands/setwaypoint.d.ts +1 -0
  146. package/dist/modules/teleports/commands/setwaypoint.d.ts.map +1 -0
  147. package/dist/modules/teleports/commands/setwaypoint.js +5 -63
  148. package/dist/modules/teleports/commands/setwaypoint.js.map +1 -1
  149. package/dist/modules/teleports/commands/teleport.d.ts +1 -0
  150. package/dist/modules/teleports/commands/teleport.d.ts.map +1 -0
  151. package/dist/modules/teleports/commands/teleportwaypoint.d.ts +1 -0
  152. package/dist/modules/teleports/commands/teleportwaypoint.d.ts.map +1 -0
  153. package/dist/modules/teleports/commands/teleportwaypoint.js +7 -23
  154. package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -1
  155. package/dist/modules/teleports/commands/tplist.d.ts +1 -0
  156. package/dist/modules/teleports/commands/tplist.d.ts.map +1 -0
  157. package/dist/modules/teleports/cronJobs/Waypoint reconciler.d.ts +2 -0
  158. package/dist/modules/teleports/cronJobs/Waypoint reconciler.d.ts.map +1 -0
  159. package/dist/modules/teleports/cronJobs/Waypoint reconciler.js +6 -0
  160. package/dist/modules/teleports/cronJobs/Waypoint reconciler.js.map +1 -0
  161. package/dist/modules/teleports/functions/utils.d.ts +12 -0
  162. package/dist/modules/teleports/functions/utils.d.ts.map +1 -0
  163. package/dist/modules/teleports/functions/utils.js +117 -0
  164. package/dist/modules/teleports/functions/utils.js.map +1 -1
  165. package/dist/modules/teleports/index.d.ts +3 -2
  166. package/dist/modules/teleports/index.d.ts.map +1 -0
  167. package/dist/modules/teleports/index.js +188 -172
  168. package/dist/modules/teleports/index.js.map +1 -1
  169. package/dist/modules/timedShutdown/cronJobs/Shutdown.d.ts +1 -0
  170. package/dist/modules/timedShutdown/cronJobs/Shutdown.d.ts.map +1 -0
  171. package/dist/modules/timedShutdown/cronJobs/warning.d.ts +1 -0
  172. package/dist/modules/timedShutdown/cronJobs/warning.d.ts.map +1 -0
  173. package/dist/modules/timedShutdown/index.d.ts +3 -2
  174. package/dist/modules/timedShutdown/index.d.ts.map +1 -0
  175. package/dist/modules/timedShutdown/index.js +35 -27
  176. package/dist/modules/timedShutdown/index.js.map +1 -1
  177. package/dist/modules/utils/commands/help.d.ts +1 -0
  178. package/dist/modules/utils/commands/help.d.ts.map +1 -0
  179. package/dist/modules/utils/commands/help.js +10 -9
  180. package/dist/modules/utils/commands/help.js.map +1 -1
  181. package/dist/modules/utils/commands/ping.d.ts +1 -0
  182. package/dist/modules/utils/commands/ping.d.ts.map +1 -0
  183. package/dist/modules/utils/index.d.ts +3 -2
  184. package/dist/modules/utils/index.d.ts.map +1 -0
  185. package/dist/modules/utils/index.js +36 -28
  186. package/dist/modules/utils/index.js.map +1 -1
  187. package/dist/modules.json +601 -506
  188. package/package.json +2 -5
  189. package/scripts/buildBuiltinJson.ts +50 -2
  190. package/src/BuiltinModule.ts +25 -17
  191. package/src/__tests__/aliases.integration.test.ts +23 -26
  192. package/src/__tests__/bugRepros.integration.test.ts +261 -10
  193. package/src/__tests__/builtinmodule.unit.test.ts +3 -1
  194. package/src/__tests__/commandArgs.integration.test.ts +13 -6
  195. package/src/__tests__/economy/claim.integration.test.ts +1 -0
  196. package/src/__tests__/economy/economyUtils.integration.test.ts +43 -46
  197. package/src/__tests__/economy/shop.integration.test.ts +28 -4
  198. package/src/__tests__/economy/zombieKillReward.integration.test.ts +28 -31
  199. package/src/__tests__/geoblock.integration.test.ts +76 -91
  200. package/src/__tests__/gimme.integration.test.ts +25 -22
  201. package/src/__tests__/help.integration.test.ts +21 -20
  202. package/src/__tests__/lottery.integration.test.ts +15 -11
  203. package/src/__tests__/modulePermission.integration.test.ts +17 -13
  204. package/src/__tests__/onboarding.integration.test.ts +43 -43
  205. package/src/__tests__/ping.integration.test.ts +5 -4
  206. package/src/__tests__/roleExpiry.integration.test.ts +5 -4
  207. package/src/__tests__/serverMessages.integration.test.ts +24 -27
  208. package/src/__tests__/systemConfigCooldown.integration.test.ts +5 -1
  209. package/src/__tests__/systemConfigCost.integration.test.ts +16 -17
  210. package/src/__tests__/teleports/listtp.integration.test.ts +20 -21
  211. package/src/__tests__/teleports/publicteleports.integration.test.ts +58 -70
  212. package/src/__tests__/teleports/teleport.integration.test.ts +16 -17
  213. package/src/__tests__/teleports/tpManagement.integration.test.ts +21 -20
  214. package/src/__tests__/teleports/waypoints.integration.test.ts +52 -6
  215. package/src/dto/takaroEvents.ts +21 -0
  216. package/src/main.ts +14 -4
  217. package/src/modules/chatBridge/index.ts +54 -51
  218. package/src/modules/dailyRewards/commands/daily.js +118 -0
  219. package/src/modules/dailyRewards/commands/streak.js +42 -0
  220. package/src/modules/dailyRewards/commands/topstreak.js +54 -0
  221. package/src/modules/dailyRewards/functions/utils.js +36 -0
  222. package/src/modules/dailyRewards/hooks/dailyLoginCheck.js +24 -0
  223. package/src/modules/dailyRewards/index.ts +136 -0
  224. package/src/modules/economyUtils/index.ts +182 -179
  225. package/src/modules/geoBlock/hooks/IPDetected.js +4 -2
  226. package/src/modules/geoBlock/index.ts +72 -70
  227. package/src/modules/gimme/commands/gimme.js +16 -6
  228. package/src/modules/gimme/index.ts +62 -37
  229. package/src/modules/highPingKicker/index.ts +35 -32
  230. package/src/modules/lottery/index.ts +73 -71
  231. package/src/modules/playerOnboarding/commands/starterkit.js +19 -5
  232. package/src/modules/playerOnboarding/index.ts +72 -47
  233. package/src/modules/serverMessages/index.ts +36 -32
  234. package/src/modules/teleports/commands/deletewaypoint.js +4 -53
  235. package/src/modules/teleports/commands/listwaypoints.js +3 -35
  236. package/src/modules/teleports/commands/setwaypoint.js +5 -83
  237. package/src/modules/teleports/commands/teleportwaypoint.js +9 -36
  238. package/src/modules/teleports/cronJobs/Waypoint reconciler.js +7 -0
  239. package/src/modules/teleports/functions/utils.js +150 -0
  240. package/src/modules/teleports/index.ts +196 -180
  241. package/src/modules/timedShutdown/index.ts +35 -30
  242. package/src/modules/utils/commands/help.js +14 -14
  243. package/src/modules/utils/index.ts +36 -32
  244. package/tsconfig.json +1 -1
@@ -1,48 +1,73 @@
1
- import { BuiltinModule, ICommand } from '../../BuiltinModule.js';
1
+ import { ModuleTransferDTO, ICommand, ModuleTransferVersionDTO } from '../../BuiltinModule.js';
2
2
 
3
- export class Gimme extends BuiltinModule<Gimme> {
3
+ export class Gimme extends ModuleTransferDTO<Gimme> {
4
4
  constructor() {
5
- super(
6
- 'gimme',
7
- 'Randomly selects an item from a list of items.',
8
- JSON.stringify({
9
- $schema: 'http://json-schema.org/draft-07/schema#',
10
- type: 'object',
11
- properties: {
12
- items: {
13
- 'x-component': 'item',
14
- type: 'array',
15
- title: 'Items',
16
- description: 'List of items that a player can receive.',
17
- uniqueItems: true,
5
+ super();
6
+
7
+ this.name = 'gimme';
8
+ this.versions = [
9
+ new ModuleTransferVersionDTO({
10
+ tag: '0.0.1',
11
+ description: 'Randomly selects item from a list of items and entities.',
12
+ configSchema: JSON.stringify({
13
+ $schema: 'http://json-schema.org/draft-07/schema#',
14
+ type: 'object',
15
+ properties: {
18
16
  items: {
19
- type: 'string',
17
+ 'x-component': 'item',
18
+ type: 'array',
19
+ title: 'Items',
20
+ description: 'List of items that a player can receive.',
21
+ uniqueItems: true,
22
+ items: {
23
+ type: 'object',
24
+ title: 'Item',
25
+ properties: {
26
+ item: {
27
+ type: 'string',
28
+ title: 'Item',
29
+ },
30
+ amount: {
31
+ type: 'number',
32
+ title: 'Amount',
33
+ },
34
+ quality: {
35
+ type: 'string',
36
+ title: 'Quality',
37
+ },
38
+ },
39
+ },
40
+ },
41
+ commands: {
42
+ title: 'Commands',
43
+ type: 'array',
44
+ default: ['say hello from gimme'],
45
+ items: {
46
+ type: 'string',
47
+ },
20
48
  },
21
49
  },
22
- commands: {
23
- title: 'Commands',
24
- type: 'array',
25
- default: ['say hello from gimme'],
50
+ required: ['items'],
51
+ additionalProperties: false,
52
+ }),
53
+ uiSchema: JSON.stringify({
54
+ items: {
26
55
  items: {
27
- type: 'string',
56
+ item: {
57
+ 'ui:widget': 'item',
58
+ },
28
59
  },
29
60
  },
30
- },
31
- required: ['items'],
32
- additionalProperties: false,
33
- }),
34
- JSON.stringify({
35
- items: { 'ui:widget': 'item' },
36
- }),
37
- );
38
-
39
- this.commands = [
40
- new ICommand({
41
- function: this.loadFn('commands', 'gimme'),
42
- name: 'gimme',
43
- trigger: 'gimme',
44
- helpText: 'Randomly selects item from a list of items and entities.',
45
- arguments: [],
61
+ }),
62
+ commands: [
63
+ new ICommand({
64
+ function: this.loadFn('commands', 'gimme'),
65
+ name: 'gimme',
66
+ trigger: 'gimme',
67
+ helpText: 'Randomly selects item from a list of items and entities.',
68
+ arguments: [],
69
+ }),
70
+ ],
46
71
  }),
47
72
  ];
48
73
  }
@@ -1,38 +1,41 @@
1
- import { BuiltinModule, ICronJob } from '../../BuiltinModule.js';
1
+ import { ModuleTransferDTO, ICronJob, ModuleTransferVersionDTO } from '../../BuiltinModule.js';
2
2
 
3
- export class HighPingKicker extends BuiltinModule<HighPingKicker> {
3
+ export class HighPingKicker extends ModuleTransferDTO<HighPingKicker> {
4
4
  constructor() {
5
- super(
6
- 'highPingKicker',
7
- 'Automatically kick players with high ping, with warnings and configurable thresholds.',
8
- JSON.stringify({
9
- $schema: 'http://json-schema.org/draft-07/schema#',
10
- type: 'object',
11
- properties: {
12
- pingThreshold: {
13
- type: 'number',
14
- title: 'Ping threshold',
15
- description: 'A ping value that is deemed too high and prompts a warning.',
16
- default: 200,
17
- minimum: 0,
5
+ super();
6
+ this.name = 'highPingKicker';
7
+ this.versions = [
8
+ new ModuleTransferVersionDTO({
9
+ tag: '0.0.1',
10
+ description: 'Automatically kick players with high ping, with warnings and configurable thresholds.',
11
+ configSchema: JSON.stringify({
12
+ $schema: 'http://json-schema.org/draft-07/schema#',
13
+ type: 'object',
14
+ properties: {
15
+ pingThreshold: {
16
+ type: 'number',
17
+ title: 'Ping threshold',
18
+ description: 'A ping value that is deemed too high and prompts a warning.',
19
+ default: 200,
20
+ minimum: 0,
21
+ },
22
+ warningsBeforeKick: {
23
+ type: 'number',
24
+ title: 'Kick warnings',
25
+ description: 'Number of warnings before a player is kicked.',
26
+ default: 3,
27
+ minimum: 0,
28
+ },
18
29
  },
19
- warningsBeforeKick: {
20
- type: 'number',
21
- title: 'Kick warnings',
22
- description: 'Number of warnings before a player is kicked.',
23
- default: 3,
24
- minimum: 0,
25
- },
26
- },
27
- required: [],
28
- }),
29
- );
30
-
31
- this.cronJobs = [
32
- new ICronJob({
33
- name: 'Ping check',
34
- temporalValue: '*/5 * * * *',
35
- function: this.loadFn('cronJobs', 'Ping check'),
30
+ required: [],
31
+ }),
32
+ cronJobs: [
33
+ new ICronJob({
34
+ name: 'Ping check',
35
+ temporalValue: '*/5 * * * *',
36
+ function: this.loadFn('cronJobs', 'Ping check'),
37
+ }),
38
+ ],
36
39
  }),
37
40
  ];
38
41
  }
@@ -1,79 +1,81 @@
1
- import { BuiltinModule, ICommand, ICronJob, IPermission } from '../../BuiltinModule.js';
1
+ import { ModuleTransferDTO, ICommand, ICronJob, IPermission, ModuleTransferVersionDTO } from '../../BuiltinModule.js';
2
2
 
3
- export class Lottery extends BuiltinModule<Lottery> {
3
+ export class Lottery extends ModuleTransferDTO<Lottery> {
4
4
  constructor() {
5
- super(
6
- 'lottery',
7
- 'Players can buy tickets for a lottery, and the winner is chosen at random.',
8
- JSON.stringify({
9
- $schema: 'http://json-schema.org/draft-07/schema#',
10
- type: 'object',
11
- properties: {
12
- profitMargin: {
13
- type: 'number',
14
- maximum: 1,
15
- minimum: 0,
16
- description: 'The profit margin the server takes from the lottery.',
17
- default: 0.1,
18
- },
19
- },
20
- required: [],
21
- additionalProperties: false,
22
- }),
23
- );
5
+ super();
24
6
 
25
- this.permissions = [
26
- new IPermission({
27
- permission: 'LOTTERY_BUY',
28
- friendlyName: 'Buy Lottery Tickets',
29
- canHaveCount: false,
30
- description: 'Allows the player to buy lottery tickets.',
31
- }),
32
- new IPermission({
33
- permission: 'LOTTERY_VIEW_TICKETS',
34
- friendlyName: 'View Lottery Tickets',
35
- description: 'Allows the player to view his lottery tickets.',
36
- canHaveCount: false,
37
- }),
38
- ];
39
-
40
- this.cronJobs = [
41
- new ICronJob({
42
- name: 'drawLottery',
43
- temporalValue: '0 0 * * *',
44
- function: this.loadFn('cronJobs', 'drawLottery'),
45
- }),
46
- ];
47
-
48
- this.commands = [
49
- new ICommand({
50
- function: this.loadFn('commands', 'buyTicket'),
51
- name: 'buyTicket',
52
- trigger: 'buyTicket',
53
- helpText: 'Buy a lottery ticket.',
54
- arguments: [
55
- {
56
- name: 'amount',
57
- type: 'number',
58
- helpText: 'The amount of tickets to buy.',
59
- position: 0,
60
- defaultValue: null,
7
+ this.name = 'lottery';
8
+ this.versions = [
9
+ new ModuleTransferVersionDTO({
10
+ tag: '0.0.1',
11
+ description: 'Players can buy tickets for a lottery, and the winner is chosen at random.',
12
+ configSchema: JSON.stringify({
13
+ $schema: 'http://json-schema.org/draft-07/schema#',
14
+ type: 'object',
15
+ properties: {
16
+ profitMargin: {
17
+ type: 'number',
18
+ maximum: 1,
19
+ minimum: 0,
20
+ description: 'The profit margin the server takes from the lottery.',
21
+ default: 0.1,
22
+ },
61
23
  },
24
+ required: [],
25
+ additionalProperties: false,
26
+ }),
27
+ permissions: [
28
+ new IPermission({
29
+ permission: 'LOTTERY_BUY',
30
+ friendlyName: 'Buy Lottery Tickets',
31
+ canHaveCount: false,
32
+ description: 'Allows the player to buy lottery tickets.',
33
+ }),
34
+ new IPermission({
35
+ permission: 'LOTTERY_VIEW_TICKETS',
36
+ friendlyName: 'View Lottery Tickets',
37
+ description: 'Allows the player to view his lottery tickets.',
38
+ canHaveCount: false,
39
+ }),
40
+ ],
41
+ cronJobs: [
42
+ new ICronJob({
43
+ name: 'drawLottery',
44
+ temporalValue: '0 0 * * *',
45
+ function: this.loadFn('cronJobs', 'drawLottery'),
46
+ }),
47
+ ],
48
+ commands: [
49
+ new ICommand({
50
+ function: this.loadFn('commands', 'buyTicket'),
51
+ name: 'buyTicket',
52
+ trigger: 'buyTicket',
53
+ helpText: 'Buy a lottery ticket.',
54
+ arguments: [
55
+ {
56
+ name: 'amount',
57
+ type: 'number',
58
+ helpText: 'The amount of tickets to buy.',
59
+ position: 0,
60
+ defaultValue: null,
61
+ },
62
+ ],
63
+ }),
64
+ new ICommand({
65
+ function: this.loadFn('commands', 'viewTickets'),
66
+ name: 'viewTickets',
67
+ trigger: 'viewTickets',
68
+ helpText: 'View your lottery tickets.',
69
+ arguments: [],
70
+ }),
71
+ new ICommand({
72
+ function: this.loadFn('commands', 'nextDraw'),
73
+ name: 'nextDraw',
74
+ trigger: 'nextDraw',
75
+ helpText: 'View when the next draw is.',
76
+ arguments: [],
77
+ }),
62
78
  ],
63
- }),
64
- new ICommand({
65
- function: this.loadFn('commands', 'viewTickets'),
66
- name: 'viewTickets',
67
- trigger: 'viewTickets',
68
- helpText: 'View your lottery tickets.',
69
- arguments: [],
70
- }),
71
- new ICommand({
72
- function: this.loadFn('commands', 'nextDraw'),
73
- name: 'nextDraw',
74
- trigger: 'nextDraw',
75
- helpText: 'View when the next draw is.',
76
- arguments: [],
77
79
  }),
78
80
  ];
79
81
  }
@@ -7,7 +7,7 @@ async function main() {
7
7
 
8
8
  if (!items || items.length === 0) {
9
9
  throw new TakaroUserError(
10
- 'No starter kit items configured. Please ask your server administrator to configure this.'
10
+ 'No starter kit items configured. Please ask your server administrator to configure this.',
11
11
  );
12
12
  }
13
13
 
@@ -25,13 +25,27 @@ async function main() {
25
25
 
26
26
  await data.player.pm('You are about to receive your starter kit...');
27
27
 
28
+ const itemRecords = (await takaro.item.itemControllerSearch({ filters: { id: items.map((_) => _.item) } })).data.data;
29
+ const fullItems = items.map((item) => {
30
+ const itemRecord = itemRecords.find((record) => record.id === item.item);
31
+ if (!itemRecord) {
32
+ throw new TakaroUserError(`Item with ID ${item.item} not found.`);
33
+ }
34
+ return {
35
+ code: itemRecord.code,
36
+ quality: item.quality,
37
+ amount: item.amount,
38
+ };
39
+ });
40
+
28
41
  await Promise.all(
29
- items.map(async (item) => {
42
+ fullItems.map(async (item) => {
30
43
  return takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {
31
- name: item,
32
- amount: 1,
44
+ name: item.code,
45
+ quality: item.quality ?? '',
46
+ amount: item.amount,
33
47
  });
34
- })
48
+ }),
35
49
  );
36
50
 
37
51
  await takaro.variable.variableControllerCreate({
@@ -1,58 +1,83 @@
1
- import { BuiltinModule, ICommand, IHook } from '../../BuiltinModule.js';
1
+ import { ModuleTransferDTO, ICommand, IHook, ModuleTransferVersionDTO } from '../../BuiltinModule.js';
2
2
  import { HookEvents } from '../../dto/index.js';
3
3
 
4
- export class PlayerOnboarding extends BuiltinModule<PlayerOnboarding> {
4
+ export class PlayerOnboarding extends ModuleTransferDTO<PlayerOnboarding> {
5
5
  constructor() {
6
- super(
7
- 'playerOnboarding',
8
- 'Collection of functions that are executed when a player joins the server. Helps with onboarding new players, like sending a welcome message.',
9
- JSON.stringify({
10
- $schema: 'http://json-schema.org/draft-07/schema#',
11
- type: 'object',
12
- properties: {
13
- message: {
14
- title: 'Message',
15
- description: 'The message to send to the player when they join the server.',
16
- type: 'string',
17
- minLength: 1,
18
- maxLength: 256,
19
- default: 'Welcome {player} to the server!',
6
+ super();
7
+
8
+ this.name = 'playerOnboarding';
9
+ this.versions = [
10
+ new ModuleTransferVersionDTO({
11
+ tag: '0.0.1',
12
+ description:
13
+ 'Collection of functions that are executed when a player joins the server. Helps with onboarding new players, like sending a welcome message.',
14
+ configSchema: JSON.stringify({
15
+ $schema: 'http://json-schema.org/draft-07/schema#',
16
+ type: 'object',
17
+ properties: {
18
+ message: {
19
+ title: 'Message',
20
+ description: 'The message to send to the player when they join the server.',
21
+ type: 'string',
22
+ minLength: 1,
23
+ maxLength: 256,
24
+ default: 'Welcome {player} to the server!',
25
+ },
26
+ starterKitItems: {
27
+ type: 'array',
28
+ title: 'Starter kit items',
29
+ 'x-component': 'item',
30
+ description:
31
+ 'List of items a player will receive when they execute the starterkit command for the first time.',
32
+ uniqueItems: true,
33
+ items: {
34
+ type: 'object',
35
+ title: 'Item',
36
+ properties: {
37
+ item: {
38
+ type: 'string',
39
+ title: 'Item',
40
+ },
41
+ amount: {
42
+ type: 'number',
43
+ title: 'Amount',
44
+ },
45
+ quality: {
46
+ type: 'string',
47
+ title: 'Quality',
48
+ },
49
+ },
50
+ },
51
+ },
20
52
  },
53
+ required: [],
54
+ additionalProperties: false,
55
+ }),
56
+ uiSchema: JSON.stringify({
21
57
  starterKitItems: {
22
- type: 'array',
23
- 'x-component': 'item',
24
- title: 'Starter kit items',
25
- description:
26
- 'List of items a player will receive when they execute the starterkit command for the first time.',
27
- uniqueItems: true,
28
58
  items: {
29
- type: 'string',
59
+ item: {
60
+ 'ui:widget': 'item',
61
+ },
30
62
  },
31
63
  },
32
- },
33
- required: [],
34
- additionalProperties: false,
35
- }),
36
- JSON.stringify({
37
- starterKitItems: { 'ui:widget': 'item' },
38
- }),
39
- );
40
-
41
- this.hooks = [
42
- new IHook({
43
- eventType: HookEvents.PLAYER_CONNECTED,
44
- name: 'playerConnected',
45
- function: this.loadFn('hooks', 'playerConnected'),
46
- }),
47
- ];
48
-
49
- this.commands = [
50
- new ICommand({
51
- name: 'starterkit',
52
- function: this.loadFn('commands', 'starterkit'),
53
- trigger: 'starterkit',
54
- helpText: 'Get a starter kit, you can only execute this once on a server!',
55
- arguments: [],
64
+ }),
65
+ hooks: [
66
+ new IHook({
67
+ eventType: HookEvents.PLAYER_CONNECTED,
68
+ name: 'playerConnected',
69
+ function: this.loadFn('hooks', 'playerConnected'),
70
+ }),
71
+ ],
72
+ commands: [
73
+ new ICommand({
74
+ name: 'starterkit',
75
+ function: this.loadFn('commands', 'starterkit'),
76
+ trigger: 'starterkit',
77
+ helpText: 'Get a starter kit, you can only execute this once on a server!',
78
+ arguments: [],
79
+ }),
80
+ ],
56
81
  }),
57
82
  ];
58
83
  }
@@ -1,39 +1,43 @@
1
- import { BuiltinModule, ICronJob } from '../../BuiltinModule.js';
1
+ import { ModuleTransferDTO, ICronJob, ModuleTransferVersionDTO } from '../../BuiltinModule.js';
2
2
 
3
- export class ServerMessages extends BuiltinModule<ServerMessages> {
3
+ export class ServerMessages extends ModuleTransferDTO<ServerMessages> {
4
4
  constructor() {
5
- super(
6
- 'serverMessages',
7
- 'Send automated, rotated, configurable messages to players on the server.',
8
- JSON.stringify({
9
- $schema: 'http://json-schema.org/draft-07/schema#',
10
- type: 'object',
11
- properties: {
12
- messages: {
13
- type: 'array',
14
- title: 'Messages',
15
- description: 'List of messages that will be sent to players on the server.',
16
- default: [
17
- // prettier-ignore
18
- 'This is an automated message, don\'t forget to read the server rules!',
19
- ],
20
- items: {
21
- type: 'string',
22
- minLength: 5,
23
- maxLength: 1024,
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
- required: ['messages'],
29
- }),
30
- );
31
-
32
- this.cronJobs = [
33
- new ICronJob({
34
- name: 'Automated message',
35
- temporalValue: '*/30 * * * *',
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: [waypointsInstallation.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