@takaro/modules 0.0.13 → 0.0.15
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.
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -1
- package/dist/modules/dailyRewards/commands/daily.d.ts +1 -0
- package/dist/modules/dailyRewards/commands/daily.js +106 -0
- package/dist/modules/dailyRewards/commands/daily.js.map +1 -0
- package/dist/modules/dailyRewards/commands/streak.d.ts +1 -0
- package/dist/modules/dailyRewards/commands/streak.js +34 -0
- package/dist/modules/dailyRewards/commands/streak.js.map +1 -0
- package/dist/modules/dailyRewards/commands/topstreak.d.ts +1 -0
- package/dist/modules/dailyRewards/commands/topstreak.js +44 -0
- package/dist/modules/dailyRewards/commands/topstreak.js.map +1 -0
- package/dist/modules/dailyRewards/functions/utils.d.ts +5 -0
- package/dist/modules/dailyRewards/functions/utils.js +32 -0
- package/dist/modules/dailyRewards/functions/utils.js.map +1 -0
- package/dist/modules/dailyRewards/hooks/dailyLoginCheck.d.ts +1 -0
- package/dist/modules/dailyRewards/hooks/dailyLoginCheck.js +19 -0
- package/dist/modules/dailyRewards/hooks/dailyLoginCheck.js.map +1 -0
- package/dist/modules/dailyRewards/index.d.ts +4 -0
- package/dist/modules/dailyRewards/index.js +117 -0
- package/dist/modules/dailyRewards/index.js.map +1 -0
- package/dist/modules/economyUtils/commands/shop.js +6 -6
- package/dist/modules/economyUtils/commands/shop.js.map +1 -1
- package/dist/modules/economyUtils/cronJobs/zombieKillReward.d.ts +1 -0
- package/dist/modules/economyUtils/cronJobs/zombieKillReward.js +66 -0
- package/dist/modules/economyUtils/cronJobs/zombieKillReward.js.map +1 -0
- package/dist/modules/economyUtils/index.js +21 -2
- package/dist/modules/economyUtils/index.js.map +1 -1
- package/dist/modules/geoBlock/hooks/IPDetected.js +4 -2
- package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -1
- package/dist/modules/gimme/commands/gimme.js +17 -6
- package/dist/modules/gimme/commands/gimme.js.map +1 -1
- package/dist/modules/gimme/index.js +23 -2
- package/dist/modules/gimme/index.js.map +1 -1
- package/dist/modules/playerOnboarding/commands/starterkit.js +16 -3
- package/dist/modules/playerOnboarding/commands/starterkit.js.map +1 -1
- package/dist/modules/playerOnboarding/index.js +24 -3
- package/dist/modules/playerOnboarding/index.js.map +1 -1
- package/dist/modules.json +88 -11
- package/package.json +1 -1
- package/scripts/buildBuiltinJson.ts +46 -2
- package/src/__tests__/economy/shop.integration.test.ts +23 -0
- package/src/__tests__/economy/zombieKillReward.integration.test.ts +296 -0
- package/src/__tests__/gimme.integration.test.ts +8 -2
- package/src/__tests__/onboarding.integration.test.ts +23 -20
- package/src/main.ts +2 -0
- package/src/modules/dailyRewards/commands/daily.js +118 -0
- package/src/modules/dailyRewards/commands/streak.js +42 -0
- package/src/modules/dailyRewards/commands/topstreak.js +54 -0
- package/src/modules/dailyRewards/functions/utils.js +36 -0
- package/src/modules/dailyRewards/hooks/dailyLoginCheck.js +24 -0
- package/src/modules/dailyRewards/index.ts +126 -0
- package/src/modules/economyUtils/commands/shop.js +6 -6
- package/src/modules/economyUtils/cronJobs/zombieKillReward.js +82 -0
- package/src/modules/economyUtils/index.ts +23 -2
- package/src/modules/geoBlock/hooks/IPDetected.js +4 -2
- package/src/modules/gimme/commands/gimme.js +16 -6
- package/src/modules/gimme/index.ts +23 -2
- package/src/modules/playerOnboarding/commands/starterkit.js +19 -5
- package/src/modules/playerOnboarding/index.ts +24 -3
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/economyUtils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,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M;gBACZ,OAAO,EAAE,MAAM;gBACf,QAAQ,EAAE,2CAA2C;gBACrD,SAAS,EAAE;oBACT;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,QAAQ;wBACd,QAAQ,EAAE,+DAA+D;wBACzE,QAAQ,EAAE,CAAC;wBACX,YAAY,EAAE,GAAG;qBAClB;oBACD;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,QAAQ;wBACd,QAAQ,EAAE,8CAA8C;wBACxD,QAAQ,EAAE,CAAC;wBACX,YAAY,EAAE,GAAG;qBAClB;oBACD;wBACE,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,QAAQ;wBACd,QAAQ,EAAE,4EAA4E;wBACtF,QAAQ,EAAE,CAAC;wBACX,YAAY,EAAE,MAAM;qBACrB;iBACF;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -7,9 +7,11 @@ async function main() {
|
|
|
7
7
|
if (ban) {
|
|
8
8
|
const now = new Date();
|
|
9
9
|
const expiresAt = new Date(now.getTime() + banDuration * 1000);
|
|
10
|
-
await takaro.
|
|
10
|
+
await takaro.player.banControllerCreate({
|
|
11
|
+
gameServerId,
|
|
12
|
+
playerId: player.id,
|
|
13
|
+
until: expiresAt,
|
|
11
14
|
reason: message,
|
|
12
|
-
expiresAt,
|
|
13
15
|
});
|
|
14
16
|
}
|
|
15
17
|
else {
|
|
@@ -1 +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,MAAM,iBAAiB,CAAC;AAEhE,KAAK,UAAU,IAAI;IACjB,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC3C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;IACnC,MAAM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,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,EAAE;gBAC9E,MAAM,EAAE,OAAO;aAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;IAC3D,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAC9C,OAAO;IACT,CAAC;IAED,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,IAAI,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;YACnD,OAAO;QACT,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;QAC5D,MAAM,YAAY,EAAE,CAAC;QACrB,OAAO;IACT,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"}
|
|
@@ -9,12 +9,23 @@ async function main() {
|
|
|
9
9
|
const randomIndex = Math.floor(Math.random() * (items.length + commands.length));
|
|
10
10
|
const randomOption = items.concat(commands)[randomIndex];
|
|
11
11
|
if (randomIndex < items.length) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
if (typeof randomOption === 'string') {
|
|
13
|
+
await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {
|
|
14
|
+
name: randomOption,
|
|
15
|
+
amount: 1,
|
|
16
|
+
quality: '0',
|
|
17
|
+
});
|
|
18
|
+
await data.player.pm(`You received ${randomOption}!`);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const item = (await takaro.item.itemControllerFindOne(randomOption.item)).data.data;
|
|
22
|
+
await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {
|
|
23
|
+
name: item.code,
|
|
24
|
+
amount: randomOption.amount,
|
|
25
|
+
quality: randomOption.quality ?? '',
|
|
26
|
+
});
|
|
27
|
+
await data.player.pm(`You received ${randomOption.amount}x ${item.name}!`);
|
|
28
|
+
}
|
|
18
29
|
}
|
|
19
30
|
else {
|
|
20
31
|
await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: randomOption });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gimme.js","sourceRoot":"","sources":["../../../../src/modules/gimme/commands/gimme.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEhE,KAAK,UAAU,IAAI;IACjB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;IAEjD,IAAI,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,eAAe,CACvB,iGAAiG,CAClG,CAAC;IACJ,CAAC;IAED,oFAAoF;IACpF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACjF,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC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AM,CAAC,EAAE,CAAC,gBAAgB,YAAY,GAAG,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YACpF,MAAM,MAAM,CAAC,UAAU,CAAC,4BAA4B,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;gBACtF,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,MAAM,EAAE,YAAY,CAAC,MAAM;gBAC3B,OAAO,EAAE,YAAY,CAAC,OAAO,IAAI,EAAE;aACpC,CAAC,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,YAAY,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;IAC3G,CAAC;AACH,CAAC;AAED,MAAM,IAAI,EAAE,CAAC"}
|
|
@@ -12,7 +12,22 @@ export class Gimme extends BuiltinModule {
|
|
|
12
12
|
description: 'List of items that a player can receive.',
|
|
13
13
|
uniqueItems: true,
|
|
14
14
|
items: {
|
|
15
|
-
type: '
|
|
15
|
+
type: 'object',
|
|
16
|
+
title: 'Item',
|
|
17
|
+
properties: {
|
|
18
|
+
item: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
title: 'Item',
|
|
21
|
+
},
|
|
22
|
+
amount: {
|
|
23
|
+
type: 'number',
|
|
24
|
+
title: 'Amount',
|
|
25
|
+
},
|
|
26
|
+
quality: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
title: 'Quality',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
16
31
|
},
|
|
17
32
|
},
|
|
18
33
|
commands: {
|
|
@@ -27,7 +42,13 @@ export class Gimme extends BuiltinModule {
|
|
|
27
42
|
required: ['items'],
|
|
28
43
|
additionalProperties: false,
|
|
29
44
|
}), JSON.stringify({
|
|
30
|
-
items: {
|
|
45
|
+
items: {
|
|
46
|
+
items: {
|
|
47
|
+
item: {
|
|
48
|
+
'ui:widget': 'item',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
31
52
|
}));
|
|
32
53
|
this.commands = [
|
|
33
54
|
new ICommand({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/gimme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,OAAO,KAAM,SAAQ,aAAoB;IAC7C;QACE,KAAK,CACH,OAAO,EACP,gDAAgD,EAChD,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,yCAAyC;YAClD,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,aAAa,EAAE,MAAM;oBACrB,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,OAAO;oBACd,WAAW,EAAE,0CAA0C;oBACvD,WAAW,EAAE,IAAI;oBACjB,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/gimme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,OAAO,KAAM,SAAQ,aAAoB;IAC7C;QACE,KAAK,CACH,OAAO,EACP,gDAAgD,EAChD,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,yCAAyC;YAClD,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,aAAa,EAAE,MAAM;oBACrB,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,OAAO;oBACd,WAAW,EAAE,0CAA0C;oBACvD,WAAW,EAAE,IAAI;oBACjB,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,MAAM;wBACb,UAAU,EAAE;4BACV,IAAI,EAAE;gCACJ,IAAI,EAAE,QAAQ;gCACd,KAAK,EAAE,MAAM;6BACd;4BACD,MAAM,EAAE;gCACN,IAAI,EAAE,QAAQ;gCACd,KAAK,EAAE,QAAQ;6BAChB;4BACD,OAAO,EAAE;gCACP,IAAI,EAAE,QAAQ;gCACd,KAAK,EAAE,SAAS;6BACjB;yBACF;qBACF;iBACF;gBACD,QAAQ,EAAE;oBACR,KAAK,EAAE,UAAU;oBACjB,IAAI,EAAE,OAAO;oBACb,OAAO,EAAE,CAAC,sBAAsB,CAAC;oBACjC,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;YACD,QAAQ,EAAE,CAAC,OAAO,CAAC;YACnB,oBAAoB,EAAE,KAAK;SAC5B,CAAC,EACF,IAAI,CAAC,SAAS,CAAC;YACb,KAAK,EAAE;gBACL,KAAK,EAAE;oBACL,IAAI,EAAE;wBACJ,WAAW,EAAE,MAAM;qBACpB;iBACF;aACF;SACF,CAAC,CACH,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,QAAQ,CAAC;gBACX,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC;gBAC1C,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,0DAA0D;gBACpE,SAAS,EAAE,EAAE;aACd,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -16,10 +16,23 @@ async function main() {
|
|
|
16
16
|
throw new TakaroUserError('You already used starterkit on this server');
|
|
17
17
|
}
|
|
18
18
|
await data.player.pm('You are about to receive your starter kit...');
|
|
19
|
-
await
|
|
19
|
+
const itemRecords = (await takaro.item.itemControllerSearch({ filters: { id: items.map((_) => _.item) } })).data.data;
|
|
20
|
+
const fullItems = items.map((item) => {
|
|
21
|
+
const itemRecord = itemRecords.find((record) => record.id === item.item);
|
|
22
|
+
if (!itemRecord) {
|
|
23
|
+
throw new TakaroUserError(`Item with ID ${item.item} not found.`);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
code: itemRecord.code,
|
|
27
|
+
quality: item.quality,
|
|
28
|
+
amount: item.amount,
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
await Promise.all(fullItems.map(async (item) => {
|
|
20
32
|
return takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {
|
|
21
|
-
name: item,
|
|
22
|
-
|
|
33
|
+
name: item.code,
|
|
34
|
+
quality: item.quality ?? '',
|
|
35
|
+
amount: item.amount,
|
|
23
36
|
});
|
|
24
37
|
}));
|
|
25
38
|
await takaro.variable.variableControllerCreate({
|
|
@@ -1 +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,CA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ACV,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"}
|
|
@@ -16,19 +16,40 @@ export class PlayerOnboarding extends BuiltinModule {
|
|
|
16
16
|
},
|
|
17
17
|
starterKitItems: {
|
|
18
18
|
type: 'array',
|
|
19
|
-
'x-component': 'item',
|
|
20
19
|
title: 'Starter kit items',
|
|
20
|
+
'x-component': 'item',
|
|
21
21
|
description: 'List of items a player will receive when they execute the starterkit command for the first time.',
|
|
22
22
|
uniqueItems: true,
|
|
23
23
|
items: {
|
|
24
|
-
type: '
|
|
24
|
+
type: 'object',
|
|
25
|
+
title: 'Item',
|
|
26
|
+
properties: {
|
|
27
|
+
item: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
title: 'Item',
|
|
30
|
+
},
|
|
31
|
+
amount: {
|
|
32
|
+
type: 'number',
|
|
33
|
+
title: 'Amount',
|
|
34
|
+
},
|
|
35
|
+
quality: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
title: 'Quality',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
25
40
|
},
|
|
26
41
|
},
|
|
27
42
|
},
|
|
28
43
|
required: [],
|
|
29
44
|
additionalProperties: false,
|
|
30
45
|
}), JSON.stringify({
|
|
31
|
-
starterKitItems: {
|
|
46
|
+
starterKitItems: {
|
|
47
|
+
items: {
|
|
48
|
+
item: {
|
|
49
|
+
'ui:widget': 'item',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
32
53
|
}));
|
|
33
54
|
this.hooks = [
|
|
34
55
|
new IHook({
|
|
@@ -1 +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;AAEhD,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,
|
|
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;AAEhD,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,KAAK,EAAE,mBAAmB;oBAC1B,aAAa,EAAE,MAAM;oBACrB,WAAW,EACT,kGAAkG;oBACpG,WAAW,EAAE,IAAI;oBACjB,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,MAAM;wBACb,UAAU,EAAE;4BACV,IAAI,EAAE;gCACJ,IAAI,EAAE,QAAQ;gCACd,KAAK,EAAE,MAAM;6BACd;4BACD,MAAM,EAAE;gCACN,IAAI,EAAE,QAAQ;gCACd,KAAK,EAAE,QAAQ;6BAChB;4BACD,OAAO,EAAE;gCACP,IAAI,EAAE,QAAQ;gCACd,KAAK,EAAE,SAAS;6BACjB;yBACF;qBACF;iBACF;aACF;YACD,QAAQ,EAAE,EAAE;YACZ,oBAAoB,EAAE,KAAK;SAC5B,CAAC,EACF,IAAI,CAAC,SAAS,CAAC;YACb,eAAe,EAAE;gBACf,KAAK,EAAE;oBACL,IAAI,EAAE;wBACJ,WAAW,EAAE,MAAM;qBACpB;iBACF;aACF;SACF,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"}
|
package/dist/modules.json
CHANGED
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
"commands": [
|
|
200
200
|
{
|
|
201
201
|
"name": "starterkit",
|
|
202
|
-
"function": "import { takaro, data, TakaroUserError } from '@takaro/helpers';\nconst VARIABLE_KEY = 't_starterkit_lock';\nasync function main() {\n const items = data.module.userConfig.starterKitItems;\n if (!items || items.length === 0) {\n throw new TakaroUserError('No starter kit items configured. Please ask your server administrator to configure this.');\n }\n const starterKitLockRes = await takaro.variable.variableControllerSearch({\n filters: {\n key: [VARIABLE_KEY],\n gameServerId: [data.gameServerId],\n playerId: [data.player.id],\n },\n });\n if (starterKitLockRes.data.data.length > 0) {\n throw new TakaroUserError('You already used starterkit on this server');\n }\n await data.player.pm('You are about to receive your starter kit...');\n await Promise.all(
|
|
202
|
+
"function": "import { takaro, data, TakaroUserError } from '@takaro/helpers';\nconst VARIABLE_KEY = 't_starterkit_lock';\nasync function main() {\n const items = data.module.userConfig.starterKitItems;\n if (!items || items.length === 0) {\n throw new TakaroUserError('No starter kit items configured. Please ask your server administrator to configure this.');\n }\n const starterKitLockRes = await takaro.variable.variableControllerSearch({\n filters: {\n key: [VARIABLE_KEY],\n gameServerId: [data.gameServerId],\n playerId: [data.player.id],\n },\n });\n if (starterKitLockRes.data.data.length > 0) {\n throw new TakaroUserError('You already used starterkit on this server');\n }\n await data.player.pm('You are about to receive your starter kit...');\n const itemRecords = (await takaro.item.itemControllerSearch({ filters: { id: items.map((_) => _.item) } })).data.data;\n const fullItems = items.map((item) => {\n const itemRecord = itemRecords.find((record) => record.id === item.item);\n if (!itemRecord) {\n throw new TakaroUserError(`Item with ID ${item.item} not found.`);\n }\n return {\n code: itemRecord.code,\n quality: item.quality,\n amount: item.amount,\n };\n });\n await Promise.all(fullItems.map(async (item) => {\n return takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {\n name: item.code,\n quality: item.quality ?? '',\n amount: item.amount,\n });\n }));\n await takaro.variable.variableControllerCreate({\n key: VARIABLE_KEY,\n value: '1',\n gameServerId: data.gameServerId,\n playerId: data.player.id,\n });\n await data.player.pm(`Gave ${items.length} items, enjoy!`);\n}\nawait main();\n//# sourceMappingURL=starterkit.js.map",
|
|
203
203
|
"trigger": "starterkit",
|
|
204
204
|
"helpText": "Get a starter kit, you can only execute this once on a server!",
|
|
205
205
|
"arguments": []
|
|
@@ -217,8 +217,8 @@
|
|
|
217
217
|
"permissions": [],
|
|
218
218
|
"name": "playerOnboarding",
|
|
219
219
|
"description": "Collection of functions that are executed when a player joins the server. Helps with onboarding new players, like sending a welcome message.",
|
|
220
|
-
"configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{\"message\":{\"title\":\"Message\",\"description\":\"The message to send to the player when they join the server.\",\"type\":\"string\",\"minLength\":1,\"maxLength\":256,\"default\":\"Welcome {player} to the server!\"},\"starterKitItems\":{\"type\":\"array\",\"
|
|
221
|
-
"uiSchema": "{\"starterKitItems\":{\"ui:widget\":\"item\"}}"
|
|
220
|
+
"configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{\"message\":{\"title\":\"Message\",\"description\":\"The message to send to the player when they join the server.\",\"type\":\"string\",\"minLength\":1,\"maxLength\":256,\"default\":\"Welcome {player} to the server!\"},\"starterKitItems\":{\"type\":\"array\",\"title\":\"Starter kit items\",\"x-component\":\"item\",\"description\":\"List of items a player will receive when they execute the starterkit command for the first time.\",\"uniqueItems\":true,\"items\":{\"type\":\"object\",\"title\":\"Item\",\"properties\":{\"item\":{\"type\":\"string\",\"title\":\"Item\"},\"amount\":{\"type\":\"number\",\"title\":\"Amount\"},\"quality\":{\"type\":\"string\",\"title\":\"Quality\"}}}}},\"required\":[],\"additionalProperties\":false}",
|
|
221
|
+
"uiSchema": "{\"starterKitItems\":{\"items\":{\"item\":{\"ui:widget\":\"item\"}}}}"
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
224
|
"commands": [],
|
|
@@ -272,7 +272,7 @@
|
|
|
272
272
|
{
|
|
273
273
|
"commands": [
|
|
274
274
|
{
|
|
275
|
-
"function": "import { takaro, data, TakaroUserError } from '@takaro/helpers';\nasync function main() {\n const items = data.module.userConfig.items;\n const commands = data.module.userConfig.commands;\n if (items.length + commands.length === 0) {\n throw new TakaroUserError('No items or commands configured, please ask your server administrator to configure this module.');\n }\n // pick a random item between 0 and the length of both the items and commands arrays\n const randomIndex = Math.floor(Math.random() * (items.length + commands.length));\n const randomOption = items.concat(commands)[randomIndex];\n if (randomIndex < items.length) {\n await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {\n
|
|
275
|
+
"function": "import { takaro, data, TakaroUserError } from '@takaro/helpers';\nasync function main() {\n const items = data.module.userConfig.items;\n const commands = data.module.userConfig.commands;\n if (items.length + commands.length === 0) {\n throw new TakaroUserError('No items or commands configured, please ask your server administrator to configure this module.');\n }\n // pick a random item between 0 and the length of both the items and commands arrays\n const randomIndex = Math.floor(Math.random() * (items.length + commands.length));\n const randomOption = items.concat(commands)[randomIndex];\n if (randomIndex < items.length) {\n if (typeof randomOption === 'string') {\n await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {\n name: randomOption,\n amount: 1,\n quality: '0',\n });\n await data.player.pm(`You received ${randomOption}!`);\n }\n else {\n const item = (await takaro.item.itemControllerFindOne(randomOption.item)).data.data;\n await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {\n name: item.code,\n amount: randomOption.amount,\n quality: randomOption.quality ?? '',\n });\n await data.player.pm(`You received ${randomOption.amount}x ${item.name}!`);\n }\n }\n else {\n await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: randomOption });\n }\n}\nawait main();\n//# sourceMappingURL=gimme.js.map",
|
|
276
276
|
"name": "gimme",
|
|
277
277
|
"trigger": "gimme",
|
|
278
278
|
"helpText": "Randomly selects item from a list of items and entities.",
|
|
@@ -285,8 +285,8 @@
|
|
|
285
285
|
"permissions": [],
|
|
286
286
|
"name": "gimme",
|
|
287
287
|
"description": "Randomly selects an item from a list of items.",
|
|
288
|
-
"configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{\"items\":{\"x-component\":\"item\",\"type\":\"array\",\"title\":\"Items\",\"description\":\"List of items that a player can receive.\",\"uniqueItems\":true,\"items\":{\"type\":\"string\"}},\"commands\":{\"title\":\"Commands\",\"type\":\"array\",\"default\":[\"say hello from gimme\"],\"items\":{\"type\":\"string\"}}},\"required\":[\"items\"],\"additionalProperties\":false}",
|
|
289
|
-
"uiSchema": "{\"items\":{\"ui:widget\":\"item\"}}"
|
|
288
|
+
"configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{\"items\":{\"x-component\":\"item\",\"type\":\"array\",\"title\":\"Items\",\"description\":\"List of items that a player can receive.\",\"uniqueItems\":true,\"items\":{\"type\":\"object\",\"title\":\"Item\",\"properties\":{\"item\":{\"type\":\"string\",\"title\":\"Item\"},\"amount\":{\"type\":\"number\",\"title\":\"Amount\"},\"quality\":{\"type\":\"string\",\"title\":\"Quality\"}}}},\"commands\":{\"title\":\"Commands\",\"type\":\"array\",\"default\":[\"say hello from gimme\"],\"items\":{\"type\":\"string\"}}},\"required\":[\"items\"],\"additionalProperties\":false}",
|
|
289
|
+
"uiSchema": "{\"items\":{\"items\":{\"item\":{\"ui:widget\":\"item\"}}}}"
|
|
290
290
|
},
|
|
291
291
|
{
|
|
292
292
|
"commands": [],
|
|
@@ -347,7 +347,7 @@
|
|
|
347
347
|
"function": "import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';\nasync function main() {\n const { pog: revoker, arguments: args, gameServerId } = data;\n // args.receiver has an argument type of \"player\". Arguments of this type are automatically resolved to the player's id.\n // 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.\n const receiver = args.receiver;\n if (!checkPermission(revoker, 'ECONOMY_UTILS_MANAGE_CURRENCY')) {\n throw new TakaroUserError('You do not have permission to use revoke currency command.');\n }\n const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value;\n const revokerName = (await takaro.player.playerControllerGetOne(revoker.playerId)).data.data.name;\n const receiverName = (await takaro.player.playerControllerGetOne(receiver.playerId)).data.data.name;\n await takaro.playerOnGameserver.playerOnGameServerControllerDeductCurrency(receiver.gameServerId, receiver.playerId, {\n currency: args.amount,\n });\n const messageToReceiver = takaro.gameserver.gameServerControllerSendMessage(gameServerId, {\n message: `${args.amount} ${currencyName} were revoked by ${revokerName}`,\n opts: {\n recipient: {\n gameId: receiver.gameId,\n },\n },\n });\n await Promise.all([\n revoker.pm(`You successfully revoked ${args.amount} ${currencyName} of ${receiverName}'s balance`),\n messageToReceiver,\n ]);\n return;\n}\nawait main();\n//# sourceMappingURL=revokeCurrency.js.map",
|
|
348
348
|
"name": "revokeCurrency",
|
|
349
349
|
"trigger": "revokecurrency",
|
|
350
|
-
"helpText": "
|
|
350
|
+
"helpText": "Revokes money from a player. The money disappears.",
|
|
351
351
|
"arguments": [
|
|
352
352
|
{
|
|
353
353
|
"name": "receiver",
|
|
@@ -410,7 +410,7 @@
|
|
|
410
410
|
]
|
|
411
411
|
},
|
|
412
412
|
{
|
|
413
|
-
"function": "import { takaro, data, TakaroUserError } from '@takaro/helpers';\nasync function main() {\n const { arguments: args, player, gameServerId
|
|
413
|
+
"function": "import { takaro, data, TakaroUserError } from '@takaro/helpers';\nasync function main() {\n const { arguments: args, player, gameServerId } = data;\n const { page, item, action } = args;\n const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value;\n // If command is called without any arguments\n const messageWithoutPrefix = data.chatMessage.msg.slice(prefix.length).trim();\n if (!messageWithoutPrefix.includes(' ')) {\n await player.pm('This command allows you to browse the shop and view available items.');\n await player.pm(`Usage: ${prefix}shop [page] [item] [action]`);\n await player.pm(`${prefix}shop 2 - View the second page of shop items`);\n await player.pm(`${prefix}shop 1 3 - View details about the third item on the first page`);\n await player.pm(`${prefix}shop 1 3 buy - Purchase the third item on the first page`);\n return;\n }\n const shopItems = await takaro.shopListing.shopListingControllerSearch({\n limit: 5,\n page: page - 1,\n sortBy: 'name',\n sortDirection: 'asc',\n filters: {\n gameServerId: [gameServerId],\n draft: false,\n },\n });\n if (shopItems.data.data.length === 0) {\n await player.pm('No items found.');\n return;\n }\n const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', data.gameServerId)).data.data;\n if (!item) {\n // List the shop items with index\n let index = 1;\n for (const listing of shopItems.data.data) {\n const items = listing.items.slice(0, 3).map((item) => {\n return `${item.amount}x ${item.item.name}`;\n });\n await player.pm(`${index} - ${listing.name} - ${listing.price} ${currencyName.value}. ${items.join(', ')}`);\n index++;\n }\n return;\n }\n const selectedItem = shopItems.data.data[item - 1];\n if (!selectedItem)\n throw new TakaroUserError(`Item not found. Please select an item from the list, valid options are 1-${shopItems.data.data.length}.`);\n if (action === 'none') {\n // Display more info about the item\n await player.pm(`Listing ${selectedItem.name} - ${selectedItem.price} ${currencyName.value}`);\n await Promise.all(selectedItem.items.map((item) => {\n const quality = item.quality ? `Quality: ${item.quality}` : '';\n const description = (item.item.description ? `Description: ${item.item.description}` : '').replaceAll('\\\\n', ' ');\n return player.pm(`- ${item.amount}x ${item.item.name}. ${quality} ${description}`);\n }));\n return;\n }\n if (action === 'buy') {\n const orderRes = await takaro.shopOrder.shopOrderControllerCreate({\n amount: 1,\n listingId: selectedItem.id,\n playerId: player.id,\n });\n await player.pm(`You have purchased ${selectedItem.name} for ${selectedItem.price} ${currencyName.value}.`);\n await takaro.shopOrder.shopOrderControllerClaim(orderRes.data.data.id);\n return;\n }\n throw new TakaroUserError('Invalid action. Valid actions are \"buy\".');\n}\nawait main();\n//# sourceMappingURL=shop.js.map",
|
|
414
414
|
"name": "shop",
|
|
415
415
|
"trigger": "shop",
|
|
416
416
|
"helpText": "Browse the shop and view available items.",
|
|
@@ -440,7 +440,13 @@
|
|
|
440
440
|
}
|
|
441
441
|
],
|
|
442
442
|
"hooks": [],
|
|
443
|
-
"cronJobs": [
|
|
443
|
+
"cronJobs": [
|
|
444
|
+
{
|
|
445
|
+
"function": "import { data, takaro, checkPermission } from '@takaro/helpers';\nconst VARIABLE_KEY = 'lastZombieKillReward';\nasync function main() {\n const { gameServerId, module: mod } = data;\n const lastRunRes = (await takaro.variable.variableControllerSearch({\n filters: {\n key: [VARIABLE_KEY],\n gameServerId: [gameServerId],\n moduleId: [mod.moduleId],\n },\n })).data.data;\n // We last ran the rewards script at this time\n // If this is the first time we run it, just get the last 5 minutes\n const lastRun = lastRunRes.length ? new Date(JSON.parse(lastRunRes[0].value)) : new Date(Date.now() - 5 * 60 * 1000);\n // Fetch all the kill events since the last time we gave out rewards\n const killEvents = (await takaro.event.eventControllerSearch({\n filters: { eventName: ['entity-killed'], gameserverId: [gameServerId] },\n greaterThan: { createdAt: lastRun.toISOString() },\n limit: 1000,\n })).data.data;\n console.log(`Found ${killEvents.length} kill events since ${lastRun.toISOString()}`);\n // Group the events by player\n const playerKills = {};\n for (const killEvent of killEvents) {\n if (!playerKills[killEvent.playerId]) {\n playerKills[killEvent.playerId] = [];\n }\n playerKills[killEvent.playerId].push(killEvent);\n }\n // Give each player their reward\n // We use Promise.allSettled to run this concurrently\n const results = await Promise.allSettled(Object.entries(playerKills).map(async ([playerId, kills]) => {\n const pog = (await takaro.playerOnGameserver.playerOnGameServerControllerGetOne(gameServerId, playerId)).data\n .data;\n const hasPermission = checkPermission(pog, 'ZOMBIE_KILL_REWARD_OVERRIDE');\n const defaultReward = mod.userConfig.zombieKillReward;\n const reward = hasPermission && hasPermission.count != null ? hasPermission.count : defaultReward;\n const totalReward = reward * kills.length;\n return takaro.playerOnGameserver.playerOnGameServerControllerAddCurrency(gameServerId, playerId, {\n currency: totalReward,\n });\n }));\n // Log any errors\n for (const result of results) {\n if (result.status === 'rejected') {\n console.error(result.reason);\n throw new Error(`Failed to give rewards: ${result.reason}`);\n }\n }\n // Update the last run time\n if (lastRunRes.length) {\n await takaro.variable.variableControllerUpdate(lastRunRes[0].id, {\n value: JSON.stringify(new Date()),\n });\n }\n else {\n await takaro.variable.variableControllerCreate({\n key: VARIABLE_KEY,\n value: JSON.stringify(new Date()),\n moduleId: mod.moduleId,\n gameServerId,\n });\n }\n}\nawait main();\n//# sourceMappingURL=zombieKillReward.js.map",
|
|
446
|
+
"name": "zombieKillReward",
|
|
447
|
+
"temporalValue": "*/5 * * * *"
|
|
448
|
+
}
|
|
449
|
+
],
|
|
444
450
|
"functions": [],
|
|
445
451
|
"permissions": [
|
|
446
452
|
{
|
|
@@ -448,11 +454,17 @@
|
|
|
448
454
|
"friendlyName": "Manage currency",
|
|
449
455
|
"description": "Allows players to manage currency of other players. This includes granting and revoking currency.",
|
|
450
456
|
"canHaveCount": false
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
"permission": "ZOMBIE_KILL_REWARD_OVERRIDE",
|
|
460
|
+
"friendlyName": "Zombie kill reward override",
|
|
461
|
+
"description": "Allows a role to override the amount of currency a player receives for killing a entity.",
|
|
462
|
+
"canHaveCount": true
|
|
451
463
|
}
|
|
452
464
|
],
|
|
453
465
|
"name": "economyUtils",
|
|
454
466
|
"description": "A set of commands to allow players to manage their currency.",
|
|
455
|
-
"configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{\"pendingAmount\":{\"title\":\"Pending amount\",\"type\":\"number\",\"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.\",\"default\":0}},\"required\":[],\"additionalProperties\":false}",
|
|
467
|
+
"configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{\"pendingAmount\":{\"title\":\"Pending amount\",\"type\":\"number\",\"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.\",\"default\":0},\"zombieKillReward\":{\"title\":\"Zombie kill reward\",\"type\":\"number\",\"description\":\"The default amount of currency a player receives for killing a zombie. This can be overridden by roles.\",\"default\":1}},\"required\":[],\"additionalProperties\":false}",
|
|
456
468
|
"uiSchema": "{}"
|
|
457
469
|
},
|
|
458
470
|
{
|
|
@@ -521,7 +533,7 @@
|
|
|
521
533
|
{
|
|
522
534
|
"eventType": "player-new-ip-detected",
|
|
523
535
|
"name": "IPDetected",
|
|
524
|
-
"function": "import { takaro, data, checkPermission } from '@takaro/helpers';\nasync function main() {\n const { gameServerId, player, pog } = data;\n const { country } = data.eventData;\n const { ban, banDuration, countries, message, mode } = data.module.userConfig;\n async function handleAction() {\n if (ban) {\n const now = new Date();\n const expiresAt = new Date(now.getTime() + banDuration * 1000);\n await takaro.
|
|
536
|
+
"function": "import { takaro, data, checkPermission } from '@takaro/helpers';\nasync function main() {\n const { gameServerId, player, pog } = data;\n const { country } = data.eventData;\n const { ban, banDuration, countries, message, mode } = data.module.userConfig;\n async function handleAction() {\n if (ban) {\n const now = new Date();\n const expiresAt = new Date(now.getTime() + banDuration * 1000);\n await takaro.player.banControllerCreate({\n gameServerId,\n playerId: player.id,\n until: expiresAt,\n reason: message,\n });\n }\n else {\n await takaro.gameserver.gameServerControllerKickPlayer(gameServerId, player.id, {\n reason: message,\n });\n }\n }\n const isImmune = checkPermission(pog, 'GEOBLOCK_IMMUNITY');\n if (isImmune) {\n console.log('Player has immunity, no action');\n return;\n }\n if (mode === 'allow') {\n if (countries.includes(country)) {\n console.log('Allowed country detected, no action');\n return;\n }\n console.log('Blocked country detected, performing actions');\n await handleAction();\n return;\n }\n if (mode === 'deny') {\n if (countries.includes(country)) {\n console.log('Blocked country detected, performing actions');\n await handleAction();\n return;\n }\n else {\n console.log('Allowed country detected, no action');\n return;\n }\n }\n}\nawait main();\n//# sourceMappingURL=IPDetected.js.map"
|
|
525
537
|
}
|
|
526
538
|
],
|
|
527
539
|
"cronJobs": [],
|
|
@@ -560,5 +572,70 @@
|
|
|
560
572
|
"description": "Automatically shut down the server at a specific time.",
|
|
561
573
|
"configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{\"warningMessage\":{\"type\":\"string\",\"title\":\"Warning message\",\"description\":\"Message to send to players before the server shuts down.\",\"default\":\"Server is shutting down in 5 minutes!\",\"minLength\":1,\"maxLength\":1024}},\"required\":[\"warningMessage\"]}",
|
|
562
574
|
"uiSchema": "{}"
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
"commands": [
|
|
578
|
+
{
|
|
579
|
+
"function": "import { takaro, data, TakaroUserError, checkPermission } from '@takaro/helpers';\nimport { DAILY_KEY, STREAK_KEY, getMultiplier } from './utils.js';\nasync function main() {\n const { pog, gameServerId, module: mod } = data;\n if (!checkPermission(pog, 'DAILY_CLAIM')) {\n throw new TakaroUserError('You do not have permission to claim daily rewards.');\n }\n // Get last claim time\n const lastClaimRes = await takaro.variable.variableControllerSearch({\n filters: {\n key: [DAILY_KEY],\n gameServerId: [gameServerId],\n playerId: [pog.playerId],\n moduleId: [mod.moduleId],\n },\n });\n const now = new Date();\n let streak = 1;\n if (lastClaimRes.data.data.length > 0) {\n const lastClaim = new Date(JSON.parse(lastClaimRes.data.data[0].value));\n const hoursSinceLastClaim = (now - lastClaim) / (1000 * 60 * 60);\n // Check if 24 hours have passed\n if (hoursSinceLastClaim < 24) {\n const nextClaimTime = new Date(lastClaim.getTime() + 24 * 60 * 60 * 1000);\n throw new TakaroUserError(`You can claim your next reward at ${nextClaimTime.toLocaleString()}`);\n }\n // Get current streak\n const streakRes = await takaro.variable.variableControllerSearch({\n filters: {\n key: [STREAK_KEY],\n gameServerId: [gameServerId],\n playerId: [pog.playerId],\n moduleId: [mod.moduleId],\n },\n });\n if (streakRes.data.data.length > 0) {\n // If claimed within 48 hours, increment streak\n if (hoursSinceLastClaim < 48) {\n streak = Math.min(JSON.parse(streakRes.data.data[0].value) + 1, mod.userConfig.maxStreak);\n await takaro.variable.variableControllerUpdate(streakRes.data.data[0].id, {\n value: JSON.stringify(streak),\n });\n }\n else {\n // Reset streak if more than 48 hours\n await takaro.variable.variableControllerUpdate(streakRes.data.data[0].id, {\n value: JSON.stringify(1),\n });\n }\n }\n else {\n // Create new streak record\n await takaro.variable.variableControllerCreate({\n key: STREAK_KEY,\n value: JSON.stringify(1),\n gameServerId,\n playerId: pog.playerId,\n moduleId: mod.moduleId,\n });\n }\n // Update last claim time\n await takaro.variable.variableControllerUpdate(lastClaimRes.data.data[0].id, {\n value: JSON.stringify(now),\n });\n }\n else {\n // First time claim\n await takaro.variable.variableControllerCreate({\n key: DAILY_KEY,\n value: JSON.stringify(now),\n gameServerId,\n playerId: pog.playerId,\n moduleId: mod.moduleId,\n });\n await takaro.variable.variableControllerCreate({\n key: STREAK_KEY,\n value: JSON.stringify(1),\n gameServerId,\n playerId: pog.playerId,\n moduleId: mod.moduleId,\n });\n }\n const multiplier = await getMultiplier(pog);\n const baseReward = mod.userConfig.baseReward * streak * multiplier;\n let bonusReward = 0;\n let milestoneMessage = '';\n // Check for milestones\n for (const milestone of mod.userConfig.milestoneRewards) {\n if (streak === milestone.days) {\n bonusReward = milestone.reward;\n milestoneMessage = `\\n${milestone.message}`;\n break;\n }\n }\n // Award total rewards\n const totalReward = baseReward + bonusReward;\n await takaro.playerOnGameserver.playerOnGameServerControllerAddCurrency(gameServerId, pog.playerId, {\n currency: totalReward,\n });\n const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value;\n await pog.pm(`Daily reward claimed! You received ${totalReward} ${currencyName}\\n` +\n `Current streak: ${streak} days${multiplier > 1 ? ` (${multiplier}x bonus!)` : ''}` +\n milestoneMessage);\n}\nawait main();\n//# sourceMappingURL=daily.js.map",
|
|
580
|
+
"name": "daily",
|
|
581
|
+
"trigger": "daily",
|
|
582
|
+
"helpText": "Claim your daily reward",
|
|
583
|
+
"arguments": []
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
"function": "import { data, takaro } from '@takaro/helpers';\nimport { getPlayerStreak, getLastClaim, getMultiplier } from './utils.js';\nasync function main() {\n const { pog, gameServerId, module: mod } = data;\n const streak = await getPlayerStreak(gameServerId, pog.playerId, mod.moduleId);\n const lastClaim = await getLastClaim(gameServerId, pog.playerId, mod.moduleId);\n const multiplier = await getMultiplier(pog);\n const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value;\n if (!streak || !lastClaim) {\n await pog.pm(`You haven't claimed any daily rewards yet! Use ${prefix}daily to get started.`);\n return;\n }\n const nextClaimTime = new Date(lastClaim.getTime() + 24 * 60 * 60 * 1000);\n const now = new Date();\n const canClaim = now >= nextClaimTime;\n // Find next milestone\n let nextMilestone = null;\n for (const milestone of mod.userConfig.milestoneRewards) {\n if (milestone.days > streak) {\n nextMilestone = milestone;\n break;\n }\n }\n let message = `Current streak: ${streak} days${multiplier > 1 ? ` (${multiplier}x donor bonus!)` : ''}\\n`;\n message += canClaim\n ? `Your daily reward is available! Use ${prefix}daily to claim it!\\n`\n : `Next reward available at: ${nextClaimTime.toLocaleString()}\\n`;\n if (nextMilestone) {\n message += `\\n🎯 Next milestone: ${nextMilestone.days} days (${nextMilestone.days - streak} days to go!)`;\n }\n await pog.pm(message);\n}\nawait main();\n//# sourceMappingURL=streak.js.map",
|
|
587
|
+
"name": "streak",
|
|
588
|
+
"trigger": "streak",
|
|
589
|
+
"helpText": "Check your current daily reward streak and next claim time",
|
|
590
|
+
"arguments": []
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
"function": "import { takaro, data } from '@takaro/helpers';\nimport { STREAK_KEY } from './utils.js';\nasync function main() {\n const { pog, gameServerId, module: mod, arguments: args } = data;\n // Limit count to reasonable number\n const count = Math.min(Math.max(1, args.count), 50);\n // Get all streaks\n const streaksRes = await takaro.variable.variableControllerSearch({\n filters: {\n key: [STREAK_KEY],\n gameServerId: [gameServerId],\n moduleId: [mod.moduleId],\n },\n limit: 1000, // Get all possible streaks\n });\n if (streaksRes.data.data.length === 0) {\n await pog.pm('No players have started their daily streak yet!');\n return;\n }\n // Sort by streak value\n const sortedStreaks = streaksRes.data.data\n .map((record) => ({\n playerId: record.playerId,\n streak: JSON.parse(record.value),\n }))\n .sort((a, b) => b.streak - a.streak)\n .slice(0, count);\n // Get player names\n const playerDetails = await Promise.all(sortedStreaks.map(async (record) => {\n const player = (await takaro.player.playerControllerGetOne(record.playerId)).data.data;\n return {\n name: player.name,\n streak: record.streak,\n };\n }));\n // Build message\n let message = `Top ${count} Daily Streaks:\\n\\n`;\n playerDetails.forEach((player, index) => {\n message += `${index + 1}. ${player.name}: ${player.streak} days\\n`;\n });\n await pog.pm(message);\n}\nawait main();\n//# sourceMappingURL=topstreak.js.map",
|
|
594
|
+
"name": "topstreak",
|
|
595
|
+
"trigger": "topstreak",
|
|
596
|
+
"helpText": "Shows the players with highest daily reward streaks",
|
|
597
|
+
"arguments": [
|
|
598
|
+
{
|
|
599
|
+
"name": "count",
|
|
600
|
+
"type": "number",
|
|
601
|
+
"defaultValue": "5",
|
|
602
|
+
"helpText": "Number of players to show (max 25)",
|
|
603
|
+
"position": 0
|
|
604
|
+
}
|
|
605
|
+
]
|
|
606
|
+
}
|
|
607
|
+
],
|
|
608
|
+
"hooks": [
|
|
609
|
+
{
|
|
610
|
+
"eventType": "player-connected",
|
|
611
|
+
"name": "dailyLoginCheck",
|
|
612
|
+
"function": "import { data, takaro } from '@takaro/helpers';\nimport { getLastClaim } from './utils.js';\nasync function main() {\n const { pog, gameServerId, module: mod } = data;\n const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value;\n const lastClaim = await getLastClaim(gameServerId, pog.playerId, mod.moduleId);\n // First time player\n if (!lastClaim) {\n await pog.pm(`Welcome! Use ${prefix}daily to claim your first daily reward and start your streak!`);\n return;\n }\n const now = new Date();\n const nextClaimTime = new Date(lastClaim.getTime() + 24 * 60 * 60 * 1000);\n if (now >= nextClaimTime) {\n await pog.pm(`Your daily reward is ready! Use ${prefix}daily to claim it!`);\n }\n}\nawait main();\n//# sourceMappingURL=dailyLoginCheck.js.map"
|
|
613
|
+
}
|
|
614
|
+
],
|
|
615
|
+
"cronJobs": [],
|
|
616
|
+
"functions": [
|
|
617
|
+
{
|
|
618
|
+
"name": "utils",
|
|
619
|
+
"function": "import { takaro, checkPermission } from '@takaro/helpers';\nexport const DAILY_KEY = 'daily_timestamp';\nexport const STREAK_KEY = 'daily_streak';\nexport async function getMultiplier(pog) {\n const perm = checkPermission(pog, 'DAILY_REWARD_MULTIPLIER');\n if (perm)\n return perm.count;\n return 1;\n}\nexport async function getPlayerStreak(gameServerId, playerId, moduleId) {\n const streakRes = await takaro.variable.variableControllerSearch({\n filters: {\n key: [STREAK_KEY],\n gameServerId: [gameServerId],\n playerId: [playerId],\n moduleId: [moduleId],\n },\n });\n return streakRes.data.data.length ? parseInt(JSON.parse(streakRes.data.data[0].value)) : 0;\n}\nexport async function getLastClaim(gameServerId, playerId, moduleId) {\n const lastClaimRes = await takaro.variable.variableControllerSearch({\n filters: {\n key: [DAILY_KEY],\n gameServerId: [gameServerId],\n playerId: [playerId],\n moduleId: [moduleId],\n },\n });\n return lastClaimRes.data.data.length ? new Date(JSON.parse(lastClaimRes.data.data[0].value)) : null;\n}\n//# sourceMappingURL=utils.js.map"
|
|
620
|
+
}
|
|
621
|
+
],
|
|
622
|
+
"permissions": [
|
|
623
|
+
{
|
|
624
|
+
"permission": "DAILY_CLAIM",
|
|
625
|
+
"friendlyName": "Claim Daily Rewards",
|
|
626
|
+
"description": "Allows the player to claim daily rewards",
|
|
627
|
+
"canHaveCount": false
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
"permission": "DAILY_REWARD_MULTIPLIER",
|
|
631
|
+
"friendlyName": "Multiplier",
|
|
632
|
+
"description": "Control the multiplier per role. This is useful to give your donors a little extra. Count is an integer multiplier.",
|
|
633
|
+
"canHaveCount": true
|
|
634
|
+
}
|
|
635
|
+
],
|
|
636
|
+
"name": "dailyRewards",
|
|
637
|
+
"description": "Provides daily login rewards with streak tracking",
|
|
638
|
+
"configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{\"baseReward\":{\"type\":\"number\",\"title\":\"Base Reward\",\"description\":\"Base amount of currency given for daily rewards. This is multiplied by streak level.\",\"default\":100,\"minimum\":1},\"maxStreak\":{\"type\":\"number\",\"title\":\"Maximum Streak\",\"description\":\"Maximum streak level a player can reach\",\"default\":365,\"minimum\":1},\"milestoneRewards\":{\"type\":\"array\",\"title\":\"Milestone Rewards\",\"description\":\"Additional rewards for reaching certain streak milestones\",\"items\":{\"type\":\"object\",\"properties\":{\"days\":{\"type\":\"number\",\"description\":\"Days needed to reach milestone\",\"minimum\":1},\"reward\":{\"type\":\"number\",\"description\":\"Bonus reward amount\"},\"message\":{\"type\":\"string\",\"description\":\"Message to show when milestone is reached\"}}},\"default\":[{\"days\":7,\"reward\":1000,\"message\":\"You did it! 7 days in a row!\"},{\"days\":30,\"reward\":5000,\"message\":\"A whole month! You're on fire!\"},{\"days\":90,\"reward\":20000,\"message\":\"90 days! You're unstoppable!\"},{\"days\":180,\"reward\":50000,\"message\":\"Half a year! You're a legend!\"},{\"days\":365,\"reward\":150000,\"message\":\"365 days! You're a true champion!\"}]}},\"required\":[\"baseReward\",\"maxStreak\",\"milestoneRewards\"],\"additionalProperties\":false}",
|
|
639
|
+
"uiSchema": "{}"
|
|
563
640
|
}
|
|
564
641
|
]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { getModules } from '@takaro/modules';
|
|
3
3
|
import { writeFile } from 'fs/promises';
|
|
4
|
-
import { readdir, readFile } from 'node:fs/promises';
|
|
4
|
+
import { readdir, readFile, stat } from 'node:fs/promises';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
|
|
7
7
|
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
@@ -12,7 +12,7 @@ async function main() {
|
|
|
12
12
|
const modules = getModules();
|
|
13
13
|
const modulesJson = JSON.stringify(modules, null, 2);
|
|
14
14
|
await writeFile('dist/modules.json', modulesJson);
|
|
15
|
-
await writeFile('../web-docs/docs/modules.json', modulesJson);
|
|
15
|
+
await writeFile('../web-docs/docs/modules/modules.json', modulesJson);
|
|
16
16
|
await writeFile('../e2e/src/web-main/fixtures/modules.json', modulesJson);
|
|
17
17
|
|
|
18
18
|
// Community modules
|
|
@@ -28,6 +28,50 @@ async function main() {
|
|
|
28
28
|
await writeFile('dist/community-modules.json', communityModulesJson);
|
|
29
29
|
await writeFile('../web-docs/docs/community-modules.json', communityModulesJson);
|
|
30
30
|
await writeFile('../e2e/src/web-main/fixtures/community-modules.json', communityModulesJson);
|
|
31
|
+
|
|
32
|
+
const startMarker = '{/* START AUTO-GENERATED CONTENT */}';
|
|
33
|
+
const endMarker = '{/* END AUTO-GENERATED CONTENT */}';
|
|
34
|
+
|
|
35
|
+
// Generate docs pages for each builtin module
|
|
36
|
+
for (const mod of modules) {
|
|
37
|
+
const fileExists = await stat(`../web-docs/docs/modules/${mod.name}.mdx`).catch(() => null);
|
|
38
|
+
|
|
39
|
+
const autoGeneratedContent = `${startMarker}
|
|
40
|
+
import { Commands, Config, CronJobs, Hooks } from './helpers';
|
|
41
|
+
|
|
42
|
+
# ${mod.name}
|
|
43
|
+
|
|
44
|
+
export function Module() {
|
|
45
|
+
const mod = ${JSON.stringify(mod, null, 2)};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div>
|
|
49
|
+
<p>{mod.description}</p>
|
|
50
|
+
<Commands commands={mod.commands} />
|
|
51
|
+
<CronJobs cronJobs={mod.cronJobs} />
|
|
52
|
+
<Hooks hooks={mod.hooks} />
|
|
53
|
+
<Config configSchema={mod.configSchema} />
|
|
54
|
+
</div>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
<Module />
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
${endMarker}`;
|
|
62
|
+
|
|
63
|
+
// If file doesnt exist yet, create it
|
|
64
|
+
if (!fileExists) {
|
|
65
|
+
await writeFile(`../web-docs/docs/modules/${mod.name}.mdx`, autoGeneratedContent);
|
|
66
|
+
} else {
|
|
67
|
+
const existingFile = await readFile(`../web-docs/docs/modules/${mod.name}.mdx`, 'utf-8');
|
|
68
|
+
// Otherwise, fine the auto generated content markers and replace it
|
|
69
|
+
const end = existingFile.indexOf(endMarker) + endMarker.length;
|
|
70
|
+
|
|
71
|
+
const newFile = autoGeneratedContent + existingFile.slice(end);
|
|
72
|
+
await writeFile(`../web-docs/docs/modules/${mod.name}.mdx`, newFile);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
31
75
|
}
|
|
32
76
|
|
|
33
77
|
main().catch(console.error);
|
|
@@ -139,6 +139,29 @@ const tests = [
|
|
|
139
139
|
playerId: this.setupData.players[0].id,
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
+
expect(await events).to.have.length(2);
|
|
143
|
+
expect((await events)[0].data.meta.msg).to.equal('You have purchased Test item for 100 test coin.');
|
|
144
|
+
expect((await events)[1].data.meta.msg).to.equal('You have received items from a shop order.');
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
new IntegrationTest<IShopSetup>({
|
|
148
|
+
group,
|
|
149
|
+
snapshot: false,
|
|
150
|
+
setup: shopSetup,
|
|
151
|
+
name: 'Can buy an item when not linked to a user',
|
|
152
|
+
test: async function () {
|
|
153
|
+
const events = (await new EventsAwaiter().connect(this.client)).waitForEvents(HookEvents.CHAT_MESSAGE, 2);
|
|
154
|
+
const unlinkedPlayer = this.setupData.players[1];
|
|
155
|
+
await this.client.playerOnGameserver.playerOnGameServerControllerAddCurrency(
|
|
156
|
+
this.setupData.gameserver.id,
|
|
157
|
+
unlinkedPlayer.id,
|
|
158
|
+
{ currency: 250 },
|
|
159
|
+
);
|
|
160
|
+
await this.client.command.commandControllerTrigger(this.setupData.gameserver.id, {
|
|
161
|
+
msg: '/shop 1 1 buy',
|
|
162
|
+
playerId: unlinkedPlayer.id,
|
|
163
|
+
});
|
|
164
|
+
|
|
142
165
|
expect(await events).to.have.length(2);
|
|
143
166
|
expect((await events)[0].data.meta.msg).to.equal('You have purchased Test item for 100 test coin.');
|
|
144
167
|
expect((await events)[1].data.meta.msg).to.equal('You have received items from a shop order.');
|