@takaro/modules 0.0.1 → 0.0.5
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.js +0 -4
- package/dist/BuiltinModule.js.map +1 -1
- package/dist/community-modules.json +21 -0
- package/dist/dto/gameEvents.d.ts +3 -2
- package/dist/dto/gameEvents.js +1 -0
- package/dist/dto/gameEvents.js.map +1 -1
- package/dist/dto/index.d.ts +6 -0
- package/dist/dto/takaroEvents.d.ts +46 -0
- package/dist/dto/takaroEvents.js +129 -1
- package/dist/dto/takaroEvents.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/modules/chatBridge/hooks/GameToDiscord.js +1 -1
- package/dist/modules/chatBridge/hooks/GameToDiscord.js.map +1 -1
- package/dist/modules/chatBridge/hooks/PlayerConnected.js +2 -2
- package/dist/modules/chatBridge/hooks/PlayerConnected.js.map +1 -1
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js +1 -1
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js.map +1 -1
- package/dist/modules/economyUtils/commands/transfer.js +1 -1
- package/dist/modules/economyUtils/commands/transfer.js.map +1 -1
- package/dist/modules/geoBlock/hooks/IPDetected.js +3 -5
- package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -1
- package/dist/modules/geoBlock/index.js +1 -1
- package/dist/modules/geoBlock/index.js.map +1 -1
- package/dist/modules/gimme/commands/gimme.js +1 -0
- package/dist/modules/gimme/commands/gimme.js.map +1 -1
- package/dist/modules/lottery/commands/nextDraw.js +1 -1
- package/dist/modules/lottery/commands/nextDraw.js.map +1 -1
- package/dist/modules/playerOnboarding/index.js.map +1 -1
- package/dist/modules/teleports/commands/deletetp.js +1 -1
- package/dist/modules/teleports/commands/deletetp.js.map +1 -1
- package/dist/modules/teleports/commands/setprivate.js +4 -6
- package/dist/modules/teleports/commands/setprivate.js.map +1 -1
- package/dist/modules/teleports/commands/setpublic.js +8 -15
- package/dist/modules/teleports/commands/setpublic.js.map +1 -1
- package/dist/modules/teleports/commands/settp.js +2 -2
- package/dist/modules/teleports/commands/settp.js.map +1 -1
- package/dist/modules/teleports/commands/teleport.js +3 -8
- package/dist/modules/teleports/commands/teleport.js.map +1 -1
- package/dist/modules/teleports/commands/teleportwaypoint.js +9 -1
- package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -1
- package/dist/modules/teleports/commands/tplist.js +13 -12
- package/dist/modules/teleports/commands/tplist.js.map +1 -1
- package/dist/modules/teleports/functions/utils.d.ts +2 -2
- package/dist/modules/teleports/functions/utils.js +21 -3
- package/dist/modules/teleports/functions/utils.js.map +1 -1
- package/dist/modules.json +99 -79
- package/package.json +4 -8
- package/scripts/buildBuiltinJson.ts +20 -0
- package/src/BuiltinModule.ts +1 -1
- package/src/__tests__/aliases.integration.test.ts +6 -7
- package/src/__tests__/bugRepros.integration.test.ts +72 -0
- package/src/__tests__/commandArgs.integration.test.ts +24 -25
- package/src/__tests__/economyUtils.integration.test.ts +66 -60
- package/src/__tests__/geoblock.integration.test.ts +22 -65
- package/src/__tests__/gimme.integration.test.ts +35 -36
- package/src/__tests__/help.integration.test.ts +47 -35
- package/src/__tests__/lottery.integration.test.ts +32 -28
- package/src/__tests__/modulePermission.integration.test.ts +24 -18
- package/src/__tests__/onboarding.integration.test.ts +13 -14
- package/src/__tests__/ping.integration.test.ts +5 -6
- package/src/__tests__/roleExpiry.integration.test.ts +9 -10
- package/src/__tests__/serverMessages.integration.test.ts +14 -12
- package/src/__tests__/systemConfigCost.integration.test.ts +14 -15
- package/src/__tests__/teleports/listtp.integration.test.ts +98 -22
- package/src/__tests__/teleports/publicteleports.integration.test.ts +55 -48
- package/src/__tests__/teleports/teleport.integration.test.ts +17 -16
- package/src/__tests__/teleports/tpManagement.integration.test.ts +26 -27
- package/src/__tests__/teleports/waypoints.integration.test.ts +113 -82
- package/src/community-modules/README.md +5 -0
- package/src/community-modules/modules/vote.json +19 -0
- package/src/dto/gameEvents.ts +2 -2
- package/src/dto/takaroEvents.ts +79 -0
- package/src/main.ts +2 -3
- package/src/modules/chatBridge/hooks/GameToDiscord.js +1 -1
- package/src/modules/chatBridge/hooks/PlayerConnected.js +2 -2
- package/src/modules/chatBridge/hooks/PlayerDisconnected.js +1 -1
- package/src/modules/chatBridge/index.ts +1 -1
- package/src/modules/economyUtils/commands/transfer.js +4 -4
- package/src/modules/economyUtils/index.ts +1 -1
- package/src/modules/geoBlock/hooks/IPDetected.js +3 -4
- package/src/modules/geoBlock/index.ts +2 -2
- package/src/modules/gimme/commands/gimme.js +2 -1
- package/src/modules/gimme/index.ts +1 -1
- package/src/modules/highPingKicker/index.ts +1 -1
- package/src/modules/lottery/commands/nextDraw.js +3 -1
- package/src/modules/lottery/index.ts +1 -1
- package/src/modules/playerOnboarding/index.ts +2 -1
- package/src/modules/serverMessages/index.ts +1 -1
- package/src/modules/teleports/commands/deletetp.js +1 -1
- package/src/modules/teleports/commands/setprivate.js +6 -6
- package/src/modules/teleports/commands/setpublic.js +18 -25
- package/src/modules/teleports/commands/settp.js +2 -2
- package/src/modules/teleports/commands/teleport.js +3 -10
- package/src/modules/teleports/commands/teleportwaypoint.js +12 -1
- package/src/modules/teleports/commands/tplist.js +16 -15
- package/src/modules/teleports/functions/utils.js +19 -3
- package/src/modules/teleports/index.ts +1 -1
- package/src/modules/utils/index.ts +1 -1
package/src/dto/takaroEvents.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
IsObject,
|
|
10
10
|
IsOptional,
|
|
11
11
|
IsString,
|
|
12
|
+
IsUUID,
|
|
12
13
|
ValidateNested,
|
|
13
14
|
} from 'class-validator';
|
|
14
15
|
import { BaseEvent } from './base.js';
|
|
@@ -36,6 +37,12 @@ export const TakaroEvents = {
|
|
|
36
37
|
MODULE_INSTALLED: 'module-installed',
|
|
37
38
|
MODULE_UNINSTALLED: 'module-uninstalled',
|
|
38
39
|
PLAYER_CREATED: 'player-created',
|
|
40
|
+
SHOP_LISTING_CREATED: 'shop-listing-created',
|
|
41
|
+
SHOP_LISTING_UPDATED: 'shop-listing-updated',
|
|
42
|
+
SHOP_LISTING_DELETED: 'shop-listing-deleted',
|
|
43
|
+
SHOP_ORDER_CREATED: 'shop-order-created',
|
|
44
|
+
SHOP_ORDER_STATUS_CHANGED: 'shop-order-status-changed',
|
|
45
|
+
PLAYER_LINKED: 'player-linked',
|
|
39
46
|
} as const;
|
|
40
47
|
|
|
41
48
|
export class BaseTakaroEvent<T> extends BaseEvent<T> {
|
|
@@ -116,6 +123,20 @@ export class TakaroEventCommandDetails extends TakaroDTO<TakaroEventCommandDetai
|
|
|
116
123
|
arguments: Record<string, unknown>;
|
|
117
124
|
}
|
|
118
125
|
|
|
126
|
+
export class TakaroEventHookDetails extends TakaroDTO<TakaroEventHookDetails> {
|
|
127
|
+
@IsString()
|
|
128
|
+
id: string;
|
|
129
|
+
@IsString()
|
|
130
|
+
name: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export class TakaroEventCronjobDetails extends TakaroDTO<TakaroEventCronjobDetails> {
|
|
134
|
+
@IsString()
|
|
135
|
+
id: string;
|
|
136
|
+
@IsString()
|
|
137
|
+
name: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
119
140
|
export class TakaroEventCommandExecuted extends BaseEvent<TakaroEventCommandExecuted> {
|
|
120
141
|
@IsString()
|
|
121
142
|
type = TakaroEvents.COMMAND_EXECUTED;
|
|
@@ -143,6 +164,11 @@ export class TakaroEventHookExecuted extends BaseEvent<TakaroEventHookExecuted>
|
|
|
143
164
|
@ValidateNested({ each: true })
|
|
144
165
|
@Type(() => TakaroEventFunctionResult)
|
|
145
166
|
result: TakaroEventFunctionResult;
|
|
167
|
+
|
|
168
|
+
@IsOptional()
|
|
169
|
+
@ValidateNested()
|
|
170
|
+
@Type(() => TakaroEventHookDetails)
|
|
171
|
+
hook: TakaroEventHookDetails;
|
|
146
172
|
}
|
|
147
173
|
|
|
148
174
|
export class TakaroEventCronjobExecuted extends BaseEvent<TakaroEventCronjobExecuted> {
|
|
@@ -155,6 +181,11 @@ export class TakaroEventCronjobExecuted extends BaseEvent<TakaroEventCronjobExec
|
|
|
155
181
|
@ValidateNested({ each: true })
|
|
156
182
|
@Type(() => TakaroEventFunctionResult)
|
|
157
183
|
result: TakaroEventFunctionResult;
|
|
184
|
+
|
|
185
|
+
@IsOptional()
|
|
186
|
+
@ValidateNested()
|
|
187
|
+
@Type(() => TakaroEventCronjobDetails)
|
|
188
|
+
cronjob: TakaroEventCronjobDetails;
|
|
158
189
|
}
|
|
159
190
|
|
|
160
191
|
export class TakaroEventRoleMeta extends TakaroDTO<TakaroEventRoleMeta> {
|
|
@@ -267,6 +298,48 @@ export class TakaroEventPlayerCreated extends BaseEvent<TakaroEventPlayerCreated
|
|
|
267
298
|
type = TakaroEvents.PLAYER_CREATED;
|
|
268
299
|
}
|
|
269
300
|
|
|
301
|
+
export class TakaroEventShopListingCreated extends BaseEvent<TakaroEventShopListingCreated> {
|
|
302
|
+
@IsString()
|
|
303
|
+
type = TakaroEvents.SHOP_LISTING_CREATED;
|
|
304
|
+
@IsUUID()
|
|
305
|
+
id: string;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export class TakaroEventShopListingUpdated extends BaseEvent<TakaroEventShopListingUpdated> {
|
|
309
|
+
@IsString()
|
|
310
|
+
type = TakaroEvents.SHOP_LISTING_UPDATED;
|
|
311
|
+
@IsUUID()
|
|
312
|
+
id: string;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export class TakaroEventShopListingDeleted extends BaseEvent<TakaroEventShopListingDeleted> {
|
|
316
|
+
@IsString()
|
|
317
|
+
type = TakaroEvents.SHOP_LISTING_DELETED;
|
|
318
|
+
@IsUUID()
|
|
319
|
+
id: string;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export class TakaroEventShopOrderCreated extends BaseEvent<TakaroEventShopOrderCreated> {
|
|
323
|
+
@IsString()
|
|
324
|
+
type = TakaroEvents.SHOP_ORDER_CREATED;
|
|
325
|
+
@IsUUID()
|
|
326
|
+
id: string;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export class TakaroEventShopOrderStatusChanged extends BaseEvent<TakaroEventShopOrderStatusChanged> {
|
|
330
|
+
@IsString()
|
|
331
|
+
type = TakaroEvents.SHOP_ORDER_STATUS_CHANGED;
|
|
332
|
+
@IsUUID()
|
|
333
|
+
id: string;
|
|
334
|
+
@IsString()
|
|
335
|
+
status: string;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export class TakaroEventPlayerLinked extends BaseEvent<TakaroEventPlayerLinked> {
|
|
339
|
+
@IsString()
|
|
340
|
+
type = TakaroEvents.PLAYER_LINKED;
|
|
341
|
+
}
|
|
342
|
+
|
|
270
343
|
export const TakaroEventsMapping = {
|
|
271
344
|
[TakaroEvents.ROLE_ASSIGNED]: TakaroEventRoleAssigned,
|
|
272
345
|
[TakaroEvents.PLAYER_NEW_IP_DETECTED]: TakaroEventPlayerNewIpDetected,
|
|
@@ -287,4 +360,10 @@ export const TakaroEventsMapping = {
|
|
|
287
360
|
[TakaroEvents.MODULE_INSTALLED]: TakaroEventModuleInstalled,
|
|
288
361
|
[TakaroEvents.MODULE_UNINSTALLED]: TakaroEventModuleUninstalled,
|
|
289
362
|
[TakaroEvents.PLAYER_CREATED]: TakaroEventPlayerCreated,
|
|
363
|
+
[TakaroEvents.SHOP_LISTING_CREATED]: TakaroEventShopListingCreated,
|
|
364
|
+
[TakaroEvents.SHOP_LISTING_UPDATED]: TakaroEventShopListingUpdated,
|
|
365
|
+
[TakaroEvents.SHOP_LISTING_DELETED]: TakaroEventShopListingDeleted,
|
|
366
|
+
[TakaroEvents.SHOP_ORDER_CREATED]: TakaroEventShopOrderCreated,
|
|
367
|
+
[TakaroEvents.SHOP_ORDER_STATUS_CHANGED]: TakaroEventShopOrderStatusChanged,
|
|
368
|
+
[TakaroEvents.PLAYER_LINKED]: TakaroEventPlayerLinked,
|
|
290
369
|
} as const;
|
package/src/main.ts
CHANGED
|
@@ -8,12 +8,11 @@ import { Lottery } from './modules/lottery/index.js';
|
|
|
8
8
|
import { PlayerOnboarding } from './modules/playerOnboarding/index.js';
|
|
9
9
|
import { ServerMessages } from './modules/serverMessages/index.js';
|
|
10
10
|
import { Teleports } from './modules/teleports/index.js';
|
|
11
|
-
|
|
11
|
+
import { Utils } from './modules/utils/index.js';
|
|
12
12
|
|
|
13
|
+
export { BuiltinModule, ICommand, ICommandArgument, ICronJob, IHook, IFunction } from './BuiltinModule.js';
|
|
13
14
|
export * from './dto/index.js';
|
|
14
15
|
|
|
15
|
-
import { Utils } from './modules/utils/index.js';
|
|
16
|
-
|
|
17
16
|
let cached: Array<BuiltinModule<unknown>> | null = null;
|
|
18
17
|
|
|
19
18
|
export function getModules(): Array<BuiltinModule<unknown>> {
|
|
@@ -5,7 +5,7 @@ async function main() {
|
|
|
5
5
|
|
|
6
6
|
if (onlyGlobal && data.eventData.channel !== 'global') return;
|
|
7
7
|
|
|
8
|
-
const discordChannel = data.module.systemConfig.hooks['DiscordToGame
|
|
8
|
+
const discordChannel = data.module.systemConfig.hooks['DiscordToGame'].discordChannelId;
|
|
9
9
|
|
|
10
10
|
const sender = data.player ? data.player.name : 'Non-player';
|
|
11
11
|
const message = `**${sender}**: ${data.eventData.msg}`;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { takaro, data } from '@takaro/helpers';
|
|
2
2
|
|
|
3
3
|
async function main() {
|
|
4
|
-
const discordChannel = data.module.systemConfig.hooks['DiscordToGame
|
|
4
|
+
const discordChannel = data.module.systemConfig.hooks['DiscordToGame'].discordChannelId;
|
|
5
5
|
|
|
6
6
|
await takaro.discord.discordControllerSendMessage(discordChannel, {
|
|
7
|
-
message: `[
|
|
7
|
+
message: `[⚡ Connected]: ${data.player.name}`,
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { takaro, data } from '@takaro/helpers';
|
|
2
2
|
|
|
3
3
|
async function main() {
|
|
4
|
-
const discordChannel = data.module.systemConfig.hooks['DiscordToGame
|
|
4
|
+
const discordChannel = data.module.systemConfig.hooks['DiscordToGame'].discordChannelId;
|
|
5
5
|
|
|
6
6
|
await takaro.discord.discordControllerSendMessage(discordChannel, {
|
|
7
7
|
message: `[👋 Disconnected]: ${data.player.name}`,
|
|
@@ -33,7 +33,7 @@ async function main() {
|
|
|
33
33
|
|
|
34
34
|
// NOTE: we should maybe check if the player has enough balance to send the amount since this is only checked when the transaction is executed.
|
|
35
35
|
await sender.pm(
|
|
36
|
-
`You are about to send ${args.amount} ${currencyName} to ${receiverName}. (Please confirm by typing ${prefix}confirmtransfer)
|
|
36
|
+
`You are about to send ${args.amount} ${currencyName} to ${receiverName}. (Please confirm by typing ${prefix}confirmtransfer)`,
|
|
37
37
|
);
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
@@ -45,11 +45,11 @@ async function main() {
|
|
|
45
45
|
receiver.id,
|
|
46
46
|
{
|
|
47
47
|
currency: args.amount,
|
|
48
|
-
}
|
|
48
|
+
},
|
|
49
49
|
);
|
|
50
|
-
} catch (
|
|
50
|
+
} catch (_e) {
|
|
51
51
|
throw new TakaroUserError(
|
|
52
|
-
`Failed to transfer ${args.amount} ${currencyName} to ${receiverName}. Are you sure you have enough balance
|
|
52
|
+
`Failed to transfer ${args.amount} ${currencyName} to ${receiverName}. Are you sure you have enough balance?`,
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -30,11 +30,10 @@ async function main() {
|
|
|
30
30
|
if (countries.includes(country)) {
|
|
31
31
|
console.log('Allowed country detected, no action');
|
|
32
32
|
return;
|
|
33
|
-
} else {
|
|
34
|
-
console.log('Blocked country detected, performing actions');
|
|
35
|
-
await handleAction();
|
|
36
|
-
return;
|
|
37
33
|
}
|
|
34
|
+
console.log('Blocked country detected, performing actions');
|
|
35
|
+
await handleAction();
|
|
36
|
+
return;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
if (mode === 'deny') {
|
|
@@ -271,7 +271,7 @@ export class GeoBlock extends BuiltinModule<GeoBlock> {
|
|
|
271
271
|
},
|
|
272
272
|
countries: {
|
|
273
273
|
title: 'Countries',
|
|
274
|
-
description: 'List of
|
|
274
|
+
description: 'List of countries',
|
|
275
275
|
type: 'array',
|
|
276
276
|
uniqueItems: true,
|
|
277
277
|
'x-component': 'country',
|
|
@@ -307,7 +307,7 @@ export class GeoBlock extends BuiltinModule<GeoBlock> {
|
|
|
307
307
|
}),
|
|
308
308
|
JSON.stringify({
|
|
309
309
|
banDuration: { 'ui:widget': 'duration' },
|
|
310
|
-
})
|
|
310
|
+
}),
|
|
311
311
|
);
|
|
312
312
|
|
|
313
313
|
this.permissions = [
|
|
@@ -6,7 +6,7 @@ async function main() {
|
|
|
6
6
|
|
|
7
7
|
if (items.length + commands.length === 0) {
|
|
8
8
|
throw new TakaroUserError(
|
|
9
|
-
'No items or commands configured, please ask your server administrator to configure this module.'
|
|
9
|
+
'No items or commands configured, please ask your server administrator to configure this module.',
|
|
10
10
|
);
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -18,6 +18,7 @@ async function main() {
|
|
|
18
18
|
await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {
|
|
19
19
|
name: randomOption,
|
|
20
20
|
amount: 1,
|
|
21
|
+
quality: 0,
|
|
21
22
|
});
|
|
22
23
|
await data.player.pm(`You received ${randomOption}!`);
|
|
23
24
|
} else {
|
|
@@ -39,7 +39,9 @@ function formatTimeToReach(cronJob) {
|
|
|
39
39
|
|
|
40
40
|
async function main() {
|
|
41
41
|
const { player, module: mod } = data;
|
|
42
|
-
await player.pm(
|
|
42
|
+
await player.pm(
|
|
43
|
+
`The next lottery draw is in about ${formatTimeToReach(mod.systemConfig.cronJobs.drawLottery.temporalValue)}`
|
|
44
|
+
);
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
await main();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BuiltinModule, ICommand, IHook } from '../../BuiltinModule.js';
|
|
2
2
|
import { HookEvents } from '../../dto/index.js';
|
|
3
|
+
|
|
3
4
|
export class PlayerOnboarding extends BuiltinModule<PlayerOnboarding> {
|
|
4
5
|
constructor() {
|
|
5
6
|
super(
|
|
@@ -34,7 +35,7 @@ export class PlayerOnboarding extends BuiltinModule<PlayerOnboarding> {
|
|
|
34
35
|
}),
|
|
35
36
|
JSON.stringify({
|
|
36
37
|
starterKitItems: { 'ui:widget': 'item' },
|
|
37
|
-
})
|
|
38
|
+
}),
|
|
38
39
|
);
|
|
39
40
|
|
|
40
41
|
this.hooks = [
|
|
@@ -6,7 +6,7 @@ async function main() {
|
|
|
6
6
|
|
|
7
7
|
const existingVariable = await takaro.variable.variableControllerSearch({
|
|
8
8
|
filters: {
|
|
9
|
-
key: [getVariableKey(args.tp)],
|
|
9
|
+
key: [getVariableKey(args.tp), getVariableKey(args.tp, true)],
|
|
10
10
|
gameServerId: [gameServerId],
|
|
11
11
|
playerId: [pog.playerId],
|
|
12
12
|
moduleId: [mod.moduleId],
|
|
@@ -10,7 +10,7 @@ async function main() {
|
|
|
10
10
|
filters: {
|
|
11
11
|
gameServerId: [gameServerId],
|
|
12
12
|
playerId: [pog.playerId],
|
|
13
|
-
key: [getVariableKey(args.tp)],
|
|
13
|
+
key: [getVariableKey(args.tp, true)],
|
|
14
14
|
moduleId: [mod.moduleId],
|
|
15
15
|
},
|
|
16
16
|
sortBy: 'key',
|
|
@@ -20,17 +20,17 @@ async function main() {
|
|
|
20
20
|
const teleports = teleportRes.data.data;
|
|
21
21
|
|
|
22
22
|
if (teleports.length === 0) {
|
|
23
|
-
throw new TakaroUserError(
|
|
23
|
+
throw new TakaroUserError(
|
|
24
|
+
`No public teleport with name ${args.tp} found, use ${prefix}settp <name> to set one first.`
|
|
25
|
+
);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
const teleportRecord = teleports[0];
|
|
27
29
|
const teleport = JSON.parse(teleportRecord.value);
|
|
28
30
|
|
|
29
31
|
await takaro.variable.variableControllerUpdate(teleportRecord.id, {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
public: false,
|
|
33
|
-
}),
|
|
32
|
+
key: getVariableKey(args.tp),
|
|
33
|
+
value: JSON.stringify(teleport),
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
await data.player.pm(`Teleport ${args.tp} is now private.`);
|
|
@@ -4,7 +4,7 @@ import { getVariableKey } from './utils.js';
|
|
|
4
4
|
async function main() {
|
|
5
5
|
const { pog, gameServerId, module: mod, arguments: args } = data;
|
|
6
6
|
|
|
7
|
-
const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data;
|
|
7
|
+
const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value;
|
|
8
8
|
|
|
9
9
|
if (!mod.userConfig.allowPublicTeleports) {
|
|
10
10
|
throw new TakaroUserError('Public teleports are disabled.');
|
|
@@ -16,9 +16,9 @@ async function main() {
|
|
|
16
16
|
throw new TakaroUserError('You do not have permission to create public teleports.');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const existingPublicTeleportsForPlayerRes = await takaro.variable.variableControllerSearch({
|
|
20
20
|
search: {
|
|
21
|
-
key: '
|
|
21
|
+
key: ['pubtp_'],
|
|
22
22
|
},
|
|
23
23
|
filters: {
|
|
24
24
|
gameServerId: [gameServerId],
|
|
@@ -27,29 +27,24 @@ async function main() {
|
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
const teleport = JSON.parse(tp.value);
|
|
32
|
-
return teleport.public;
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if (existingPublicTeleportsForPlayer.length >= hasPermission.count) {
|
|
30
|
+
if (existingPublicTeleportsForPlayerRes.data.data.length >= hasPermission.count) {
|
|
36
31
|
throw new TakaroUserError(
|
|
37
32
|
`You have reached the maximum number of public teleports for your role, maximum allowed is ${hasPermission.count}`
|
|
38
33
|
);
|
|
39
34
|
}
|
|
40
35
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
const teleports = (
|
|
37
|
+
await takaro.variable.variableControllerSearch({
|
|
38
|
+
filters: {
|
|
39
|
+
gameServerId: [gameServerId],
|
|
40
|
+
playerId: [pog.playerId],
|
|
41
|
+
moduleId: [mod.moduleId],
|
|
42
|
+
key: [getVariableKey(args.tp)],
|
|
43
|
+
},
|
|
44
|
+
sortBy: 'key',
|
|
45
|
+
sortDirection: 'asc',
|
|
46
|
+
})
|
|
47
|
+
).data.data;
|
|
53
48
|
|
|
54
49
|
if (teleports.length === 0) {
|
|
55
50
|
throw new TakaroUserError(`No teleport with name ${args.tp} found, use ${prefix}settp <name> to set one first.`);
|
|
@@ -59,10 +54,8 @@ async function main() {
|
|
|
59
54
|
const teleport = JSON.parse(teleportRecord.value);
|
|
60
55
|
|
|
61
56
|
await takaro.variable.variableControllerUpdate(teleportRecord.id, {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
public: true,
|
|
65
|
-
}),
|
|
57
|
+
key: getVariableKey(args.tp, true),
|
|
58
|
+
value: JSON.stringify(teleport),
|
|
66
59
|
});
|
|
67
60
|
|
|
68
61
|
await data.player.pm(`Teleport ${args.tp} is now public.`);
|
|
@@ -12,7 +12,7 @@ async function main() {
|
|
|
12
12
|
|
|
13
13
|
const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value;
|
|
14
14
|
|
|
15
|
-
const existingVariable = await findTp(args.tp);
|
|
15
|
+
const existingVariable = await findTp(args.tp, pog.playerId);
|
|
16
16
|
|
|
17
17
|
if (existingVariable.data.data.length > 0) {
|
|
18
18
|
throw new TakaroUserError(`Teleport ${args.tp} already exists, use ${prefix}deletetp ${args.tp} to delete it.`);
|
|
@@ -20,7 +20,7 @@ async function main() {
|
|
|
20
20
|
|
|
21
21
|
const allPlayerTeleports = await takaro.variable.variableControllerSearch({
|
|
22
22
|
search: {
|
|
23
|
-
key: getVariableKey(
|
|
23
|
+
key: [getVariableKey(undefined), getVariableKey(undefined, true)],
|
|
24
24
|
},
|
|
25
25
|
filters: {
|
|
26
26
|
gameServerId: [gameServerId],
|
|
@@ -13,14 +13,8 @@ async function main() {
|
|
|
13
13
|
let teleports = ownedTeleportRes.data.data;
|
|
14
14
|
|
|
15
15
|
if (mod.userConfig.allowPublicTeleports) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const publicTeleports = maybePublicTeleportRes.data.data.filter((tele) => {
|
|
19
|
-
const teleport = JSON.parse(tele.value);
|
|
20
|
-
return teleport.public;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
teleports = teleports.concat(publicTeleports);
|
|
16
|
+
const publicTeleportRes = await findTp(args.tp, null, true);
|
|
17
|
+
teleports = teleports.concat(publicTeleportRes.data.data);
|
|
24
18
|
}
|
|
25
19
|
|
|
26
20
|
if (teleports.length === 0) {
|
|
@@ -29,7 +23,7 @@ async function main() {
|
|
|
29
23
|
|
|
30
24
|
const timeout = mod.userConfig.timeout;
|
|
31
25
|
|
|
32
|
-
if (timeout
|
|
26
|
+
if (timeout > 0) {
|
|
33
27
|
const lastExecuted = await takaro.variable.variableControllerSearch({
|
|
34
28
|
filters: {
|
|
35
29
|
key: ['lastExecuted'],
|
|
@@ -48,7 +42,6 @@ async function main() {
|
|
|
48
42
|
moduleId: mod.moduleId,
|
|
49
43
|
value: new Date().toISOString(),
|
|
50
44
|
});
|
|
51
|
-
console.log(createRes);
|
|
52
45
|
lastExecutedRecord = createRes.data.data;
|
|
53
46
|
} else {
|
|
54
47
|
const lastExecutedTime = new Date(lastExecutedRecord.value);
|
|
@@ -5,7 +5,18 @@ function getWaypointName(name) {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
async function main() {
|
|
8
|
-
const { pog, gameServerId, trigger } = data;
|
|
8
|
+
const { pog, gameServerId, trigger, module, itemId } = data;
|
|
9
|
+
|
|
10
|
+
const triggeredCommand = module.module.commands.find((command) => command.id === itemId);
|
|
11
|
+
|
|
12
|
+
if (!triggeredCommand) {
|
|
13
|
+
throw new Error('Waypoint not found.');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (!triggeredCommand.name.includes(`server ${gameServerId}`)) {
|
|
17
|
+
console.log(`Waypoint ${trigger} is not for this server.`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
9
20
|
|
|
10
21
|
if (!checkPermission(pog, `WAYPOINTS_USE_${trigger.toUpperCase()}_${gameServerId}`)) {
|
|
11
22
|
throw new TakaroUserError(`You are not allowed to use the waypoint ${trigger}.`);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { takaro, data } from '@takaro/helpers';
|
|
2
|
+
import { getVariableKey } from './utils.js';
|
|
2
3
|
|
|
3
4
|
async function main() {
|
|
4
5
|
const { pog, gameServerId, module: mod } = data;
|
|
5
6
|
|
|
6
|
-
const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data;
|
|
7
|
+
const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value;
|
|
7
8
|
|
|
8
9
|
const ownedTeleports = (
|
|
9
10
|
await takaro.variable.variableControllerSearch({
|
|
@@ -13,38 +14,36 @@ async function main() {
|
|
|
13
14
|
moduleId: [mod.moduleId],
|
|
14
15
|
},
|
|
15
16
|
search: {
|
|
16
|
-
key:
|
|
17
|
+
key: [getVariableKey(undefined, false)],
|
|
17
18
|
},
|
|
18
19
|
sortBy: 'key',
|
|
19
20
|
sortDirection: 'asc',
|
|
20
21
|
})
|
|
21
22
|
).data.data;
|
|
22
23
|
|
|
23
|
-
const
|
|
24
|
+
const publicTeleports = (
|
|
24
25
|
await takaro.variable.variableControllerSearch({
|
|
25
26
|
filters: {
|
|
26
27
|
gameServerId: [gameServerId],
|
|
27
28
|
moduleId: [mod.moduleId],
|
|
28
29
|
},
|
|
29
30
|
search: {
|
|
30
|
-
key: [
|
|
31
|
+
key: [getVariableKey(undefined, true)],
|
|
31
32
|
},
|
|
32
33
|
sortBy: 'key',
|
|
33
34
|
sortDirection: 'asc',
|
|
34
35
|
})
|
|
35
|
-
).data.data
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const isOwned = ownedTeleports.find((t) => t.playerId === pog.playerId);
|
|
36
|
+
).data.data
|
|
37
|
+
// Filter out public teleports that are owned by the player
|
|
38
|
+
// Since we'll be showing them in the owned teleports list
|
|
39
|
+
.filter((teleport) => {
|
|
40
|
+
return teleport.playerId !== pog.playerId;
|
|
41
|
+
});
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
});
|
|
43
|
+
const teleports = [...ownedTeleports, ...publicTeleports];
|
|
45
44
|
|
|
46
45
|
if (teleports.length === 0) {
|
|
47
|
-
await data.player.pm(`You have no teleports
|
|
46
|
+
await data.player.pm(`You have no teleports available, use ${prefix}settp <name> to set one.`);
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
49
|
|
|
@@ -53,7 +52,9 @@ async function main() {
|
|
|
53
52
|
for (const rawTeleport of teleports) {
|
|
54
53
|
const teleport = JSON.parse(rawTeleport.value);
|
|
55
54
|
await data.player.pm(
|
|
56
|
-
|
|
55
|
+
`${teleport.name}: (${teleport.x},${teleport.y},${teleport.z}) ${
|
|
56
|
+
rawTeleport.key.startsWith('pub') ? '(public)' : ''
|
|
57
|
+
}`
|
|
57
58
|
);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { takaro, data } from '@takaro/helpers';
|
|
2
2
|
|
|
3
|
-
export function getVariableKey(tpName) {
|
|
4
|
-
return `
|
|
3
|
+
export function getVariableKey(tpName, pub = false) {
|
|
4
|
+
if (pub && tpName) return `pubtp_${tpName}`;
|
|
5
|
+
if (pub && !tpName) return 'pubtp_';
|
|
6
|
+
if (tpName) return `tp_${tpName}`;
|
|
7
|
+
return 'tp_';
|
|
5
8
|
}
|
|
6
9
|
|
|
7
|
-
export async function findTp(tpName, playerId) {
|
|
10
|
+
export async function findTp(tpName, playerId, pub = false) {
|
|
8
11
|
const { gameServerId, module: mod } = data;
|
|
9
12
|
|
|
13
|
+
if (pub) {
|
|
14
|
+
return takaro.variable.variableControllerSearch({
|
|
15
|
+
filters: {
|
|
16
|
+
key: [getVariableKey(tpName, true)],
|
|
17
|
+
gameServerId: [gameServerId],
|
|
18
|
+
playerId: [playerId].filter(Boolean),
|
|
19
|
+
moduleId: [mod.moduleId],
|
|
20
|
+
},
|
|
21
|
+
sortBy: 'key',
|
|
22
|
+
sortDirection: 'asc',
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
return takaro.variable.variableControllerSearch({
|
|
11
27
|
filters: {
|
|
12
28
|
key: [getVariableKey(tpName)],
|