@takaro/modules 0.0.1

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 (227) hide show
  1. package/README.md +3 -0
  2. package/dist/BuiltinModule.d.ts +49 -0
  3. package/dist/BuiltinModule.js +194 -0
  4. package/dist/BuiltinModule.js.map +1 -0
  5. package/dist/dto/base.d.ts +6 -0
  6. package/dist/dto/base.js +28 -0
  7. package/dist/dto/base.js.map +1 -0
  8. package/dist/dto/discordEvents.d.ts +31 -0
  9. package/dist/dto/discordEvents.js +92 -0
  10. package/dist/dto/discordEvents.js.map +1 -0
  11. package/dist/dto/gameEvents.d.ts +84 -0
  12. package/dist/dto/gameEvents.js +190 -0
  13. package/dist/dto/gameEvents.js.map +1 -0
  14. package/dist/dto/index.d.ts +37 -0
  15. package/dist/dto/index.js +18 -0
  16. package/dist/dto/index.js.map +1 -0
  17. package/dist/dto/takaroEvents.d.ts +150 -0
  18. package/dist/dto/takaroEvents.js +422 -0
  19. package/dist/dto/takaroEvents.js.map +1 -0
  20. package/dist/main.d.ts +4 -0
  21. package/dist/main.js +31 -0
  22. package/dist/main.js.map +1 -0
  23. package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts +1 -0
  24. package/dist/modules/chatBridge/hooks/DiscordToGame.js +18 -0
  25. package/dist/modules/chatBridge/hooks/DiscordToGame.js.map +1 -0
  26. package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts +1 -0
  27. package/dist/modules/chatBridge/hooks/GameToDiscord.js +14 -0
  28. package/dist/modules/chatBridge/hooks/GameToDiscord.js.map +1 -0
  29. package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts +1 -0
  30. package/dist/modules/chatBridge/hooks/PlayerConnected.js +9 -0
  31. package/dist/modules/chatBridge/hooks/PlayerConnected.js.map +1 -0
  32. package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts +1 -0
  33. package/dist/modules/chatBridge/hooks/PlayerDisconnected.js +9 -0
  34. package/dist/modules/chatBridge/hooks/PlayerDisconnected.js.map +1 -0
  35. package/dist/modules/chatBridge/index.d.ts +4 -0
  36. package/dist/modules/chatBridge/index.js +54 -0
  37. package/dist/modules/chatBridge/index.js.map +1 -0
  38. package/dist/modules/economyUtils/commands/balance.d.ts +1 -0
  39. package/dist/modules/economyUtils/commands/balance.js +7 -0
  40. package/dist/modules/economyUtils/commands/balance.js.map +1 -0
  41. package/dist/modules/economyUtils/commands/confirmTransfer.d.ts +1 -0
  42. package/dist/modules/economyUtils/commands/confirmTransfer.js +38 -0
  43. package/dist/modules/economyUtils/commands/confirmTransfer.js.map +1 -0
  44. package/dist/modules/economyUtils/commands/grantCurrency.d.ts +1 -0
  45. package/dist/modules/economyUtils/commands/grantCurrency.js +31 -0
  46. package/dist/modules/economyUtils/commands/grantCurrency.js.map +1 -0
  47. package/dist/modules/economyUtils/commands/revokeCurrency.d.ts +1 -0
  48. package/dist/modules/economyUtils/commands/revokeCurrency.js +31 -0
  49. package/dist/modules/economyUtils/commands/revokeCurrency.js.map +1 -0
  50. package/dist/modules/economyUtils/commands/topCurrency.d.ts +1 -0
  51. package/dist/modules/economyUtils/commands/topCurrency.js +22 -0
  52. package/dist/modules/economyUtils/commands/topCurrency.js.map +1 -0
  53. package/dist/modules/economyUtils/commands/transfer.d.ts +1 -0
  54. package/dist/modules/economyUtils/commands/transfer.js +55 -0
  55. package/dist/modules/economyUtils/commands/transfer.js.map +1 -0
  56. package/dist/modules/economyUtils/index.d.ts +4 -0
  57. package/dist/modules/economyUtils/index.js +117 -0
  58. package/dist/modules/economyUtils/index.js.map +1 -0
  59. package/dist/modules/geoBlock/hooks/IPDetected.d.ts +1 -0
  60. package/dist/modules/geoBlock/hooks/IPDetected.js +50 -0
  61. package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -0
  62. package/dist/modules/geoBlock/index.d.ts +8 -0
  63. package/dist/modules/geoBlock/index.js +321 -0
  64. package/dist/modules/geoBlock/index.js.map +1 -0
  65. package/dist/modules/gimme/commands/gimme.d.ts +1 -0
  66. package/dist/modules/gimme/commands/gimme.js +23 -0
  67. package/dist/modules/gimme/commands/gimme.js.map +1 -0
  68. package/dist/modules/gimme/index.d.ts +4 -0
  69. package/dist/modules/gimme/index.js +43 -0
  70. package/dist/modules/gimme/index.js.map +1 -0
  71. package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts +1 -0
  72. package/dist/modules/highPingKicker/cronJobs/Ping check.js +54 -0
  73. package/dist/modules/highPingKicker/cronJobs/Ping check.js.map +1 -0
  74. package/dist/modules/highPingKicker/index.d.ts +4 -0
  75. package/dist/modules/highPingKicker/index.js +34 -0
  76. package/dist/modules/highPingKicker/index.js.map +1 -0
  77. package/dist/modules/lottery/commands/buyTicket.d.ts +1 -0
  78. package/dist/modules/lottery/commands/buyTicket.js +54 -0
  79. package/dist/modules/lottery/commands/buyTicket.js.map +1 -0
  80. package/dist/modules/lottery/commands/nextDraw.d.ts +1 -0
  81. package/dist/modules/lottery/commands/nextDraw.js +34 -0
  82. package/dist/modules/lottery/commands/nextDraw.js.map +1 -0
  83. package/dist/modules/lottery/commands/viewTickets.d.ts +1 -0
  84. package/dist/modules/lottery/commands/viewTickets.js +23 -0
  85. package/dist/modules/lottery/commands/viewTickets.js.map +1 -0
  86. package/dist/modules/lottery/cronJobs/drawLottery.d.ts +1 -0
  87. package/dist/modules/lottery/cronJobs/drawLottery.js +96 -0
  88. package/dist/modules/lottery/cronJobs/drawLottery.js.map +1 -0
  89. package/dist/modules/lottery/index.d.ts +4 -0
  90. package/dist/modules/lottery/index.js +73 -0
  91. package/dist/modules/lottery/index.js.map +1 -0
  92. package/dist/modules/playerOnboarding/commands/starterkit.d.ts +1 -0
  93. package/dist/modules/playerOnboarding/commands/starterkit.js +34 -0
  94. package/dist/modules/playerOnboarding/commands/starterkit.js.map +1 -0
  95. package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts +1 -0
  96. package/dist/modules/playerOnboarding/hooks/playerConnected.js +11 -0
  97. package/dist/modules/playerOnboarding/hooks/playerConnected.js.map +1 -0
  98. package/dist/modules/playerOnboarding/index.d.ts +4 -0
  99. package/dist/modules/playerOnboarding/index.js +51 -0
  100. package/dist/modules/playerOnboarding/index.js.map +1 -0
  101. package/dist/modules/serverMessages/cronJobs/Automated message.d.ts +1 -0
  102. package/dist/modules/serverMessages/cronJobs/Automated message.js +9 -0
  103. package/dist/modules/serverMessages/cronJobs/Automated message.js.map +1 -0
  104. package/dist/modules/serverMessages/index.d.ts +4 -0
  105. package/dist/modules/serverMessages/index.js +35 -0
  106. package/dist/modules/serverMessages/index.js.map +1 -0
  107. package/dist/modules/teleports/commands/deletetp.d.ts +1 -0
  108. package/dist/modules/teleports/commands/deletetp.js +20 -0
  109. package/dist/modules/teleports/commands/deletetp.js.map +1 -0
  110. package/dist/modules/teleports/commands/deletewaypoint.d.ts +1 -0
  111. package/dist/modules/teleports/commands/deletewaypoint.js +54 -0
  112. package/dist/modules/teleports/commands/deletewaypoint.js.map +1 -0
  113. package/dist/modules/teleports/commands/listwaypoints.d.ts +1 -0
  114. package/dist/modules/teleports/commands/listwaypoints.js +36 -0
  115. package/dist/modules/teleports/commands/listwaypoints.js.map +1 -0
  116. package/dist/modules/teleports/commands/setprivate.d.ts +1 -0
  117. package/dist/modules/teleports/commands/setprivate.js +31 -0
  118. package/dist/modules/teleports/commands/setprivate.js.map +1 -0
  119. package/dist/modules/teleports/commands/setpublic.d.ts +1 -0
  120. package/dist/modules/teleports/commands/setpublic.js +55 -0
  121. package/dist/modules/teleports/commands/setpublic.js.map +1 -0
  122. package/dist/modules/teleports/commands/settp.d.ts +1 -0
  123. package/dist/modules/teleports/commands/settp.js +42 -0
  124. package/dist/modules/teleports/commands/settp.js.map +1 -0
  125. package/dist/modules/teleports/commands/setwaypoint.d.ts +1 -0
  126. package/dist/modules/teleports/commands/setwaypoint.js +88 -0
  127. package/dist/modules/teleports/commands/setwaypoint.js.map +1 -0
  128. package/dist/modules/teleports/commands/teleport.d.ts +1 -0
  129. package/dist/modules/teleports/commands/teleport.js +74 -0
  130. package/dist/modules/teleports/commands/teleport.js.map +1 -0
  131. package/dist/modules/teleports/commands/teleportwaypoint.d.ts +1 -0
  132. package/dist/modules/teleports/commands/teleportwaypoint.js +50 -0
  133. package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -0
  134. package/dist/modules/teleports/commands/tplist.d.ts +1 -0
  135. package/dist/modules/teleports/commands/tplist.js +45 -0
  136. package/dist/modules/teleports/commands/tplist.js.map +1 -0
  137. package/dist/modules/teleports/functions/utils.d.ts +2 -0
  138. package/dist/modules/teleports/functions/utils.js +18 -0
  139. package/dist/modules/teleports/functions/utils.js.map +1 -0
  140. package/dist/modules/teleports/index.d.ts +4 -0
  141. package/dist/modules/teleports/index.js +184 -0
  142. package/dist/modules/teleports/index.js.map +1 -0
  143. package/dist/modules/utils/commands/help.d.ts +1 -0
  144. package/dist/modules/utils/commands/help.js +29 -0
  145. package/dist/modules/utils/commands/help.js.map +1 -0
  146. package/dist/modules/utils/commands/ping.d.ts +1 -0
  147. package/dist/modules/utils/commands/ping.js +6 -0
  148. package/dist/modules/utils/commands/ping.js.map +1 -0
  149. package/dist/modules/utils/index.d.ts +4 -0
  150. package/dist/modules/utils/index.js +35 -0
  151. package/dist/modules/utils/index.js.map +1 -0
  152. package/dist/modules.json +478 -0
  153. package/package.json +26 -0
  154. package/scripts/buildBuiltinJson.ts +14 -0
  155. package/src/BuiltinModule.ts +125 -0
  156. package/src/__tests__/aliases.integration.test.ts +54 -0
  157. package/src/__tests__/builtinmodule.unit.test.ts +13 -0
  158. package/src/__tests__/commandArgs.integration.test.ts +285 -0
  159. package/src/__tests__/economyUtils.integration.test.ts +488 -0
  160. package/src/__tests__/geoblock.integration.test.ts +380 -0
  161. package/src/__tests__/gimme.integration.test.ts +97 -0
  162. package/src/__tests__/help.integration.test.ts +133 -0
  163. package/src/__tests__/lottery.integration.test.ts +332 -0
  164. package/src/__tests__/modulePermission.integration.test.ts +192 -0
  165. package/src/__tests__/onboarding.integration.test.ts +123 -0
  166. package/src/__tests__/ping.integration.test.ts +36 -0
  167. package/src/__tests__/roleExpiry.integration.test.ts +74 -0
  168. package/src/__tests__/serverMessages.integration.test.ts +104 -0
  169. package/src/__tests__/systemConfigCost.integration.test.ts +196 -0
  170. package/src/__tests__/teleports/listtp.integration.test.ts +115 -0
  171. package/src/__tests__/teleports/publicteleports.integration.test.ts +350 -0
  172. package/src/__tests__/teleports/teleport.integration.test.ts +109 -0
  173. package/src/__tests__/teleports/tpManagement.integration.test.ts +175 -0
  174. package/src/__tests__/teleports/waypoints.integration.test.ts +613 -0
  175. package/src/dto/base.ts +13 -0
  176. package/src/dto/discordEvents.ts +69 -0
  177. package/src/dto/gameEvents.ts +154 -0
  178. package/src/dto/index.ts +25 -0
  179. package/src/dto/takaroEvents.ts +290 -0
  180. package/src/main.ts +36 -0
  181. package/src/modules/.eslintrc +5 -0
  182. package/src/modules/chatBridge/hooks/DiscordToGame.js +18 -0
  183. package/src/modules/chatBridge/hooks/GameToDiscord.js +18 -0
  184. package/src/modules/chatBridge/hooks/PlayerConnected.js +11 -0
  185. package/src/modules/chatBridge/hooks/PlayerDisconnected.js +11 -0
  186. package/src/modules/chatBridge/index.ts +59 -0
  187. package/src/modules/economyUtils/commands/balance.js +8 -0
  188. package/src/modules/economyUtils/commands/confirmTransfer.js +55 -0
  189. package/src/modules/economyUtils/commands/grantCurrency.js +38 -0
  190. package/src/modules/economyUtils/commands/revokeCurrency.js +38 -0
  191. package/src/modules/economyUtils/commands/topCurrency.js +29 -0
  192. package/src/modules/economyUtils/commands/transfer.js +73 -0
  193. package/src/modules/economyUtils/index.ts +125 -0
  194. package/src/modules/geoBlock/hooks/IPDetected.js +52 -0
  195. package/src/modules/geoBlock/index.ts +331 -0
  196. package/src/modules/gimme/commands/gimme.js +28 -0
  197. package/src/modules/gimme/index.ts +49 -0
  198. package/src/modules/highPingKicker/cronJobs/Ping check.js +66 -0
  199. package/src/modules/highPingKicker/index.ts +39 -0
  200. package/src/modules/lottery/commands/buyTicket.js +68 -0
  201. package/src/modules/lottery/commands/nextDraw.js +45 -0
  202. package/src/modules/lottery/commands/viewTickets.js +32 -0
  203. package/src/modules/lottery/cronJobs/drawLottery.js +124 -0
  204. package/src/modules/lottery/index.ts +80 -0
  205. package/src/modules/playerOnboarding/commands/starterkit.js +47 -0
  206. package/src/modules/playerOnboarding/hooks/playerConnected.js +14 -0
  207. package/src/modules/playerOnboarding/index.ts +58 -0
  208. package/src/modules/serverMessages/cronJobs/Automated message.js +12 -0
  209. package/src/modules/serverMessages/index.ts +40 -0
  210. package/src/modules/teleports/commands/deletetp.js +25 -0
  211. package/src/modules/teleports/commands/deletewaypoint.js +77 -0
  212. package/src/modules/teleports/commands/listwaypoints.js +55 -0
  213. package/src/modules/teleports/commands/setprivate.js +39 -0
  214. package/src/modules/teleports/commands/setpublic.js +71 -0
  215. package/src/modules/teleports/commands/settp.js +54 -0
  216. package/src/modules/teleports/commands/setwaypoint.js +112 -0
  217. package/src/modules/teleports/commands/teleport.js +93 -0
  218. package/src/modules/teleports/commands/teleportwaypoint.js +72 -0
  219. package/src/modules/teleports/commands/tplist.js +61 -0
  220. package/src/modules/teleports/functions/utils.js +20 -0
  221. package/src/modules/teleports/index.ts +193 -0
  222. package/src/modules/utils/commands/help.js +38 -0
  223. package/src/modules/utils/commands/ping.js +7 -0
  224. package/src/modules/utils/index.ts +40 -0
  225. package/tsconfig.build.json +10 -0
  226. package/tsconfig.json +9 -0
  227. package/typedoc.json +3 -0
@@ -0,0 +1,34 @@
1
+ import { nextCronJobRun, data } from '@takaro/helpers';
2
+ function formatTimeToReach(cronJob) {
3
+ const targetDate = nextCronJobRun(cronJob);
4
+ // Get the current date and time
5
+ const currentDate = new Date();
6
+ // Calculate the time difference in milliseconds
7
+ const delta = targetDate - currentDate;
8
+ // Calculate days, hours, minutes, and seconds
9
+ const days = Math.floor(delta / (1000 * 60 * 60 * 24));
10
+ const hours = Math.floor((delta % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
11
+ const minutes = Math.floor((delta % (1000 * 60 * 60)) / (1000 * 60));
12
+ const seconds = Math.floor((delta % (1000 * 60)) / 1000);
13
+ // Build the formatted string
14
+ let formattedString = '';
15
+ if (days > 0) {
16
+ formattedString += `${days} day${days > 1 ? 's' : ''} `;
17
+ }
18
+ if (hours > 0) {
19
+ formattedString += `${hours} hour${hours > 1 ? 's' : ''} `;
20
+ }
21
+ if (minutes > 0) {
22
+ formattedString += `${minutes} minute${minutes > 1 ? 's' : ''} `;
23
+ }
24
+ if (seconds > 0) {
25
+ formattedString += `${seconds} second${seconds > 1 ? 's' : ''} `;
26
+ }
27
+ return formattedString.trim();
28
+ }
29
+ async function main() {
30
+ const { player, module: mod } = data;
31
+ await player.pm(`The next lottery draw is in about ${formatTimeToReach(mod.systemConfig.cronJobs.drawLottery)}`);
32
+ }
33
+ await main();
34
+ //# sourceMappingURL=nextDraw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextDraw.js","sourceRoot":"","sources":["../../../../src/modules/lottery/commands/nextDraw.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvD,SAAS,iBAAiB,CAAC,OAAO;IAChC,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAE3C,gCAAgC;IAChC,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAE/B,gDAAgD;IAChD,MAAM,KAAK,GAAG,UAAU,GAAG,WAAW,CAAC;IAEvC,8CAA8C;IAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CA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;IACrC,MAAM,MAAM,CAAC,EAAE,CAAC,qCAAqC,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;AACnH,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';
2
+ async function main() {
3
+ const { pog, gameServerId, module: mod } = data;
4
+ const varKey = 'lottery_tickets_bought';
5
+ if (!checkPermission(pog, 'LOTTERY_VIEW_TICKETS')) {
6
+ throw new TakaroUserError('You do not have permission to view lottery tickets.');
7
+ }
8
+ const tickets = (await takaro.variable.variableControllerSearch({
9
+ filters: {
10
+ gameServerId,
11
+ key: varKey,
12
+ moduleId: mod.id,
13
+ playerId: pog.playerId,
14
+ },
15
+ })).data.data;
16
+ let ticketsBought = 0;
17
+ if (tickets.length === 1) {
18
+ ticketsBought = parseInt(JSON.parse(tickets[0].value).amount, 10);
19
+ }
20
+ await pog.pm(`You have bought ${ticketsBought} tickets.`);
21
+ }
22
+ await main();
23
+ //# sourceMappingURL=viewTickets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewTickets.js","sourceRoot":"","sources":["../../../../src/modules/lottery/commands/viewTickets.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEjF,KAAK,UAAU,IAAI;IACjB,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAEhD,MAAM,MAAM,GAAG,wBAAwB,CAAC;IAExC,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,sBAAsB,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,eAAe,CAAC,qDAAqD,CAAC,CAAC;IACnF,CAAC;IAED,MAAM,OAAO,GAAG,CACd,MAAM,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QAC7C,OAAO,EAAE;YACP,YAAY;YACZ,GAAG,EAAE,MAAM;YACX,QAAQ,EAAE,GAAG,CAAC,EAAE;YAChB,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB;KACF,CAAC,CACH,CAAC,IAAI,CAAC,IAAI,CAAC;IAEZ,IAAI,aAAa,GAAG,CAAC,CAAC;IAEtB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,GAAG,CAAC,EAAE,CAAC,mBAAmB,aAAa,WAAW,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,96 @@
1
+ import { takaro, data } from '@takaro/helpers';
2
+ function getTotalPrize(tickets, ticketPrice, profitMargin) {
3
+ const amount = tickets.reduce((acc, ticket) => {
4
+ const ticketAmount = parseInt(JSON.parse(ticket.value).amount, 10);
5
+ return acc + ticketAmount;
6
+ }, 0);
7
+ const rawTotal = amount * ticketPrice;
8
+ const profit = rawTotal * profitMargin;
9
+ const totalPrize = rawTotal - profit;
10
+ return totalPrize;
11
+ }
12
+ async function drawWinner(takaro, gameServerId, tickets) {
13
+ const randomIndex = Math.floor(Math.random() * tickets.length);
14
+ const winnerTicket = tickets[randomIndex];
15
+ const winner = (await takaro.player.playerControllerGetOne(winnerTicket.playerId)).data.data;
16
+ const pog = await takaro.playerOnGameserver.playerOnGameServerControllerSearch({
17
+ filters: {
18
+ gameServerId: [gameServerId],
19
+ playerId: [winner.id],
20
+ },
21
+ });
22
+ return {
23
+ name: winner.name,
24
+ playerId: pog.data.data[0].playerId,
25
+ };
26
+ }
27
+ async function refundPlayer(takaro, gameServerId, playerId, amount, currencyName) {
28
+ const pog = (await takaro.playerOnGameserver.playerOnGameServerControllerSearch({
29
+ filters: {
30
+ gameServerId: [gameServerId],
31
+ playerId: [playerId],
32
+ },
33
+ })).data.data[0];
34
+ await takaro.playerOnGameserver.playerOnGameServerControllerAddCurrency(gameServerId, pog.playerId, {
35
+ currency: amount,
36
+ });
37
+ await takaro.gameserver.gameServerControllerSendMessage(gameServerId, {
38
+ message: `You have been refunded ${amount} ${currencyName} because the lottery has been cancelled.`,
39
+ opts: {
40
+ recipient: {
41
+ gameId: pog.gameId,
42
+ },
43
+ },
44
+ });
45
+ }
46
+ async function cleanUp(takaro, tickets) {
47
+ const deleteTasks = tickets.map((ticket) => takaro.variable.variableControllerDelete(ticket.id));
48
+ await Promise.allSettled(deleteTasks);
49
+ }
50
+ async function main() {
51
+ const { gameServerId, module: mod } = data;
52
+ let tickets = [];
53
+ try {
54
+ const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value;
55
+ const ticketCost = mod.systemConfig.commands.buyTicket.cost;
56
+ tickets = (await takaro.variable.variableControllerSearch({
57
+ filters: {
58
+ gameServerId: [gameServerId],
59
+ moduleId: [mod.moduleId],
60
+ key: ['lottery_tickets_bought'],
61
+ },
62
+ })).data.data;
63
+ if (tickets.length === 0) {
64
+ await takaro.gameserver.gameServerControllerSendMessage(gameServerId, {
65
+ message: 'No one has bought any tickets. The lottery has been cancelled.',
66
+ });
67
+ return;
68
+ }
69
+ if (tickets.length === 1) {
70
+ await takaro.gameserver.gameServerControllerSendMessage(gameServerId, {
71
+ message: 'Only one person has bought a ticket. The lottery has been cancelled.',
72
+ });
73
+ const amount = parseInt(JSON.parse(tickets[0].value).amount, 10) * ticketCost;
74
+ await refundPlayer(takaro, gameServerId, tickets[0].playerId, amount, currencyName);
75
+ return;
76
+ }
77
+ const totalPrize = getTotalPrize(tickets, ticketCost, mod.userConfig.profitMargin);
78
+ const { name: winnerName, playerId } = await drawWinner(takaro, gameServerId, tickets);
79
+ await takaro.gameserver.gameServerControllerSendMessage(gameServerId, {
80
+ message: 'The lottery raffle is about to start!',
81
+ });
82
+ await takaro.gameserver.gameServerControllerSendMessage(gameServerId, { message: 'drumrolls please...' });
83
+ await takaro.gameserver.gameServerControllerSendMessage(gameServerId, { message: 'The winner is...' });
84
+ await takaro.playerOnGameserver.playerOnGameServerControllerAddCurrency(gameServerId, playerId, {
85
+ currency: totalPrize,
86
+ });
87
+ await takaro.gameserver.gameServerControllerSendMessage(gameServerId, {
88
+ message: `${winnerName}! Congratulations! You have won ${totalPrize} ${currencyName}!`,
89
+ });
90
+ }
91
+ finally {
92
+ await cleanUp(takaro, tickets);
93
+ }
94
+ }
95
+ await main();
96
+ //# sourceMappingURL=drawLottery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawLottery.js","sourceRoot":"","sources":["../../../../src/modules/lottery/cronJobs/drawLottery.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE/C,SAAS,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY;IACvD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QAC5C,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEnE,OAAO,GAAG,GAAG,YAAY,CAAC;IAC5B,CAAC,EAAE,CAAC,CAAC,CAAC;IAEN,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,MAAM,MAAM,GAAG,QAAQ,GAAG,YAAY,CAAC;IACvC,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;IAErC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO;IACrD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F,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;AACH,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { BuiltinModule } from '../../BuiltinModule.js';
2
+ export declare class Lottery extends BuiltinModule<Lottery> {
3
+ constructor();
4
+ }
@@ -0,0 +1,73 @@
1
+ import { BuiltinModule, ICommand, ICronJob, IPermission } from '../../BuiltinModule.js';
2
+ export class Lottery extends BuiltinModule {
3
+ constructor() {
4
+ super('lottery', 'Players can buy tickets for a lottery, and the winner is chosen at random.', JSON.stringify({
5
+ $schema: 'http://json-schema.org/draft-07/schema#',
6
+ type: 'object',
7
+ properties: {
8
+ profitMargin: {
9
+ type: 'number',
10
+ maximum: 1,
11
+ minimum: 0,
12
+ description: 'The profit margin the server takes from the lottery.',
13
+ default: 0.1,
14
+ },
15
+ },
16
+ required: [],
17
+ additionalProperties: false,
18
+ }));
19
+ this.permissions = [
20
+ new IPermission({
21
+ permission: 'LOTTERY_BUY',
22
+ friendlyName: 'Buy Lottery Tickets',
23
+ canHaveCount: false,
24
+ description: 'Allows the player to buy lottery tickets.',
25
+ }),
26
+ new IPermission({
27
+ permission: 'LOTTERY_VIEW_TICKETS',
28
+ friendlyName: 'View Lottery Tickets',
29
+ description: 'Allows the player to view his lottery tickets.',
30
+ canHaveCount: false,
31
+ }),
32
+ ];
33
+ this.cronJobs = [
34
+ new ICronJob({
35
+ name: 'drawLottery',
36
+ temporalValue: '0 0 * * *',
37
+ function: this.loadFn('cronJobs', 'drawLottery'),
38
+ }),
39
+ ];
40
+ this.commands = [
41
+ new ICommand({
42
+ function: this.loadFn('commands', 'buyTicket'),
43
+ name: 'buyTicket',
44
+ trigger: 'buyTicket',
45
+ helpText: 'Buy a lottery ticket.',
46
+ arguments: [
47
+ {
48
+ name: 'amount',
49
+ type: 'number',
50
+ helpText: 'The amount of tickets to buy.',
51
+ position: 0,
52
+ defaultValue: null,
53
+ },
54
+ ],
55
+ }),
56
+ new ICommand({
57
+ function: this.loadFn('commands', 'viewTickets'),
58
+ name: 'viewTickets',
59
+ trigger: 'viewTickets',
60
+ helpText: 'View your lottery tickets.',
61
+ arguments: [],
62
+ }),
63
+ new ICommand({
64
+ function: this.loadFn('commands', 'nextDraw'),
65
+ name: 'nextDraw',
66
+ trigger: 'nextDraw',
67
+ helpText: 'View when the next draw is.',
68
+ arguments: [],
69
+ }),
70
+ ];
71
+ }
72
+ }
73
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/lottery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAExF,MAAM,OAAO,OAAQ,SAAQ,aAAsB;IACjD;QACE,KAAK,CACH,SAAS,EACT,4EAA4E,EAC5E,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,yCAAyC;YAClD,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,YAAY,EAAE;oBACZ,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,CAAC;oBACV,OAAO,EAAE,CAAC;oBACV,WAAW,EAAE,sDAAsD;oBACnE,OAAO,EAAE,GAAG;iBACb;aACF;YACD,QAAQ,EAAE,EAAE;YACZ,oBAAoB,EAAE,KAAK;SAC5B,CAAC,CACH,CAAC;QAEF,IAAI,CAAC,WAAW,GAAG;YACjB,IAAI,WAAW,CAAC;gBACd,UAAU,EAAE,aAAa;gBACzB,YAAY,EAAE,qBAAqB;gBACnC,YAAY,EAAE,KAAK;gBACnB,WAAW,EAAE,2CAA2C;aACzD,CAAC;YACF,IAAI,WAAW,CAAC;gBACd,UAAU,EAAE,sBAAsB;gBAClC,YAAY,EAAE,sBAAsB;gBACpC,WAAW,EAAE,gDAAgD;gBAC7D,YAAY,EAAE,KAAK;aACpB,CAAC;SACH,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,QAAQ,CAAC;gBACX,IAAI,EAAE,aAAa;gBACnB,aAAa,EAAE,WAAW;gBAC1B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC;aACjD,CAAC;SACH,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,QAAQ,CAAC;gBACX,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC;gBAC9C,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,WAAW;gBACpB,QAAQ,EAAE,uBAAuB;gBACjC,SAAS,EAAE;oBACT;wBACE,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,QAAQ;wBACd,QAAQ,EAAE,+BAA+B;wBACzC,QAAQ,EAAE,CAAC;wBACX,YAAY,EAAE,IAAI;qBACnB;iBACF;aACF,CAAC;YACF,IAAI,QAAQ,CAAC;gBACX,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC;gBAChD,IAAI,EAAE,aAAa;gBACnB,OAAO,EAAE,aAAa;gBACtB,QAAQ,EAAE,4BAA4B;gBACtC,SAAS,EAAE,EAAE;aACd,CAAC;YACF,IAAI,QAAQ,CAAC;gBACX,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC;gBAC7C,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,UAAU;gBACnB,QAAQ,EAAE,6BAA6B;gBACvC,SAAS,EAAE,EAAE;aACd,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,34 @@
1
+ import { takaro, data, TakaroUserError } from '@takaro/helpers';
2
+ const VARIABLE_KEY = 't_starterkit_lock';
3
+ async function main() {
4
+ const items = data.module.userConfig.starterKitItems;
5
+ if (!items || items.length === 0) {
6
+ throw new TakaroUserError('No starter kit items configured. Please ask your server administrator to configure this.');
7
+ }
8
+ const starterKitLockRes = await takaro.variable.variableControllerSearch({
9
+ filters: {
10
+ key: [VARIABLE_KEY],
11
+ gameServerId: [data.gameServerId],
12
+ playerId: [data.player.id],
13
+ },
14
+ });
15
+ if (starterKitLockRes.data.data.length > 0) {
16
+ throw new TakaroUserError('You already used starterkit on this server');
17
+ }
18
+ await data.player.pm('You are about to receive your starter kit...');
19
+ await Promise.all(items.map(async (item) => {
20
+ return takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {
21
+ name: item,
22
+ amount: 1,
23
+ });
24
+ }));
25
+ await takaro.variable.variableControllerCreate({
26
+ key: VARIABLE_KEY,
27
+ value: '1',
28
+ gameServerId: data.gameServerId,
29
+ playerId: data.player.id,
30
+ });
31
+ await data.player.pm(`Gave ${items.length} items, enjoy!`);
32
+ }
33
+ await main();
34
+ //# sourceMappingURL=starterkit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"starterkit.js","sourceRoot":"","sources":["../../../../src/modules/playerOnboarding/commands/starterkit.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC,KAAK,UAAU,IAAI;IACjB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC;IAErD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,eAAe,CACvB,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IAED,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QACvE,OAAO,EAAE;YACP,GAAG,EAAE,CAAC,YAAY,CAAC;YACnB,YAAY,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;YACjC,QAAQ,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;SAC3B;KACF,CAAC,CAAC;IAEH,IAAI,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,eAAe,CAAC,4CAA4C,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,8CAA8C,CAAC,CAAC;IAErE,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACvB,OAAO,MAAM,CAAC,UAAU,CAAC,4BAA4B,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;YACvF,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,CAAC;SACV,CAAC,CAAC;IACL,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QAC7C,GAAG,EAAE,YAAY;QACjB,KAAK,EAAE,GAAG;QACV,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE;KACzB,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,KAAK,CAAC,MAAM,gBAAgB,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { takaro, data } from '@takaro/helpers';
2
+ async function main() {
3
+ const { player } = data;
4
+ const rawMessage = data.module.userConfig.message;
5
+ const message = rawMessage.replace('{player}', player.name);
6
+ await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {
7
+ message,
8
+ });
9
+ }
10
+ await main();
11
+ //# sourceMappingURL=playerConnected.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playerConnected.js","sourceRoot":"","sources":["../../../../src/modules/playerOnboarding/hooks/playerConnected.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE/C,KAAK,UAAU,IAAI;IACjB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAExB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;IAClD,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAE5D,MAAM,MAAM,CAAC,UAAU,CAAC,+BAA+B,CAAC,IAAI,CAAC,YAAY,EAAE;QACzE,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { BuiltinModule } from '../../BuiltinModule.js';
2
+ export declare class PlayerOnboarding extends BuiltinModule<PlayerOnboarding> {
3
+ constructor();
4
+ }
@@ -0,0 +1,51 @@
1
+ import { BuiltinModule, ICommand, IHook } from '../../BuiltinModule.js';
2
+ import { HookEvents } from '../../dto/index.js';
3
+ export class PlayerOnboarding extends BuiltinModule {
4
+ constructor() {
5
+ super('playerOnboarding', 'Collection of functions that are executed when a player joins the server. Helps with onboarding new players, like sending a welcome message.', JSON.stringify({
6
+ $schema: 'http://json-schema.org/draft-07/schema#',
7
+ type: 'object',
8
+ properties: {
9
+ message: {
10
+ title: 'Message',
11
+ description: 'The message to send to the player when they join the server.',
12
+ type: 'string',
13
+ minLength: 1,
14
+ maxLength: 256,
15
+ default: 'Welcome {player} to the server!',
16
+ },
17
+ starterKitItems: {
18
+ type: 'array',
19
+ 'x-component': 'item',
20
+ title: 'Starter kit items',
21
+ description: 'List of items a player will receive when they execute the starterkit command for the first time.',
22
+ uniqueItems: true,
23
+ items: {
24
+ type: 'string',
25
+ },
26
+ },
27
+ },
28
+ required: [],
29
+ additionalProperties: false,
30
+ }), JSON.stringify({
31
+ starterKitItems: { 'ui:widget': 'item' },
32
+ }));
33
+ this.hooks = [
34
+ new IHook({
35
+ eventType: HookEvents.PLAYER_CONNECTED,
36
+ name: 'playerConnected',
37
+ function: this.loadFn('hooks', 'playerConnected'),
38
+ }),
39
+ ];
40
+ this.commands = [
41
+ new ICommand({
42
+ name: 'starterkit',
43
+ function: this.loadFn('commands', 'starterkit'),
44
+ trigger: 'starterkit',
45
+ helpText: 'Get a starter kit, you can only execute this once on a server!',
46
+ arguments: [],
47
+ }),
48
+ ];
49
+ }
50
+ }
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/playerOnboarding/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,MAAM,OAAO,gBAAiB,SAAQ,aAA+B;IACnE;QACE,KAAK,CACH,kBAAkB,EAClB,8IAA8I,EAC9I,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,yCAAyC;YAClD,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,KAAK,EAAE,SAAS;oBAChB,WAAW,EAAE,8DAA8D;oBAC3E,IAAI,EAAE,QAAQ;oBACd,SAAS,EAAE,CAAC;oBACZ,SAAS,EAAE,GAAG;oBACd,OAAO,EAAE,iCAAiC;iBAC3C;gBACD,eAAe,EAAE;oBACf,IAAI,EAAE,OAAO;oBACb,aAAa,EAAE,MAAM;oBACrB,KAAK,EAAE,mBAAmB;oBAC1B,WAAW,EACT,kGAAkG;oBACpG,WAAW,EAAE,IAAI;oBACjB,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;YACD,QAAQ,EAAE,EAAE;YACZ,oBAAoB,EAAE,KAAK;SAC5B,CAAC,EACF,IAAI,CAAC,SAAS,CAAC;YACb,eAAe,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE;SACzC,CAAC,CACH,CAAC;QAEF,IAAI,CAAC,KAAK,GAAG;YACX,IAAI,KAAK,CAAC;gBACR,SAAS,EAAE,UAAU,CAAC,gBAAgB;gBACtC,IAAI,EAAE,iBAAiB;gBACvB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAAC;aAClD,CAAC;SACH,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,QAAQ,CAAC;gBACX,IAAI,EAAE,YAAY;gBAClB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC;gBAC/C,OAAO,EAAE,YAAY;gBACrB,QAAQ,EAAE,gEAAgE;gBAC1E,SAAS,EAAE,EAAE;aACd,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import { takaro, data } from '@takaro/helpers';
2
+ async function main() {
3
+ const randomMessage = data.module.userConfig.messages[Math.floor(Math.random() * data.module.userConfig.messages.length)];
4
+ await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {
5
+ message: randomMessage,
6
+ });
7
+ }
8
+ await main();
9
+ //# sourceMappingURL=Automated%20message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Automated message.js","sourceRoot":"","sources":["../../../../src/modules/serverMessages/cronJobs/Automated message.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE/C,KAAK,UAAU,IAAI;IACjB,MAAM,aAAa,GACjB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAEtG,MAAM,MAAM,CAAC,UAAU,CAAC,+BAA+B,CAAC,IAAI,CAAC,YAAY,EAAE;QACzE,OAAO,EAAE,aAAa;KACvB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { BuiltinModule } from '../../BuiltinModule.js';
2
+ export declare class ServerMessages extends BuiltinModule<ServerMessages> {
3
+ constructor();
4
+ }
@@ -0,0 +1,35 @@
1
+ import { BuiltinModule, ICronJob } from '../../BuiltinModule.js';
2
+ export class ServerMessages extends BuiltinModule {
3
+ constructor() {
4
+ super('serverMessages', 'Send automated, rotated, configurable messages to players on the server.', JSON.stringify({
5
+ $schema: 'http://json-schema.org/draft-07/schema#',
6
+ type: 'object',
7
+ properties: {
8
+ messages: {
9
+ type: 'array',
10
+ title: 'Messages',
11
+ description: 'List of messages that will be sent to players on the server.',
12
+ default: [
13
+ // prettier-ignore
14
+ 'This is an automated message, don\'t forget to read the server rules!',
15
+ ],
16
+ items: {
17
+ type: 'string',
18
+ minLength: 5,
19
+ maxLength: 1024,
20
+ },
21
+ minItems: 1,
22
+ },
23
+ },
24
+ required: ['messages'],
25
+ }));
26
+ this.cronJobs = [
27
+ new ICronJob({
28
+ name: 'Automated message',
29
+ temporalValue: '*/30 * * * *',
30
+ function: this.loadFn('cronJobs', 'Automated message'),
31
+ }),
32
+ ];
33
+ }
34
+ }
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/serverMessages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,OAAO,cAAe,SAAQ,aAA6B;IAC/D;QACE,KAAK,CACH,gBAAgB,EAChB,0EAA0E,EAC1E,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,yCAAyC;YAClD,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,UAAU;oBACjB,WAAW,EAAE,8DAA8D;oBAC3E,OAAO,EAAE;wBACP,kBAAkB;wBAClB,uEAAuE;qBACxE;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,SAAS,EAAE,CAAC;wBACZ,SAAS,EAAE,IAAI;qBAChB;oBACD,QAAQ,EAAE,CAAC;iBACZ;aACF;YACD,QAAQ,EAAE,CAAC,UAAU,CAAC;SACvB,CAAC,CACH,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,QAAQ,CAAC;gBACX,IAAI,EAAE,mBAAmB;gBACzB,aAAa,EAAE,cAAc;gBAC7B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,mBAAmB,CAAC;aACvD,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import { takaro, data, TakaroUserError } from '@takaro/helpers';
2
+ import { getVariableKey } from './utils.js';
3
+ async function main() {
4
+ const { pog, gameServerId, arguments: args, module: mod } = data;
5
+ const existingVariable = await takaro.variable.variableControllerSearch({
6
+ filters: {
7
+ key: [getVariableKey(args.tp)],
8
+ gameServerId: [gameServerId],
9
+ playerId: [pog.playerId],
10
+ moduleId: [mod.moduleId],
11
+ },
12
+ });
13
+ if (existingVariable.data.data.length === 0) {
14
+ throw new TakaroUserError(`Teleport ${args.tp} does not exist.`);
15
+ }
16
+ await takaro.variable.variableControllerDelete(existingVariable.data.data[0].id);
17
+ await data.player.pm(`Teleport ${args.tp} deleted.`);
18
+ }
19
+ await main();
20
+ //# sourceMappingURL=deletetp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deletetp.js","sourceRoot":"","sources":["../../../../src/modules/teleports/commands/deletetp.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,KAAK,UAAU,IAAI;IACjB,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAEjE,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QACtE,OAAO,EAAE;YACP,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC9B,YAAY,EAAE,CAAC,YAAY,CAAC;YAC5B,QAAQ,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC;YACxB,QAAQ,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC;SACzB;KACF,CAAC,CAAC;IAEH,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,eAAe,CAAC,YAAY,IAAI,CAAC,EAAE,kBAAkB,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAEjF,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';
2
+ function getWaypointName(name) {
3
+ return `waypoint ${name}`;
4
+ }
5
+ async function main() {
6
+ const { pog, gameServerId, arguments: args } = data;
7
+ if (!checkPermission(pog, 'TELEPORTS_MANAGE_WAYPOINTS')) {
8
+ throw new TakaroUserError('You do not have permission to manage waypoints.');
9
+ }
10
+ async function ensureWaypointsModule() {
11
+ let waypointsDefinition = (await takaro.module.moduleControllerSearch({
12
+ filters: {
13
+ name: ['Waypoints'],
14
+ },
15
+ })).data.data[0];
16
+ if (!waypointsDefinition) {
17
+ console.log('Waypoints module definition not found, creating it.');
18
+ waypointsDefinition = (await takaro.module.moduleControllerCreate({
19
+ name: 'Waypoints',
20
+ description: 'Waypoints module for the teleport system.',
21
+ })).data.data;
22
+ }
23
+ let waypointsInstallation = (await takaro.gameserver.gameServerControllerGetInstalledModules(gameServerId)).data.data.find((module) => module.name === 'Waypoints');
24
+ if (!waypointsInstallation) {
25
+ console.log('Waypoints module not found, installing it.');
26
+ waypointsInstallation = (await takaro.gameserver.gameServerControllerInstallModule(gameServerId, waypointsDefinition.id)).data.data;
27
+ }
28
+ return { waypointsInstallation, waypointsDefinition };
29
+ }
30
+ const { waypointsInstallation } = await ensureWaypointsModule();
31
+ const variable = await takaro.variable.variableControllerSearch({
32
+ filters: {
33
+ key: [getWaypointName(args.waypoint)],
34
+ gameServerId: [gameServerId],
35
+ moduleId: [waypointsInstallation.moduleId],
36
+ },
37
+ });
38
+ if (!variable.data.data.length) {
39
+ throw new TakaroUserError(`Waypoint ${args.waypoint} doesn't exist.`);
40
+ }
41
+ await takaro.variable.variableControllerDelete(variable.data.data[0].id);
42
+ const teleportCommand = await takaro.command.commandControllerSearch({
43
+ filters: {
44
+ moduleId: [waypointsInstallation.moduleId],
45
+ name: [`waypoint ${args.waypoint} server ${gameServerId}`],
46
+ },
47
+ });
48
+ if (teleportCommand.data.data.length) {
49
+ await takaro.command.commandControllerRemove(teleportCommand.data.data[0].id);
50
+ }
51
+ await pog.pm(`Waypoint ${args.waypoint} deleted.`);
52
+ }
53
+ await main();
54
+ //# sourceMappingURL=deletewaypoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deletewaypoint.js","sourceRoot":"","sources":["../../../../src/modules/teleports/commands/deletewaypoint.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEjF,SAAS,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AAC;AACrD,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { takaro, data, checkPermission } from '@takaro/helpers';
2
+ async function main() {
3
+ const { pog, gameServerId } = data;
4
+ async function ensureWaypointsModule() {
5
+ let waypointsDefinition = (await takaro.module.moduleControllerSearch({
6
+ filters: {
7
+ name: ['Waypoints'],
8
+ },
9
+ })).data.data[0];
10
+ if (!waypointsDefinition) {
11
+ console.log('Waypoints module definition not found, creating it.');
12
+ waypointsDefinition = (await takaro.module.moduleControllerCreate({
13
+ name: 'Waypoints',
14
+ description: 'Waypoints module for the teleport system.',
15
+ })).data.data;
16
+ }
17
+ let waypointsInstallation = (await takaro.gameserver.gameServerControllerGetInstalledModules(gameServerId)).data.data.find((module) => module.name === 'Waypoints');
18
+ if (!waypointsInstallation) {
19
+ console.log('Waypoints module not found, installing it.');
20
+ waypointsInstallation = (await takaro.gameserver.gameServerControllerInstallModule(gameServerId, waypointsDefinition.id)).data.data;
21
+ }
22
+ return { waypointsInstallation, waypointsDefinition };
23
+ }
24
+ const { waypointsDefinition } = await ensureWaypointsModule();
25
+ const allWaypoints = waypointsDefinition.commands;
26
+ const waypointsWithPermission = allWaypoints
27
+ .filter((waypoint) => checkPermission(pog, `WAYPOINTS_USE_${waypoint.trigger.toUpperCase()}_${gameServerId}`))
28
+ .sort((a, b) => a.trigger.localeCompare(b.trigger));
29
+ if (!waypointsWithPermission.length) {
30
+ await pog.pm('There are no waypoints available.');
31
+ return;
32
+ }
33
+ await pog.pm(`Available waypoints: ${waypointsWithPermission.map((waypoint) => waypoint.trigger).join(', ')}`);
34
+ }
35
+ await main();
36
+ //# sourceMappingURL=listwaypoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listwaypoints.js","sourceRoot":"","sources":["../../../../src/modules/teleports/commands/listwaypoints.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,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