@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,188 +1,191 @@
1
- import { BuiltinModule, ICommand, ICronJob, IPermission } from '../../BuiltinModule.js';
1
+ import { ModuleTransferDTO, ICommand, ICronJob, IPermission, ModuleTransferVersionDTO } from '../../BuiltinModule.js';
2
2
 
3
- export class EconomyUtils extends BuiltinModule<EconomyUtils> {
3
+ export class EconomyUtils extends ModuleTransferDTO<EconomyUtils> {
4
4
  constructor() {
5
- super(
6
- 'economyUtils',
7
- 'A set of commands to allow players to manage their currency.',
8
- JSON.stringify({
9
- $schema: 'http://json-schema.org/draft-07/schema#',
10
- type: 'object',
11
- properties: {
12
- pendingAmount: {
13
- title: 'Pending amount',
14
- type: 'number',
15
- description:
16
- 'When a player transfers money, they must confirm the transfer when the amount is equal or above this value. Set to 0 to disable.',
17
- default: 0,
18
- },
19
- zombieKillReward: {
20
- title: 'Zombie kill reward',
21
- type: 'number',
22
- description:
23
- 'The default amount of currency a player receives for killing a zombie. This can be overridden by roles.',
24
- default: 1,
25
- },
26
- },
27
- required: [],
28
- additionalProperties: false,
29
- }),
30
- );
31
-
32
- this.permissions = [
33
- new IPermission({
34
- permission: 'ECONOMY_UTILS_MANAGE_CURRENCY',
35
- friendlyName: 'Manage currency',
36
- description:
37
- 'Allows players to manage currency of other players. This includes granting and revoking currency.',
38
- canHaveCount: false,
39
- }),
40
- new IPermission({
41
- permission: 'ZOMBIE_KILL_REWARD_OVERRIDE',
42
- friendlyName: 'Zombie kill reward override',
43
- description: 'Allows a role to override the amount of currency a player receives for killing a entity.',
44
- canHaveCount: true,
45
- }),
46
- ];
47
-
48
- this.cronJobs = [
49
- new ICronJob({
50
- function: this.loadFn('cronJobs', 'zombieKillReward'),
51
- name: 'zombieKillReward',
52
- temporalValue: '*/5 * * * *',
53
- }),
54
- ];
5
+ super();
55
6
 
56
- this.commands = [
57
- new ICommand({
58
- function: this.loadFn('commands', 'balance'),
59
- name: 'balance',
60
- trigger: 'balance',
61
- helpText: 'Check your balance.',
62
- arguments: [],
63
- }),
64
- new ICommand({
65
- function: this.loadFn('commands', 'topCurrency'),
66
- name: 'topCurrency',
67
- trigger: 'topcurrency',
68
- helpText: 'List of the 10 players with the highest balance.',
69
- arguments: [],
70
- }),
71
- new ICommand({
72
- function: this.loadFn('commands', 'grantCurrency'),
73
- name: 'grantCurrency',
74
- trigger: 'grantcurrency',
75
- helpText: 'Grant money to a player. The money is not taken from your own balance but is new currency.',
76
- arguments: [
77
- {
78
- name: 'receiver',
79
- type: 'player',
80
- helpText: 'The player to grant currency to.',
81
- position: 0,
82
- defaultValue: null,
83
- },
84
- {
85
- name: 'amount',
86
- type: 'number',
87
- helpText: 'The amount of money.',
88
- position: 1,
89
- defaultValue: null,
90
- },
91
- ],
92
- }),
93
- new ICommand({
94
- function: this.loadFn('commands', 'revokeCurrency'),
95
- name: 'revokeCurrency',
96
- trigger: 'revokecurrency',
97
- helpText: 'Revokes money from a player. The money disappears.',
98
- arguments: [
99
- {
100
- name: 'receiver',
101
- type: 'player',
102
- helpText: 'The player to revoke currency from.',
103
- position: 0,
104
- defaultValue: null,
105
- },
106
- {
107
- name: 'amount',
108
- type: 'number',
109
- helpText: 'The amount of money.',
110
- position: 1,
111
- defaultValue: null,
112
- },
113
- ],
114
- }),
115
- new ICommand({
116
- function: this.loadFn('commands', 'confirmTransfer'),
117
- name: 'confirmTransfer',
118
- trigger: 'confirmtransfer',
119
- helpText: 'Confirms a pending transfer.',
120
- arguments: [],
121
- }),
122
- new ICommand({
123
- function: this.loadFn('commands', 'transfer'),
124
- name: 'transfer',
125
- trigger: 'transfer',
126
- helpText: 'Transfer money to another player.',
127
- arguments: [
128
- {
129
- name: 'receiver',
130
- type: 'player',
131
- helpText: 'The player to transfer money to.',
132
- position: 0,
133
- defaultValue: null,
134
- },
135
- {
136
- name: 'amount',
137
- type: 'number',
138
- helpText: 'The amount of money to transfer.',
139
- position: 1,
140
- defaultValue: null,
7
+ this.name = 'economyUtils';
8
+ this.versions = [
9
+ new ModuleTransferVersionDTO({
10
+ tag: '0.0.1',
11
+ description: 'A set of commands to allow players to manage their currency.',
12
+ configSchema: JSON.stringify({
13
+ $schema: 'http://json-schema.org/draft-07/schema#',
14
+ type: 'object',
15
+ properties: {
16
+ pendingAmount: {
17
+ title: 'Pending amount',
18
+ type: 'number',
19
+ description:
20
+ 'When a player transfers money, they must confirm the transfer when the amount is equal or above this value. Set to 0 to disable.',
21
+ default: 0,
22
+ },
23
+ zombieKillReward: {
24
+ title: 'Zombie kill reward',
25
+ type: 'number',
26
+ description:
27
+ 'The default amount of currency a player receives for killing a zombie. This can be overridden by roles.',
28
+ default: 1,
29
+ },
141
30
  },
31
+ required: [],
32
+ additionalProperties: false,
33
+ }),
34
+ permissions: [
35
+ new IPermission({
36
+ permission: 'ECONOMY_UTILS_MANAGE_CURRENCY',
37
+ friendlyName: 'Manage currency',
38
+ description:
39
+ 'Allows players to manage currency of other players. This includes granting and revoking currency.',
40
+ canHaveCount: false,
41
+ }),
42
+ new IPermission({
43
+ permission: 'ZOMBIE_KILL_REWARD_OVERRIDE',
44
+ friendlyName: 'Zombie kill reward override',
45
+ description: 'Allows a role to override the amount of currency a player receives for killing a entity.',
46
+ canHaveCount: true,
47
+ }),
142
48
  ],
143
- }),
144
- new ICommand({
145
- function: this.loadFn('commands', 'claim'),
146
- name: 'claim',
147
- trigger: 'claim',
148
- helpText: 'Claim your pending shop orders.',
149
- arguments: [
150
- {
151
- name: 'all',
152
- type: 'boolean',
153
- helpText: 'If true, claim ALL pending orders. If false, claim only the first one.',
154
- position: 0,
155
- defaultValue: 'false',
156
- },
49
+ cronJobs: [
50
+ new ICronJob({
51
+ function: this.loadFn('cronJobs', 'zombieKillReward'),
52
+ name: 'zombieKillReward',
53
+ temporalValue: '*/5 * * * *',
54
+ }),
157
55
  ],
158
- }),
159
- new ICommand({
160
- function: this.loadFn('commands', 'shop'),
161
- name: 'shop',
162
- trigger: 'shop',
163
- helpText: 'Browse the shop and view available items.',
164
- arguments: [
165
- {
166
- name: 'page',
167
- type: 'number',
168
- helpText: 'Display more items from the shop by specifying a page number.',
169
- position: 0,
170
- defaultValue: '1',
171
- },
172
- {
173
- name: 'item',
174
- type: 'number',
175
- helpText: 'Select a specific item to view more details.',
176
- position: 1,
177
- defaultValue: '0',
178
- },
179
- {
180
- name: 'action',
181
- type: 'string',
182
- helpText: 'Perform an action on the selected item. Currently only "buy" is supported.',
183
- position: 2,
184
- defaultValue: 'none',
185
- },
56
+
57
+ commands: [
58
+ new ICommand({
59
+ function: this.loadFn('commands', 'balance'),
60
+ name: 'balance',
61
+ trigger: 'balance',
62
+ helpText: 'Check your balance.',
63
+ arguments: [],
64
+ }),
65
+ new ICommand({
66
+ function: this.loadFn('commands', 'topCurrency'),
67
+ name: 'topCurrency',
68
+ trigger: 'topcurrency',
69
+ helpText: 'List of the 10 players with the highest balance.',
70
+ arguments: [],
71
+ }),
72
+ new ICommand({
73
+ function: this.loadFn('commands', 'grantCurrency'),
74
+ name: 'grantCurrency',
75
+ trigger: 'grantcurrency',
76
+ helpText: 'Grant money to a player. The money is not taken from your own balance but is new currency.',
77
+ arguments: [
78
+ {
79
+ name: 'receiver',
80
+ type: 'player',
81
+ helpText: 'The player to grant currency to.',
82
+ position: 0,
83
+ defaultValue: null,
84
+ },
85
+ {
86
+ name: 'amount',
87
+ type: 'number',
88
+ helpText: 'The amount of money.',
89
+ position: 1,
90
+ defaultValue: null,
91
+ },
92
+ ],
93
+ }),
94
+ new ICommand({
95
+ function: this.loadFn('commands', 'revokeCurrency'),
96
+ name: 'revokeCurrency',
97
+ trigger: 'revokecurrency',
98
+ helpText: 'Revokes money from a player. The money disappears.',
99
+ arguments: [
100
+ {
101
+ name: 'receiver',
102
+ type: 'player',
103
+ helpText: 'The player to revoke currency from.',
104
+ position: 0,
105
+ defaultValue: null,
106
+ },
107
+ {
108
+ name: 'amount',
109
+ type: 'number',
110
+ helpText: 'The amount of money.',
111
+ position: 1,
112
+ defaultValue: null,
113
+ },
114
+ ],
115
+ }),
116
+ new ICommand({
117
+ function: this.loadFn('commands', 'confirmTransfer'),
118
+ name: 'confirmTransfer',
119
+ trigger: 'confirmtransfer',
120
+ helpText: 'Confirms a pending transfer.',
121
+ arguments: [],
122
+ }),
123
+ new ICommand({
124
+ function: this.loadFn('commands', 'transfer'),
125
+ name: 'transfer',
126
+ trigger: 'transfer',
127
+ helpText: 'Transfer money to another player.',
128
+ arguments: [
129
+ {
130
+ name: 'receiver',
131
+ type: 'player',
132
+ helpText: 'The player to transfer money to.',
133
+ position: 0,
134
+ defaultValue: null,
135
+ },
136
+ {
137
+ name: 'amount',
138
+ type: 'number',
139
+ helpText: 'The amount of money to transfer.',
140
+ position: 1,
141
+ defaultValue: null,
142
+ },
143
+ ],
144
+ }),
145
+ new ICommand({
146
+ function: this.loadFn('commands', 'claim'),
147
+ name: 'claim',
148
+ trigger: 'claim',
149
+ helpText: 'Claim your pending shop orders.',
150
+ arguments: [
151
+ {
152
+ name: 'all',
153
+ type: 'boolean',
154
+ helpText: 'If true, claim ALL pending orders. If false, claim only the first one.',
155
+ position: 0,
156
+ defaultValue: 'false',
157
+ },
158
+ ],
159
+ }),
160
+ new ICommand({
161
+ function: this.loadFn('commands', 'shop'),
162
+ name: 'shop',
163
+ trigger: 'shop',
164
+ helpText: 'Browse the shop and view available items.',
165
+ arguments: [
166
+ {
167
+ name: 'page',
168
+ type: 'number',
169
+ helpText: 'Display more items from the shop by specifying a page number.',
170
+ position: 0,
171
+ defaultValue: '1',
172
+ },
173
+ {
174
+ name: 'item',
175
+ type: 'number',
176
+ helpText: 'Select a specific item to view more details.',
177
+ position: 1,
178
+ defaultValue: '0',
179
+ },
180
+ {
181
+ name: 'action',
182
+ type: 'string',
183
+ helpText: 'Perform an action on the selected item. Currently only "buy" is supported.',
184
+ position: 2,
185
+ defaultValue: 'none',
186
+ },
187
+ ],
188
+ }),
186
189
  ],
187
190
  }),
188
191
  ];
@@ -9,9 +9,11 @@ async function main() {
9
9
  if (ban) {
10
10
  const now = new Date();
11
11
  const expiresAt = new Date(now.getTime() + banDuration * 1000);
12
- await takaro.gameserver.gameServerControllerBanPlayer(gameServerId, player.id, {
12
+ await takaro.player.banControllerCreate({
13
+ gameServerId,
14
+ playerId: player.id,
15
+ until: expiresAt,
13
16
  reason: message,
14
- expiresAt,
15
17
  });
16
18
  } else {
17
19
  await takaro.gameserver.gameServerControllerKickPlayer(gameServerId, player.id, {
@@ -1,4 +1,4 @@
1
- import { BuiltinModule, IHook, IPermission } from '../../BuiltinModule.js';
1
+ import { ModuleTransferDTO, IHook, IPermission, ModuleTransferVersionDTO } from '../../BuiltinModule.js';
2
2
  import { HookEvents } from '../../dto/index.js';
3
3
  import { Duration } from 'luxon';
4
4
 
@@ -252,79 +252,81 @@ export const countryCodes = [
252
252
  { code: 'ZW', name: 'Zimbabwe' },
253
253
  ];
254
254
 
255
- export class GeoBlock extends BuiltinModule<GeoBlock> {
255
+ export class GeoBlock extends ModuleTransferDTO<GeoBlock> {
256
256
  constructor() {
257
- super(
258
- 'geoBlock',
259
- 'Block players from certain countries from joining the server.',
260
- JSON.stringify({
261
- $schema: 'http://json-schema.org/draft-07/schema#',
262
- type: 'object',
263
- properties: {
264
- mode: {
265
- title: 'Mode',
266
- type: 'string',
267
- description:
268
- 'If set to allow, only players from the specified countries will be allowed to join. If set to deny, players from the specified countries will be banned from the server.',
269
- enum: ['allow', 'deny'],
270
- default: 'deny',
271
- },
272
- countries: {
273
- title: 'Countries',
274
- description: 'List of countries',
275
- type: 'array',
276
- uniqueItems: true,
277
- 'x-component': 'country',
278
- items: {
257
+ super();
258
+
259
+ this.name = 'geoBlock';
260
+ this.versions = [
261
+ new ModuleTransferVersionDTO({
262
+ tag: '0.0.1',
263
+ description: 'Block players from certain countries from joining the server.',
264
+ configSchema: JSON.stringify({
265
+ $schema: 'http://json-schema.org/draft-07/schema#',
266
+ type: 'object',
267
+ properties: {
268
+ mode: {
269
+ title: 'Mode',
279
270
  type: 'string',
280
- anyOf: countryCodes.map(({ code, name }) => ({ const: code, title: name })),
271
+ description:
272
+ 'If set to allow, only players from the specified countries will be allowed to join. If set to deny, players from the specified countries will be banned from the server.',
273
+ enum: ['allow', 'deny'],
274
+ default: 'deny',
275
+ },
276
+ countries: {
277
+ title: 'Countries',
278
+ description: 'List of countries',
279
+ type: 'array',
280
+ uniqueItems: true,
281
+ 'x-component': 'country',
282
+ items: {
283
+ type: 'string',
284
+ anyOf: countryCodes.map(({ code, name }) => ({ const: code, title: name })),
285
+ },
286
+ },
287
+ ban: {
288
+ title: 'Ban',
289
+ description:
290
+ 'Ban players from the server when they are detected. When false, players will be kicked instead.',
291
+ type: 'boolean',
292
+ default: true,
293
+ },
294
+ banDuration: {
295
+ title: 'Ban duration',
296
+ description: 'Duration of the ban.',
297
+ 'x-component': 'duration',
298
+ type: 'number',
299
+ minimum: 0,
300
+ default: Duration.fromObject({ days: 1 }).as('milliseconds'),
301
+ },
302
+ message: {
303
+ title: 'Message',
304
+ type: 'string',
305
+ description: 'Message to send to the player when they are kicked or banned.',
306
+ default: 'Your IP address is banned.',
281
307
  },
282
308
  },
283
- ban: {
284
- title: 'Ban',
285
- description:
286
- 'Ban players from the server when they are detected. When false, players will be kicked instead.',
287
- type: 'boolean',
288
- default: true,
289
- },
290
- banDuration: {
291
- title: 'Ban duration',
292
- description: 'Duration of the ban.',
293
- 'x-component': 'duration',
294
- type: 'number',
295
- minimum: 0,
296
- default: Duration.fromObject({ days: 1 }).as('milliseconds'),
297
- },
298
- message: {
299
- title: 'Message',
300
- type: 'string',
301
- description: 'Message to send to the player when they are kicked or banned.',
302
- default: 'Your IP address is banned.',
303
- },
304
- },
305
- required: ['countries'],
306
- additionalProperties: false,
307
- }),
308
- JSON.stringify({
309
- banDuration: { 'ui:widget': 'duration' },
310
- }),
311
- );
312
-
313
- this.permissions = [
314
- new IPermission({
315
- permission: 'GEOBLOCK_IMMUNITY',
316
- friendlyName: 'GeoBlock immunity',
317
- description: 'Players with this permission will not be kicked or banned by GeoBlock.',
318
- canHaveCount: false,
319
- }),
320
- ];
321
-
322
- this.commands = [];
323
- this.hooks = [
324
- new IHook({
325
- eventType: HookEvents.PLAYER_NEW_IP_DETECTED,
326
- name: 'IPDetected',
327
- function: this.loadFn('hooks', 'IPDetected'),
309
+ required: ['countries'],
310
+ additionalProperties: false,
311
+ }),
312
+ uiSchema: JSON.stringify({
313
+ banDuration: { 'ui:widget': 'duration' },
314
+ }),
315
+ permissions: [
316
+ new IPermission({
317
+ permission: 'GEOBLOCK_IMMUNITY',
318
+ friendlyName: 'GeoBlock immunity',
319
+ description: 'Players with this permission will not be kicked or banned by GeoBlock.',
320
+ canHaveCount: false,
321
+ }),
322
+ ],
323
+ hooks: [
324
+ new IHook({
325
+ eventType: HookEvents.PLAYER_NEW_IP_DETECTED,
326
+ name: 'IPDetected',
327
+ function: this.loadFn('hooks', 'IPDetected'),
328
+ }),
329
+ ],
328
330
  }),
329
331
  ];
330
332
  }
@@ -15,12 +15,22 @@ async function main() {
15
15
  const randomOption = items.concat(commands)[randomIndex];
16
16
 
17
17
  if (randomIndex < items.length) {
18
- await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {
19
- name: randomOption,
20
- amount: 1,
21
- quality: '0',
22
- });
23
- await data.player.pm(`You received ${randomOption}!`);
18
+ if (typeof randomOption === 'string') {
19
+ await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {
20
+ name: randomOption,
21
+ amount: 1,
22
+ quality: '0',
23
+ });
24
+ await data.player.pm(`You received ${randomOption}!`);
25
+ } else {
26
+ const item = (await takaro.item.itemControllerFindOne(randomOption.item)).data.data;
27
+ await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {
28
+ name: item.code,
29
+ amount: randomOption.amount,
30
+ quality: randomOption.quality ?? '',
31
+ });
32
+ await data.player.pm(`You received ${randomOption.amount}x ${item.name}!`);
33
+ }
24
34
  } else {
25
35
  await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: randomOption });
26
36
  }