@takaro/modules 0.2.0 → 0.3.0
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/BuiltinModule.d.ts +3 -0
- package/dist/BuiltinModule.d.ts.map +1 -1
- package/dist/BuiltinModule.js +17 -0
- package/dist/BuiltinModule.js.map +1 -1
- package/dist/dto/index.d.ts +1 -0
- package/dist/dto/index.d.ts.map +1 -1
- package/dist/dto/takaroEvents.d.ts +7 -0
- package/dist/dto/takaroEvents.d.ts.map +1 -1
- package/dist/dto/takaroEvents.js +23 -1
- package/dist/dto/takaroEvents.js.map +1 -1
- package/dist/modules/chatBridge/index.d.ts.map +1 -1
- package/dist/modules/chatBridge/index.js +2 -0
- package/dist/modules/chatBridge/index.js.map +1 -1
- package/dist/modules/dailyRewards/commands/daily.js +1 -4
- package/dist/modules/dailyRewards/commands/daily.js.map +1 -1
- package/dist/modules/dailyRewards/index.d.ts.map +1 -1
- package/dist/modules/dailyRewards/index.js +4 -1
- package/dist/modules/dailyRewards/index.js.map +1 -1
- package/dist/modules/economyUtils/commands/confirmTransfer.js +4 -4
- package/dist/modules/economyUtils/commands/confirmTransfer.js.map +1 -1
- package/dist/modules/economyUtils/commands/grantCurrency.js +1 -4
- package/dist/modules/economyUtils/commands/grantCurrency.js.map +1 -1
- package/dist/modules/economyUtils/commands/revokeCurrency.js +1 -4
- package/dist/modules/economyUtils/commands/revokeCurrency.js.map +1 -1
- package/dist/modules/economyUtils/index.d.ts.map +1 -1
- package/dist/modules/economyUtils/index.js +5 -1
- package/dist/modules/economyUtils/index.js.map +1 -1
- package/dist/modules/geoBlock/index.d.ts.map +1 -1
- package/dist/modules/geoBlock/index.js +2 -0
- package/dist/modules/geoBlock/index.js.map +1 -1
- package/dist/modules/gimme/index.d.ts.map +1 -1
- package/dist/modules/gimme/index.js +2 -0
- package/dist/modules/gimme/index.js.map +1 -1
- package/dist/modules/highPingKicker/index.d.ts.map +1 -1
- package/dist/modules/highPingKicker/index.js +2 -0
- package/dist/modules/highPingKicker/index.js.map +1 -1
- package/dist/modules/lottery/commands/buyTicket.js +1 -4
- package/dist/modules/lottery/commands/buyTicket.js.map +1 -1
- package/dist/modules/lottery/commands/viewTickets.js +5 -8
- package/dist/modules/lottery/commands/viewTickets.js.map +1 -1
- package/dist/modules/lottery/index.d.ts.map +1 -1
- package/dist/modules/lottery/index.js +5 -1
- package/dist/modules/lottery/index.js.map +1 -1
- package/dist/modules/playerOnboarding/index.d.ts.map +1 -1
- package/dist/modules/playerOnboarding/index.js +2 -0
- package/dist/modules/playerOnboarding/index.js.map +1 -1
- package/dist/modules/serverMessages/index.d.ts.map +1 -1
- package/dist/modules/serverMessages/index.js +2 -0
- package/dist/modules/serverMessages/index.js.map +1 -1
- package/dist/modules/teleports/commands/deletewaypoint.js +1 -4
- package/dist/modules/teleports/commands/deletewaypoint.js.map +1 -1
- package/dist/modules/teleports/commands/setpublic.js +0 -3
- package/dist/modules/teleports/commands/setpublic.js.map +1 -1
- package/dist/modules/teleports/commands/settp.js +1 -4
- package/dist/modules/teleports/commands/settp.js.map +1 -1
- package/dist/modules/teleports/commands/setwaypoint.js +1 -4
- package/dist/modules/teleports/commands/setwaypoint.js.map +1 -1
- package/dist/modules/teleports/commands/teleport.js +1 -4
- package/dist/modules/teleports/commands/teleport.js.map +1 -1
- package/dist/modules/teleports/index.d.ts.map +1 -1
- package/dist/modules/teleports/index.js +9 -1
- package/dist/modules/teleports/index.js.map +1 -1
- package/dist/modules/timedShutdown/index.d.ts.map +1 -1
- package/dist/modules/timedShutdown/index.js +2 -0
- package/dist/modules/timedShutdown/index.js.map +1 -1
- package/dist/modules/utils/commands/help.js +60 -6
- package/dist/modules/utils/commands/help.js.map +1 -1
- package/dist/modules/utils/index.d.ts.map +1 -1
- package/dist/modules/utils/index.js +11 -2
- package/dist/modules/utils/index.js.map +1 -1
- package/dist/modules.json +112 -18
- package/package.json +1 -1
- package/src/BuiltinModule.ts +11 -0
- package/src/__tests__/economy/economyUtils.integration.test.ts +6 -2
- package/src/__tests__/help.integration.test.ts +230 -62
- package/src/__tests__/lottery.integration.test.ts +5 -1
- package/src/__tests__/modulePermission.integration.test.ts +197 -11
- package/src/__tests__/roleExpiry.integration.test.ts +6 -2
- package/src/__tests__/teleports/publicteleports.integration.test.ts +1 -1
- package/src/__tests__/teleports/waypoints.integration.test.ts +6 -2
- package/src/dto/takaroEvents.ts +16 -0
- package/src/modules/chatBridge/index.ts +2 -0
- package/src/modules/dailyRewards/commands/daily.js +1 -5
- package/src/modules/dailyRewards/index.ts +4 -1
- package/src/modules/economyUtils/commands/confirmTransfer.js +6 -6
- package/src/modules/economyUtils/commands/grantCurrency.js +1 -5
- package/src/modules/economyUtils/commands/revokeCurrency.js +1 -5
- package/src/modules/economyUtils/index.ts +5 -1
- package/src/modules/geoBlock/index.ts +2 -0
- package/src/modules/gimme/index.ts +2 -0
- package/src/modules/highPingKicker/index.ts +2 -0
- package/src/modules/lottery/commands/buyTicket.js +1 -5
- package/src/modules/lottery/commands/viewTickets.js +5 -9
- package/src/modules/lottery/index.ts +5 -1
- package/src/modules/playerOnboarding/index.ts +2 -0
- package/src/modules/serverMessages/index.ts +2 -0
- package/src/modules/teleports/commands/deletewaypoint.js +1 -5
- package/src/modules/teleports/commands/setpublic.js +1 -5
- package/src/modules/teleports/commands/settp.js +1 -6
- package/src/modules/teleports/commands/setwaypoint.js +1 -5
- package/src/modules/teleports/commands/teleport.js +1 -5
- package/src/modules/teleports/index.ts +9 -1
- package/src/modules/timedShutdown/index.ts +2 -0
- package/src/modules/utils/commands/help.js +70 -8
- package/src/modules/utils/index.ts +11 -2
|
@@ -29,7 +29,9 @@ const tests = [
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
expect((await eventsBeforeRole).length).to.be.eq(1);
|
|
32
|
-
expect((await eventsBeforeRole)[0].data.meta.msg).to.match(
|
|
32
|
+
expect((await eventsBeforeRole)[0].data.meta.msg).to.match(
|
|
33
|
+
/⚠️ You need the 'Teleports Use' permission to use this command. Please contact an admin if you need access/,
|
|
34
|
+
);
|
|
33
35
|
|
|
34
36
|
// Assign the role with expiry 10 minutes from now
|
|
35
37
|
await this.client.player.playerControllerAssignRole(this.setupData.players[0].id, this.setupData.role.id, {
|
|
@@ -62,7 +64,9 @@ const tests = [
|
|
|
62
64
|
});
|
|
63
65
|
|
|
64
66
|
expect((await eventsAfterExpire).length).to.be.eq(1);
|
|
65
|
-
expect((await eventsAfterExpire)[0].data.meta.msg).to.match(
|
|
67
|
+
expect((await eventsAfterExpire)[0].data.meta.msg).to.match(
|
|
68
|
+
/⚠️ You need the 'Teleports Use' permission to use this command. Please contact an admin if you need access/,
|
|
69
|
+
);
|
|
66
70
|
},
|
|
67
71
|
}),
|
|
68
72
|
];
|
|
@@ -251,7 +251,7 @@ const tests = [
|
|
|
251
251
|
|
|
252
252
|
expect((await setPublicEvent).length).to.be.eq(1);
|
|
253
253
|
expect((await setPublicEvent)[0].data.meta.msg).to.be.eq(
|
|
254
|
-
|
|
254
|
+
"⚠️ You need the 'Teleports Create Public' permission to use this command. Please contact an admin if you need access.",
|
|
255
255
|
);
|
|
256
256
|
},
|
|
257
257
|
}),
|
|
@@ -171,7 +171,9 @@ const tests = [
|
|
|
171
171
|
});
|
|
172
172
|
|
|
173
173
|
expect((await firstEvents).length).to.be.eq(1);
|
|
174
|
-
expect((await firstEvents)[0].data.meta.msg).to.be.eq(
|
|
174
|
+
expect((await firstEvents)[0].data.meta.msg).to.be.eq(
|
|
175
|
+
"⚠️ You need the 'Teleports Manage Waypoints' permission to use this command. Please contact an admin if you need access.",
|
|
176
|
+
);
|
|
175
177
|
|
|
176
178
|
await this.client.player.playerControllerAssignRole(
|
|
177
179
|
this.setupData.player.id,
|
|
@@ -278,7 +280,9 @@ const tests = [
|
|
|
278
280
|
});
|
|
279
281
|
|
|
280
282
|
expect((await secondEvents).length).to.be.eq(1);
|
|
281
|
-
expect((await secondEvents)[0].data.meta.msg).to.be.eq(
|
|
283
|
+
expect((await secondEvents)[0].data.meta.msg).to.be.eq(
|
|
284
|
+
"⚠️ You need the 'Teleports Manage Waypoints' permission to use this command. Please contact an admin if you need access.",
|
|
285
|
+
);
|
|
282
286
|
|
|
283
287
|
const thirdEvents = (await new EventsAwaiter().connect(this.client)).waitForEvents(GameEvents.CHAT_MESSAGE, 1);
|
|
284
288
|
|
package/src/dto/takaroEvents.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
IsArray,
|
|
2
3
|
IsBoolean,
|
|
3
4
|
IsEnum,
|
|
4
5
|
IsIP,
|
|
@@ -23,6 +24,7 @@ export const TakaroEvents = {
|
|
|
23
24
|
ROLE_UPDATED: 'role-updated',
|
|
24
25
|
ROLE_DELETED: 'role-deleted',
|
|
25
26
|
COMMAND_EXECUTED: 'command-executed',
|
|
27
|
+
COMMAND_EXECUTION_DENIED: 'command-execution-denied',
|
|
26
28
|
HOOK_EXECUTED: 'hook-executed',
|
|
27
29
|
CRONJOB_EXECUTED: 'cronjob-executed',
|
|
28
30
|
CURRENCY_ADDED: 'currency-added',
|
|
@@ -156,6 +158,19 @@ export class TakaroEventCommandExecuted extends BaseEvent<TakaroEventCommandExec
|
|
|
156
158
|
command: TakaroEventCommandDetails;
|
|
157
159
|
}
|
|
158
160
|
|
|
161
|
+
export class TakaroEventCommandExecutionDenied extends BaseEvent<TakaroEventCommandExecutionDenied> {
|
|
162
|
+
@IsString()
|
|
163
|
+
type = TakaroEvents.COMMAND_EXECUTION_DENIED;
|
|
164
|
+
|
|
165
|
+
@ValidateNested()
|
|
166
|
+
@Type(() => TakaroEventCommandDetails)
|
|
167
|
+
command: TakaroEventCommandDetails;
|
|
168
|
+
|
|
169
|
+
@IsArray()
|
|
170
|
+
@IsString({ each: true })
|
|
171
|
+
missingPermissions: string[];
|
|
172
|
+
}
|
|
173
|
+
|
|
159
174
|
export class TakaroEventHookExecuted extends BaseEvent<TakaroEventHookExecuted> {
|
|
160
175
|
@IsString()
|
|
161
176
|
type = TakaroEvents.HOOK_EXECUTED;
|
|
@@ -423,6 +438,7 @@ export const TakaroEventsMapping = {
|
|
|
423
438
|
[TakaroEvents.CURRENCY_DEDUCTED]: TakaroEventCurrencyDeducted,
|
|
424
439
|
[TakaroEvents.CURRENCY_ADDED]: TakaroEventCurrencyAdded,
|
|
425
440
|
[TakaroEvents.COMMAND_EXECUTED]: TakaroEventCommandExecuted,
|
|
441
|
+
[TakaroEvents.COMMAND_EXECUTION_DENIED]: TakaroEventCommandExecutionDenied,
|
|
426
442
|
[TakaroEvents.ROLE_REMOVED]: TakaroEventRoleRemoved,
|
|
427
443
|
[TakaroEvents.ROLE_CREATED]: TakaroEventRoleCreated,
|
|
428
444
|
[TakaroEvents.ROLE_UPDATED]: TakaroEventRoleUpdated,
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { takaro, data, TakaroUserError
|
|
1
|
+
import { takaro, data, TakaroUserError } from '@takaro/helpers';
|
|
2
2
|
import { DAILY_KEY, STREAK_KEY, getMultiplier } from './utils.js';
|
|
3
3
|
|
|
4
4
|
async function main() {
|
|
5
5
|
const { pog, gameServerId, module: mod } = data;
|
|
6
6
|
|
|
7
|
-
if (!checkPermission(pog, 'DAILY_CLAIM')) {
|
|
8
|
-
throw new TakaroUserError('You do not have permission to claim daily rewards.');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
7
|
// Get last claim time
|
|
12
8
|
const lastClaimRes = await takaro.variable.variableControllerSearch({
|
|
13
9
|
filters: {
|
|
@@ -11,10 +11,12 @@ export class DailyRewards extends ModuleTransferDTO<DailyRewards> {
|
|
|
11
11
|
constructor() {
|
|
12
12
|
super();
|
|
13
13
|
this.name = 'dailyRewards';
|
|
14
|
+
this.author = 'Takaro';
|
|
15
|
+
this.supportedGames = ['all'];
|
|
14
16
|
this.versions = [
|
|
15
17
|
new ModuleTransferVersionDTO({
|
|
16
18
|
description: 'Provides daily login rewards with streak tracking',
|
|
17
|
-
tag: '0.0.
|
|
19
|
+
tag: '0.0.2',
|
|
18
20
|
configSchema: JSON.stringify({
|
|
19
21
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
20
22
|
type: 'object',
|
|
@@ -96,6 +98,7 @@ export class DailyRewards extends ModuleTransferDTO<DailyRewards> {
|
|
|
96
98
|
name: 'daily',
|
|
97
99
|
trigger: 'daily',
|
|
98
100
|
helpText: 'Claim your daily reward',
|
|
101
|
+
requiredPermissions: ['DAILY_CLAIM'],
|
|
99
102
|
arguments: [],
|
|
100
103
|
}),
|
|
101
104
|
new ICommand({
|
|
@@ -7,10 +7,10 @@ async function main() {
|
|
|
7
7
|
const variables = (
|
|
8
8
|
await takaro.variable.variableControllerSearch({
|
|
9
9
|
filters: {
|
|
10
|
-
key: 'confirmTransfer',
|
|
11
|
-
gameServerId,
|
|
12
|
-
moduleId: mod.moduleId,
|
|
13
|
-
playerId: sender.playerId,
|
|
10
|
+
key: ['confirmTransfer'],
|
|
11
|
+
gameServerId: [gameServerId],
|
|
12
|
+
moduleId: [mod.moduleId],
|
|
13
|
+
playerId: [sender.playerId],
|
|
14
14
|
},
|
|
15
15
|
})
|
|
16
16
|
).data.data;
|
|
@@ -29,7 +29,7 @@ async function main() {
|
|
|
29
29
|
pendingTransfer.receiver.id,
|
|
30
30
|
{
|
|
31
31
|
currency: pendingTransfer.amount,
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
33
|
);
|
|
34
34
|
|
|
35
35
|
const receiverName = (await takaro.player.playerControllerGetOne(pendingTransfer.receiver.playerId)).data.data.name;
|
|
@@ -37,7 +37,7 @@ async function main() {
|
|
|
37
37
|
const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value;
|
|
38
38
|
|
|
39
39
|
const messageToSender = sender.pm(
|
|
40
|
-
`You successfully transferred ${pendingTransfer.amount} ${currencyName} to ${receiverName}
|
|
40
|
+
`You successfully transferred ${pendingTransfer.amount} ${currencyName} to ${receiverName}`,
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
const messageToReceiver = takaro.gameserver.gameServerControllerSendMessage(gameServerId, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { takaro, data
|
|
1
|
+
import { takaro, data } from '@takaro/helpers';
|
|
2
2
|
|
|
3
3
|
async function main() {
|
|
4
4
|
const { pog: granter, arguments: args, gameServerId } = data;
|
|
@@ -7,10 +7,6 @@ async function main() {
|
|
|
7
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
8
|
const receiver = args.receiver;
|
|
9
9
|
|
|
10
|
-
if (!checkPermission(granter, 'ECONOMY_UTILS_MANAGE_CURRENCY')) {
|
|
11
|
-
throw new TakaroUserError('You do not have permission to use grant currency command.');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
10
|
const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value;
|
|
15
11
|
const granterName = (await takaro.player.playerControllerGetOne(granter.playerId)).data.data.name;
|
|
16
12
|
const receiverName = (await takaro.player.playerControllerGetOne(receiver.playerId)).data.data.name;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { takaro, data
|
|
1
|
+
import { takaro, data } from '@takaro/helpers';
|
|
2
2
|
|
|
3
3
|
async function main() {
|
|
4
4
|
const { pog: revoker, arguments: args, gameServerId } = data;
|
|
@@ -7,10 +7,6 @@ async function main() {
|
|
|
7
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
8
|
const receiver = args.receiver;
|
|
9
9
|
|
|
10
|
-
if (!checkPermission(revoker, 'ECONOMY_UTILS_MANAGE_CURRENCY')) {
|
|
11
|
-
throw new TakaroUserError('You do not have permission to use revoke currency command.');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
10
|
const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value;
|
|
15
11
|
const revokerName = (await takaro.player.playerControllerGetOne(revoker.playerId)).data.data.name;
|
|
16
12
|
const receiverName = (await takaro.player.playerControllerGetOne(receiver.playerId)).data.data.name;
|
|
@@ -5,9 +5,11 @@ export class EconomyUtils extends ModuleTransferDTO<EconomyUtils> {
|
|
|
5
5
|
super();
|
|
6
6
|
|
|
7
7
|
this.name = 'economyUtils';
|
|
8
|
+
this.author = 'Takaro';
|
|
9
|
+
this.supportedGames = ['all'];
|
|
8
10
|
this.versions = [
|
|
9
11
|
new ModuleTransferVersionDTO({
|
|
10
|
-
tag: '0.0.
|
|
12
|
+
tag: '0.0.2',
|
|
11
13
|
description: 'A set of commands to allow players to manage their currency.',
|
|
12
14
|
configSchema: JSON.stringify({
|
|
13
15
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
@@ -74,6 +76,7 @@ export class EconomyUtils extends ModuleTransferDTO<EconomyUtils> {
|
|
|
74
76
|
name: 'grantCurrency',
|
|
75
77
|
trigger: 'grantcurrency',
|
|
76
78
|
helpText: 'Grant money to a player. The money is not taken from your own balance but is new currency.',
|
|
79
|
+
requiredPermissions: ['ECONOMY_UTILS_MANAGE_CURRENCY'],
|
|
77
80
|
arguments: [
|
|
78
81
|
{
|
|
79
82
|
name: 'receiver',
|
|
@@ -96,6 +99,7 @@ export class EconomyUtils extends ModuleTransferDTO<EconomyUtils> {
|
|
|
96
99
|
name: 'revokeCurrency',
|
|
97
100
|
trigger: 'revokecurrency',
|
|
98
101
|
helpText: 'Revokes money from a player. The money disappears.',
|
|
102
|
+
requiredPermissions: ['ECONOMY_UTILS_MANAGE_CURRENCY'],
|
|
99
103
|
arguments: [
|
|
100
104
|
{
|
|
101
105
|
name: 'receiver',
|
|
@@ -4,6 +4,8 @@ export class HighPingKicker extends ModuleTransferDTO<HighPingKicker> {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
super();
|
|
6
6
|
this.name = 'highPingKicker';
|
|
7
|
+
this.author = 'Takaro';
|
|
8
|
+
this.supportedGames = ['7 days to die', 'rust', 'minecraft'];
|
|
7
9
|
this.versions = [
|
|
8
10
|
new ModuleTransferVersionDTO({
|
|
9
11
|
tag: '0.0.2',
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { takaro, data,
|
|
1
|
+
import { takaro, data, TakaroUserError } from '@takaro/helpers';
|
|
2
2
|
|
|
3
3
|
async function main() {
|
|
4
4
|
const { pog, gameServerId, arguments: args, module: mod } = data;
|
|
5
5
|
|
|
6
6
|
const varKey = 'lottery_tickets_bought';
|
|
7
7
|
|
|
8
|
-
if (!checkPermission(pog, 'LOTTERY_BUY')) {
|
|
9
|
-
throw new TakaroUserError('You do not have permission to buy lottery tickets.');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
8
|
if (args.amount < 1) {
|
|
13
9
|
throw new TakaroUserError('You must buy at least 1 ticket.');
|
|
14
10
|
}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import { takaro, data
|
|
1
|
+
import { takaro, data } from '@takaro/helpers';
|
|
2
2
|
|
|
3
3
|
async function main() {
|
|
4
4
|
const { pog, gameServerId, module: mod } = data;
|
|
5
5
|
|
|
6
6
|
const varKey = 'lottery_tickets_bought';
|
|
7
7
|
|
|
8
|
-
if (!checkPermission(pog, 'LOTTERY_VIEW_TICKETS')) {
|
|
9
|
-
throw new TakaroUserError('You do not have permission to view lottery tickets.');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
8
|
const tickets = (
|
|
13
9
|
await takaro.variable.variableControllerSearch({
|
|
14
10
|
filters: {
|
|
15
|
-
gameServerId,
|
|
16
|
-
key: varKey,
|
|
17
|
-
moduleId: mod.
|
|
18
|
-
playerId: pog.playerId,
|
|
11
|
+
gameServerId: [gameServerId],
|
|
12
|
+
key: [varKey],
|
|
13
|
+
moduleId: [mod.moduleId],
|
|
14
|
+
playerId: [pog.playerId],
|
|
19
15
|
},
|
|
20
16
|
})
|
|
21
17
|
).data.data;
|
|
@@ -5,9 +5,11 @@ export class Lottery extends ModuleTransferDTO<Lottery> {
|
|
|
5
5
|
super();
|
|
6
6
|
|
|
7
7
|
this.name = 'lottery';
|
|
8
|
+
this.author = 'Takaro';
|
|
9
|
+
this.supportedGames = ['all'];
|
|
8
10
|
this.versions = [
|
|
9
11
|
new ModuleTransferVersionDTO({
|
|
10
|
-
tag: '0.0.
|
|
12
|
+
tag: '0.0.2',
|
|
11
13
|
description: 'Players can buy tickets for a lottery, and the winner is chosen at random.',
|
|
12
14
|
configSchema: JSON.stringify({
|
|
13
15
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
@@ -51,6 +53,7 @@ export class Lottery extends ModuleTransferDTO<Lottery> {
|
|
|
51
53
|
name: 'buyTicket',
|
|
52
54
|
trigger: 'buyTicket',
|
|
53
55
|
helpText: 'Buy a lottery ticket.',
|
|
56
|
+
requiredPermissions: ['LOTTERY_BUY'],
|
|
54
57
|
arguments: [
|
|
55
58
|
{
|
|
56
59
|
name: 'amount',
|
|
@@ -66,6 +69,7 @@ export class Lottery extends ModuleTransferDTO<Lottery> {
|
|
|
66
69
|
name: 'viewTickets',
|
|
67
70
|
trigger: 'viewTickets',
|
|
68
71
|
helpText: 'View your lottery tickets.',
|
|
72
|
+
requiredPermissions: ['LOTTERY_VIEW_TICKETS'],
|
|
69
73
|
arguments: [],
|
|
70
74
|
}),
|
|
71
75
|
new ICommand({
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { takaro, data,
|
|
1
|
+
import { takaro, data, TakaroUserError } from '@takaro/helpers';
|
|
2
2
|
import { getWaypointName, waypointReconciler } from './utils.js';
|
|
3
3
|
|
|
4
4
|
async function main() {
|
|
5
5
|
const { pog, gameServerId, arguments: args, module: mod } = data;
|
|
6
6
|
|
|
7
|
-
if (!checkPermission(pog, 'TELEPORTS_MANAGE_WAYPOINTS')) {
|
|
8
|
-
throw new TakaroUserError('You do not have permission to manage waypoints.');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
7
|
const variable = await takaro.variable.variableControllerSearch({
|
|
12
8
|
filters: {
|
|
13
9
|
key: [getWaypointName(args.waypoint)],
|
|
@@ -12,10 +12,6 @@ async function main() {
|
|
|
12
12
|
|
|
13
13
|
const hasPermission = checkPermission(pog, 'TELEPORTS_CREATE_PUBLIC');
|
|
14
14
|
|
|
15
|
-
if (!hasPermission) {
|
|
16
|
-
throw new TakaroUserError('You do not have permission to create public teleports.');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
15
|
const existingPublicTeleportsForPlayerRes = await takaro.variable.variableControllerSearch({
|
|
20
16
|
search: {
|
|
21
17
|
key: ['pubtp_'],
|
|
@@ -29,7 +25,7 @@ async function main() {
|
|
|
29
25
|
|
|
30
26
|
if (existingPublicTeleportsForPlayerRes.data.data.length >= hasPermission.count) {
|
|
31
27
|
throw new TakaroUserError(
|
|
32
|
-
`You have reached the maximum number of public teleports for your role, maximum allowed is ${hasPermission.count}
|
|
28
|
+
`You have reached the maximum number of public teleports for your role, maximum allowed is ${hasPermission.count}`,
|
|
33
29
|
);
|
|
34
30
|
}
|
|
35
31
|
|
|
@@ -4,12 +4,6 @@ import { getVariableKey, findTp } from './utils.js';
|
|
|
4
4
|
async function main() {
|
|
5
5
|
const { pog, gameServerId, module: mod, arguments: args } = data;
|
|
6
6
|
|
|
7
|
-
const hasPermission = checkPermission(pog, 'TELEPORTS_USE');
|
|
8
|
-
|
|
9
|
-
if (!hasPermission) {
|
|
10
|
-
throw new TakaroUserError('You do not have permission to use teleports.');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
7
|
const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value;
|
|
14
8
|
|
|
15
9
|
const existingVariable = await findTp(args.tp, pog.playerId);
|
|
@@ -18,6 +12,7 @@ async function main() {
|
|
|
18
12
|
throw new TakaroUserError(`Teleport ${args.tp} already exists, use ${prefix}deletetp ${args.tp} to delete it.`);
|
|
19
13
|
}
|
|
20
14
|
|
|
15
|
+
const hasPermission = checkPermission(pog, 'TELEPORTS_USE');
|
|
21
16
|
const allPlayerTeleports = await takaro.variable.variableControllerSearch({
|
|
22
17
|
search: {
|
|
23
18
|
key: [getVariableKey(undefined), getVariableKey(undefined, true)],
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { takaro, data,
|
|
1
|
+
import { takaro, data, TakaroUserError } from '@takaro/helpers';
|
|
2
2
|
import { getWaypointName, waypointReconciler } from './utils.js';
|
|
3
3
|
|
|
4
4
|
async function main() {
|
|
5
5
|
const { pog, gameServerId, arguments: args, module: mod } = data;
|
|
6
6
|
|
|
7
|
-
if (!checkPermission(pog, 'TELEPORTS_MANAGE_WAYPOINTS')) {
|
|
8
|
-
throw new TakaroUserError('You do not have permission to manage waypoints.');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
7
|
try {
|
|
12
8
|
await takaro.variable.variableControllerCreate({
|
|
13
9
|
moduleId: mod.moduleId,
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { takaro, data,
|
|
1
|
+
import { takaro, data, TakaroUserError } from '@takaro/helpers';
|
|
2
2
|
import { findTp } from './utils.js';
|
|
3
3
|
|
|
4
4
|
async function main() {
|
|
5
5
|
const { pog, gameServerId, arguments: args, module: mod } = data;
|
|
6
6
|
|
|
7
|
-
if (!checkPermission(pog, 'TELEPORTS_USE')) {
|
|
8
|
-
throw new TakaroUserError('You do not have permission to use teleports.');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
7
|
const ownedTeleportRes = await findTp(args.tp, pog.playerId);
|
|
12
8
|
|
|
13
9
|
let teleports = ownedTeleportRes.data.data;
|
|
@@ -13,9 +13,11 @@ export class Teleports extends ModuleTransferDTO<Teleports> {
|
|
|
13
13
|
super();
|
|
14
14
|
|
|
15
15
|
this.name = 'teleports';
|
|
16
|
+
this.author = 'Takaro';
|
|
17
|
+
this.supportedGames = ['7 days to die', 'rust', 'minecraft'];
|
|
16
18
|
this.versions = [
|
|
17
19
|
new ModuleTransferVersionDTO({
|
|
18
|
-
tag: '0.0.
|
|
20
|
+
tag: '0.0.4',
|
|
19
21
|
description: 'A set of commands to allow players to set their own teleport points and teleport to them.',
|
|
20
22
|
configSchema: JSON.stringify({
|
|
21
23
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
@@ -73,6 +75,7 @@ export class Teleports extends ModuleTransferDTO<Teleports> {
|
|
|
73
75
|
name: 'teleport',
|
|
74
76
|
trigger: 'tp',
|
|
75
77
|
helpText: 'Teleports to one of your set locations.',
|
|
78
|
+
requiredPermissions: ['TELEPORTS_USE'],
|
|
76
79
|
arguments: [
|
|
77
80
|
{
|
|
78
81
|
name: 'tp',
|
|
@@ -88,6 +91,7 @@ export class Teleports extends ModuleTransferDTO<Teleports> {
|
|
|
88
91
|
name: 'tplist',
|
|
89
92
|
trigger: 'tplist',
|
|
90
93
|
helpText: 'Lists all your set locations.',
|
|
94
|
+
requiredPermissions: ['TELEPORTS_USE'],
|
|
91
95
|
arguments: [],
|
|
92
96
|
}),
|
|
93
97
|
new ICommand({
|
|
@@ -95,6 +99,7 @@ export class Teleports extends ModuleTransferDTO<Teleports> {
|
|
|
95
99
|
name: 'settp',
|
|
96
100
|
trigger: 'settp',
|
|
97
101
|
helpText: 'Sets a location to teleport to.',
|
|
102
|
+
requiredPermissions: ['TELEPORTS_USE'],
|
|
98
103
|
arguments: [
|
|
99
104
|
{
|
|
100
105
|
name: 'tp',
|
|
@@ -125,6 +130,7 @@ export class Teleports extends ModuleTransferDTO<Teleports> {
|
|
|
125
130
|
name: 'setpublic',
|
|
126
131
|
trigger: 'setpublic',
|
|
127
132
|
helpText: 'Sets a teleport to be public, allowing other players to teleport to it.',
|
|
133
|
+
requiredPermissions: ['TELEPORTS_CREATE_PUBLIC'],
|
|
128
134
|
arguments: [
|
|
129
135
|
{
|
|
130
136
|
name: 'tp',
|
|
@@ -155,6 +161,7 @@ export class Teleports extends ModuleTransferDTO<Teleports> {
|
|
|
155
161
|
name: 'setwaypoint',
|
|
156
162
|
trigger: 'setwaypoint',
|
|
157
163
|
helpText: 'Creates a new waypoint.',
|
|
164
|
+
requiredPermissions: ['TELEPORTS_MANAGE_WAYPOINTS'],
|
|
158
165
|
arguments: [
|
|
159
166
|
{
|
|
160
167
|
name: 'waypoint',
|
|
@@ -170,6 +177,7 @@ export class Teleports extends ModuleTransferDTO<Teleports> {
|
|
|
170
177
|
name: 'deletewaypoint',
|
|
171
178
|
trigger: 'deletewaypoint',
|
|
172
179
|
helpText: 'Deletes a waypoint.',
|
|
180
|
+
requiredPermissions: ['TELEPORTS_MANAGE_WAYPOINTS'],
|
|
173
181
|
arguments: [
|
|
174
182
|
{
|
|
175
183
|
name: 'waypoint',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { data, takaro, TakaroUserError } from '@takaro/helpers';
|
|
1
|
+
import { data, takaro, TakaroUserError, checkPermission } from '@takaro/helpers';
|
|
2
2
|
async function main() {
|
|
3
3
|
const enabledModules = await takaro.module.moduleInstallationsControllerGetInstalledModules({
|
|
4
4
|
filters: { gameserverId: [data.gameServerId] },
|
|
@@ -6,20 +6,72 @@ async function main() {
|
|
|
6
6
|
|
|
7
7
|
const moduleCommands = await Promise.all(
|
|
8
8
|
enabledModules.data.data.map(async (mod) => {
|
|
9
|
+
// Check if the module itself is enabled
|
|
10
|
+
if (!mod.systemConfig.enabled) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
const installedVersion = await takaro.module.moduleVersionControllerGetModuleVersion(mod.versionId);
|
|
10
|
-
|
|
15
|
+
const commands = installedVersion.data.data.commands;
|
|
16
|
+
|
|
17
|
+
// Filter out disabled commands
|
|
18
|
+
return commands.filter((command) => {
|
|
19
|
+
const commandConfig = mod.systemConfig.commands && mod.systemConfig.commands[command.name];
|
|
20
|
+
return commandConfig && commandConfig.enabled;
|
|
21
|
+
});
|
|
11
22
|
}),
|
|
12
23
|
);
|
|
13
24
|
const allCommandsFlat = moduleCommands.flat();
|
|
14
25
|
|
|
15
|
-
|
|
26
|
+
// Filter commands based on player permissions
|
|
27
|
+
const accessibleCommands = allCommandsFlat.filter((command) => {
|
|
28
|
+
// If command has no required permissions, it's accessible to all
|
|
29
|
+
if (!command.requiredPermissions || command.requiredPermissions.length === 0) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Check if player has all required permissions
|
|
34
|
+
return command.requiredPermissions.every((permission) => checkPermission(data.pog, permission));
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (data.arguments.command === 'search') {
|
|
38
|
+
// Check if a search term was actually provided (not the default 'none')
|
|
39
|
+
if (data.arguments.searchTerm === 'none') {
|
|
40
|
+
throw new TakaroUserError('Please provide a search term. Usage: /help search <term>');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Search functionality
|
|
44
|
+
const searchTerm = data.arguments.searchTerm.toLowerCase();
|
|
45
|
+
const matchingCommands = accessibleCommands.filter((command) => {
|
|
46
|
+
// Check if command name contains search term
|
|
47
|
+
const nameMatch = command.name.toLowerCase().includes(searchTerm);
|
|
48
|
+
// Check if help text contains search term
|
|
49
|
+
const helpTextMatch = command.helpText.toLowerCase().includes(searchTerm);
|
|
50
|
+
return nameMatch || helpTextMatch;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (matchingCommands.length === 0) {
|
|
54
|
+
await data.player.pm(`No commands found matching "${data.arguments.searchTerm}".`);
|
|
55
|
+
} else {
|
|
56
|
+
await data.player.pm(`Commands matching "${data.arguments.searchTerm}":`);
|
|
57
|
+
await Promise.all(
|
|
58
|
+
matchingCommands.map(async (command) => {
|
|
59
|
+
await data.player.pm(`${command.name}: ${command.helpText}`);
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
} else if (data.arguments.command === 'all') {
|
|
16
64
|
await data.player.pm('Available commands:');
|
|
17
65
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
66
|
+
if (accessibleCommands.length === 0) {
|
|
67
|
+
await data.player.pm('No commands available to you.');
|
|
68
|
+
} else {
|
|
69
|
+
await Promise.all(
|
|
70
|
+
accessibleCommands.map(async (command) => {
|
|
71
|
+
await data.player.pm(`${command.name}: ${command.helpText}`);
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
23
75
|
} else {
|
|
24
76
|
const requestedCommand = allCommandsFlat.find((c) => {
|
|
25
77
|
return c.name === data.arguments.command;
|
|
@@ -30,6 +82,16 @@ async function main() {
|
|
|
30
82
|
`Unknown command "${data.arguments.command}", use this command without arguments to see all available commands.`,
|
|
31
83
|
);
|
|
32
84
|
} else {
|
|
85
|
+
// Check if player has permission to use this command
|
|
86
|
+
const hasAccess =
|
|
87
|
+
!requestedCommand.requiredPermissions ||
|
|
88
|
+
requestedCommand.requiredPermissions.length === 0 ||
|
|
89
|
+
requestedCommand.requiredPermissions.every((permission) => checkPermission(data.pog, permission));
|
|
90
|
+
|
|
91
|
+
if (!hasAccess) {
|
|
92
|
+
throw new TakaroUserError(`You don't have permission to use the "${data.arguments.command}" command.`);
|
|
93
|
+
}
|
|
94
|
+
|
|
33
95
|
await data.player.pm(`${requestedCommand.name}: ${requestedCommand.helpText}`);
|
|
34
96
|
}
|
|
35
97
|
}
|