@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,38 @@
1
+ import { takaro, data, TakaroUserError } from '@takaro/helpers';
2
+ async function main() {
3
+ const { gameServerId, pog: sender, module: mod } = data;
4
+ // try to find a variable with key "confirmTransfer"
5
+ const variables = (await takaro.variable.variableControllerSearch({
6
+ filters: {
7
+ key: 'confirmTransfer',
8
+ gameServerId,
9
+ moduleId: mod.moduleId,
10
+ playerId: sender.playerId,
11
+ },
12
+ })).data.data;
13
+ if (variables.length === 0) {
14
+ throw new TakaroUserError('You have no pending transfer.');
15
+ }
16
+ // Remove the variable before potentially executing the transaction.
17
+ await takaro.variable.variableControllerDelete(variables[0].id);
18
+ const pendingTransfer = JSON.parse(variables[0].value);
19
+ await takaro.playerOnGameserver.playerOnGameServerControllerTransactBetweenPlayers(sender.gameServerId, sender.id, pendingTransfer.receiver.id, {
20
+ currency: pendingTransfer.amount,
21
+ });
22
+ const receiverName = (await takaro.player.playerControllerGetOne(pendingTransfer.receiver.playerId)).data.data.name;
23
+ const senderName = (await takaro.player.playerControllerGetOne(sender.playerId)).data.data.name;
24
+ const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value;
25
+ const messageToSender = sender.pm(`You successfully transferred ${pendingTransfer.amount} ${currencyName} to ${receiverName}`);
26
+ const messageToReceiver = takaro.gameserver.gameServerControllerSendMessage(gameServerId, {
27
+ message: `You received ${pendingTransfer.amount} ${currencyName} from ${senderName}`,
28
+ opts: {
29
+ recipient: {
30
+ gameId: pendingTransfer.receiver.gameId,
31
+ },
32
+ },
33
+ });
34
+ await Promise.all([messageToSender, messageToReceiver]);
35
+ return;
36
+ }
37
+ await main();
38
+ //# sourceMappingURL=confirmTransfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmTransfer.js","sourceRoot":"","sources":["../../../../src/modules/economyUtils/commands/confirmTransfer.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEhE,KAAK,UAAU,IAAI;IACjB,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAExD,oDAAoD;IACpD,MAAM,SAAS,GAAG,CAChB,MAAM,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QAC7C,OAAO,EAAE;YACP,GAAG,EAAE,iBAAiB;YACtB,YAAY;YACZ,QAAQ,EAAE,G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AG,MAAM,CAAC,UAAU,CAAC,+BAA+B,CAAC,YAAY,EAAE;QACxF,OAAO,EAAE,gBAAgB,eAAe,CAAC,MAAM,IAAI,YAAY,SAAS,UAAU,EAAE;QACpF,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,MAAM;aACxC;SACF;KACF,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC,CAAC;IACxD,OAAO;AACT,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';
2
+ async function main() {
3
+ const { pog: granter, arguments: args, gameServerId } = data;
4
+ // args.receiver has an argument type of "player". Arguments of this type are automatically resolved to the player's id.
5
+ // If the player doesn't exist or multiple players with the same name where found, it will have thrown an error before this command is executed.
6
+ const receiver = args.receiver;
7
+ if (!checkPermission(granter, 'ECONOMY_UTILS_MANAGE_CURRENCY')) {
8
+ throw new TakaroUserError('You do not have permission to use grant currency command.');
9
+ }
10
+ const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value;
11
+ const granterName = (await takaro.player.playerControllerGetOne(granter.playerId)).data.data.name;
12
+ const receiverName = (await takaro.player.playerControllerGetOne(receiver.playerId)).data.data.name;
13
+ await takaro.playerOnGameserver.playerOnGameServerControllerAddCurrency(receiver.gameServerId, receiver.playerId, {
14
+ currency: args.amount,
15
+ });
16
+ const messageToReceiver = takaro.gameserver.gameServerControllerSendMessage(gameServerId, {
17
+ message: `Granted ${args.amount} ${currencyName} by ${granterName}`,
18
+ opts: {
19
+ recipient: {
20
+ gameId: receiver.gameId,
21
+ },
22
+ },
23
+ });
24
+ await Promise.all([
25
+ granter.pm(`You successfully granted ${args.amount} ${currencyName} to ${receiverName}`),
26
+ messageToReceiver,
27
+ ]);
28
+ return;
29
+ }
30
+ await main();
31
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AY,EAAE;QACxF,OAAO,EAAE,WAAW,IAAI,CAAC,MAAM,IAAI,YAAY,OAAO,WAAW,EAAE;QACnE,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB;SACF;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,OAAO,CAAC,EAAE,CAAC,4BAA4B,IAAI,CAAC,MAAM,IAAI,YAAY,OAAO,YAAY,EAAE,CAAC;QACxF,iBAAiB;KAClB,CAAC,CAAC;IAEH,OAAO;AACT,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';
2
+ async function main() {
3
+ const { pog: revoker, arguments: args, gameServerId } = data;
4
+ // args.receiver has an argument type of "player". Arguments of this type are automatically resolved to the player's id.
5
+ // If the player doesn't exist or multiple players with the same name where found, it will have thrown an error before this command is executed.
6
+ const receiver = args.receiver;
7
+ if (!checkPermission(revoker, 'ECONOMY_UTILS_MANAGE_CURRENCY')) {
8
+ throw new TakaroUserError('You do not have permission to use revoke currency command.');
9
+ }
10
+ const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value;
11
+ const revokerName = (await takaro.player.playerControllerGetOne(revoker.playerId)).data.data.name;
12
+ const receiverName = (await takaro.player.playerControllerGetOne(receiver.playerId)).data.data.name;
13
+ await takaro.playerOnGameserver.playerOnGameServerControllerDeductCurrency(receiver.gameServerId, receiver.playerId, {
14
+ currency: args.amount,
15
+ });
16
+ const messageToReceiver = takaro.gameserver.gameServerControllerSendMessage(gameServerId, {
17
+ message: `${args.amount} ${currencyName} were revoked by ${revokerName}`,
18
+ opts: {
19
+ recipient: {
20
+ gameId: receiver.gameId,
21
+ },
22
+ },
23
+ });
24
+ await Promise.all([
25
+ revoker.pm(`You successfully revoked ${args.amount} ${currencyName} of ${receiverName}'s balance`),
26
+ messageToReceiver,
27
+ ]);
28
+ return;
29
+ }
30
+ await main();
31
+ //# sourceMappingURL=revokeCurrency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revokeCurrency.js","sourceRoot":"","sources":["../../../../src/modules/economyUtils/commands/revokeCurrency.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,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAE7D,wHAAwH;IACxH,gJAAgJ;IAChJ,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAE/B,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,+BAA+B,CAAC,EAAE,CAAC;QAC/D,MAAM,IAAI,eAAe,CAAC,4DAA4D,CAAC,CAAC;IAC1F,CAAC;IAED,MAAM,YAAY,GAAG,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACpH,MAAM,WAAW,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAClG,MAAM,YAAY,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACpG,MAAM,MAAM,CAAC,kBAAkB,CAAC,0CAA0C,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,QAAQ,EAAE;QACnH,QAAQ,EAAE,IAAI,CAAC,MAAM;KACtB,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,MAAM,CAAC,UAAU,CAAC,+BAA+B,CAAC,YAAY,EAAE;QACxF,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,IAAI,YAAY,oBAAoB,WAAW,EAAE;QACxE,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB;SACF;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,OAAO,CAAC,EAAE,CAAC,4BAA4B,IAAI,CAAC,MAAM,IAAI,YAAY,OAAO,YAAY,YAAY,CAAC;QAClG,iBAAiB;KAClB,CAAC,CAAC;IAEH,OAAO;AACT,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { takaro, data } from '@takaro/helpers';
2
+ async function main() {
3
+ const richest = (await takaro.playerOnGameserver.playerOnGameServerControllerSearch({
4
+ limit: 10,
5
+ sortBy: 'currency',
6
+ sortDirection: 'desc',
7
+ extend: ['player'],
8
+ })).data.data;
9
+ const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', data.gameServerId)).data.data
10
+ .value;
11
+ // TODO: change this to name when it become available in playerOnGameServer
12
+ const richestStrings = richest.map(async (pog, index) => {
13
+ const playerName = (await takaro.player.playerControllerGetOne(pog.playerId)).data.data.name;
14
+ return `${index + 1}. ${playerName} - ${pog.currency} ${currencyName}`;
15
+ });
16
+ await data.player.pm('Richest players:');
17
+ for (const string of richestStrings) {
18
+ await data.player.pm(await string);
19
+ }
20
+ }
21
+ await main();
22
+ //# sourceMappingURL=topCurrency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topCurrency.js","sourceRoot":"","sources":["../../../../src/modules/economyUtils/commands/topCurrency.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE/C,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,CACd,MAAM,MAAM,CAAC,kBAAkB,CAAC,kCAAkC,CAAC;QACjE,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,UAAU;QAClB,aAAa,EAAE,MAAM;QACrB,MAAM,EAAE,CAAC,QAAQ,CAAC;KACnB,CAAC,CACH,CAAC,IAAI,CAAC,IAAI,CAAC;IAEZ,MAAM,YAAY,GAAG,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI;SAC/G,KAAK,CAAC;IAET,2EAA2E;IAC3E,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QACtD,MAAM,UAAU,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAC7F,OAAO,GAAG,KAAK,GAAG,CAAC,KAAK,UAAU,MAAM,GAAG,CAAC,QAAQ,IAAI,YAAY,EAAE,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC;IAEzC,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE,CAAC;QACpC,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,MAAM,CAAC,CAAC;IACrC,CAAC;AACH,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ import { takaro, data, TakaroUserError } from '@takaro/helpers';
2
+ async function main() {
3
+ const { pog: sender, arguments: args, gameServerId, module: mod } = data;
4
+ const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value;
5
+ const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value;
6
+ // args.receiver has an argument type of "player". Arguments of this type are automatically resolved to the player's id.
7
+ // If the player doesn't exist or multiple players with the same name where found, it will have thrown an error before this command is executed.
8
+ const receiver = args.receiver;
9
+ const senderName = (await takaro.player.playerControllerGetOne(sender.playerId)).data.data.name;
10
+ const receiverName = (await takaro.player.playerControllerGetOne(receiver.playerId)).data.data.name;
11
+ if (mod.userConfig.pendingAmount !== 0 && args.amount >= mod.userConfig.pendingAmount) {
12
+ // create a variable to store confirmation requirement
13
+ // TODO: in the future, we should probably add an expiration date to this variable.
14
+ await takaro.variable.variableControllerCreate({
15
+ key: 'confirmTransfer',
16
+ value: JSON.stringify({
17
+ amount: args.amount,
18
+ receiver: {
19
+ id: receiver.id,
20
+ gameId: receiver.gameId,
21
+ playerId: receiver.playerId,
22
+ },
23
+ }),
24
+ moduleId: mod.moduleId,
25
+ playerId: sender.playerId,
26
+ gameServerId,
27
+ });
28
+ // 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.
29
+ await sender.pm(`You are about to send ${args.amount} ${currencyName} to ${receiverName}. (Please confirm by typing ${prefix}confirmtransfer)`);
30
+ return;
31
+ }
32
+ try {
33
+ await takaro.playerOnGameserver.playerOnGameServerControllerTransactBetweenPlayers(sender.gameServerId, sender.id, receiver.id, {
34
+ currency: args.amount,
35
+ });
36
+ }
37
+ catch (e) {
38
+ throw new TakaroUserError(`Failed to transfer ${args.amount} ${currencyName} to ${receiverName}. Are you sure you have enough balance?`);
39
+ }
40
+ const messageToReceiver = takaro.gameserver.gameServerControllerSendMessage(gameServerId, {
41
+ message: `You received ${args.amount} ${currencyName} from ${senderName}`,
42
+ opts: {
43
+ recipient: {
44
+ gameId: receiver.gameId,
45
+ },
46
+ },
47
+ });
48
+ await Promise.all([
49
+ sender.pm(`You successfully transferred ${args.amount} ${currencyName} to ${receiverName}`),
50
+ messageToReceiver,
51
+ ]);
52
+ return;
53
+ }
54
+ await main();
55
+ //# sourceMappingURL=transfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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IAEH,OAAO;AACT,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { BuiltinModule } from '../../BuiltinModule.js';
2
+ export declare class EconomyUtils extends BuiltinModule<EconomyUtils> {
3
+ constructor();
4
+ }
@@ -0,0 +1,117 @@
1
+ import { BuiltinModule, ICommand, IPermission } from '../../BuiltinModule.js';
2
+ export class EconomyUtils extends BuiltinModule {
3
+ constructor() {
4
+ super('economyUtils', 'A set of commands to allow players to manage their currency.', JSON.stringify({
5
+ $schema: 'http://json-schema.org/draft-07/schema#',
6
+ type: 'object',
7
+ properties: {
8
+ pendingAmount: {
9
+ title: 'Pending amount',
10
+ type: 'number',
11
+ description: 'When a player transfers money, they must confirm the transfer when the amount is equal or above this value. Set to 0 to disable.',
12
+ default: 0,
13
+ },
14
+ },
15
+ required: [],
16
+ additionalProperties: false,
17
+ }));
18
+ this.permissions = [
19
+ new IPermission({
20
+ permission: 'ECONOMY_UTILS_MANAGE_CURRENCY',
21
+ friendlyName: 'Manage currency',
22
+ description: 'Allows players to manage currency of other players. This includes granting and revoking currency.',
23
+ canHaveCount: false,
24
+ }),
25
+ ];
26
+ this.commands = [
27
+ new ICommand({
28
+ function: this.loadFn('commands', 'balance'),
29
+ name: 'balance',
30
+ trigger: 'balance',
31
+ helpText: 'Check your balance.',
32
+ arguments: [],
33
+ }),
34
+ new ICommand({
35
+ function: this.loadFn('commands', 'topCurrency'),
36
+ name: 'topCurrency',
37
+ trigger: 'topcurrency',
38
+ helpText: 'List of the 10 players with the highest balance.',
39
+ arguments: [],
40
+ }),
41
+ new ICommand({
42
+ function: this.loadFn('commands', 'grantCurrency'),
43
+ name: 'grantCurrency',
44
+ trigger: 'grantcurrency',
45
+ helpText: 'Grant money to a player. The money is not taken from your own balance but is new currency.',
46
+ arguments: [
47
+ {
48
+ name: 'receiver',
49
+ type: 'player',
50
+ helpText: 'The player to grant currency to.',
51
+ position: 0,
52
+ defaultValue: null,
53
+ },
54
+ {
55
+ name: 'amount',
56
+ type: 'number',
57
+ helpText: 'The amount of money.',
58
+ position: 1,
59
+ defaultValue: null,
60
+ },
61
+ ],
62
+ }),
63
+ new ICommand({
64
+ function: this.loadFn('commands', 'revokeCurrency'),
65
+ name: 'revokeCurrency',
66
+ trigger: 'revokecurrency',
67
+ helpText: 'Grant money to a player. The money is not taken from your own balance but is new currency.',
68
+ arguments: [
69
+ {
70
+ name: 'receiver',
71
+ type: 'player',
72
+ helpText: 'The player to revoke currency from.',
73
+ position: 0,
74
+ defaultValue: null,
75
+ },
76
+ {
77
+ name: 'amount',
78
+ type: 'number',
79
+ helpText: 'The amount of money.',
80
+ position: 1,
81
+ defaultValue: null,
82
+ },
83
+ ],
84
+ }),
85
+ new ICommand({
86
+ function: this.loadFn('commands', 'confirmTransfer'),
87
+ name: 'confirmTransfer',
88
+ trigger: 'confirmtransfer',
89
+ helpText: 'Confirms a pending transfer.',
90
+ arguments: [],
91
+ }),
92
+ new ICommand({
93
+ function: this.loadFn('commands', 'transfer'),
94
+ name: 'transfer',
95
+ trigger: 'transfer',
96
+ helpText: 'Transfer money to another player.',
97
+ arguments: [
98
+ {
99
+ name: 'receiver',
100
+ type: 'player',
101
+ helpText: 'The player to transfer money to.',
102
+ position: 0,
103
+ defaultValue: null,
104
+ },
105
+ {
106
+ name: 'amount',
107
+ type: 'number',
108
+ helpText: 'The amount of money to transfer.',
109
+ position: 1,
110
+ defaultValue: null,
111
+ },
112
+ ],
113
+ }),
114
+ ];
115
+ }
116
+ }
117
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/economyUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE9E,MAAM,OAAO,YAAa,SAAQ,aAA2B;IAC3D;QACE,KAAK,CACH,cAAc,EACd,8DAA8D,EAC9D,IAAI,CAAC,SA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;wBACE,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,QAAQ;wBACd,QAAQ,EAAE,kCAAkC;wBAC5C,QAAQ,EAAE,CAAC;wBACX,YAAY,EAAE,IAAI;qBACnB;iBACF;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,50 @@
1
+ import { takaro, data, checkPermission } from '@takaro/helpers';
2
+ async function main() {
3
+ const { gameServerId, player, pog } = data;
4
+ const { country } = data.eventData;
5
+ const { ban, banDuration, countries, message, mode } = data.module.userConfig;
6
+ async function handleAction() {
7
+ if (ban) {
8
+ const now = new Date();
9
+ const expiresAt = new Date(now.getTime() + banDuration * 1000);
10
+ await takaro.gameserver.gameServerControllerBanPlayer(gameServerId, player.id, {
11
+ reason: message,
12
+ expiresAt,
13
+ });
14
+ }
15
+ else {
16
+ await takaro.gameserver.gameServerControllerKickPlayer(gameServerId, player.id, {
17
+ reason: message,
18
+ });
19
+ }
20
+ }
21
+ const isImmune = checkPermission(pog, 'GEOBLOCK_IMMUNITY');
22
+ if (isImmune) {
23
+ console.log('Player has immunity, no action');
24
+ return;
25
+ }
26
+ if (mode === 'allow') {
27
+ if (countries.includes(country)) {
28
+ console.log('Allowed country detected, no action');
29
+ return;
30
+ }
31
+ else {
32
+ console.log('Blocked country detected, performing actions');
33
+ await handleAction();
34
+ return;
35
+ }
36
+ }
37
+ if (mode === 'deny') {
38
+ if (countries.includes(country)) {
39
+ console.log('Blocked country detected, performing actions');
40
+ await handleAction();
41
+ return;
42
+ }
43
+ else {
44
+ console.log('Allowed country detected, no action');
45
+ return;
46
+ }
47
+ }
48
+ }
49
+ await main();
50
+ //# sourceMappingURL=IPDetected.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPDetected.js","sourceRoot":"","sources":["../../../../src/modules/geoBlock/hooks/IPDetected.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,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;YAC5D,MAAM,YAAY,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;IACH,CAAC;IAED,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,IAAI,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;YAC5D,MAAM,YAAY,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;YACnD,OAAO;QACT,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { BuiltinModule } from '../../BuiltinModule.js';
2
+ export declare const countryCodes: {
3
+ code: string;
4
+ name: string;
5
+ }[];
6
+ export declare class GeoBlock extends BuiltinModule<GeoBlock> {
7
+ constructor();
8
+ }