@takaro/modules 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/BuiltinModule.d.ts +49 -0
- package/dist/BuiltinModule.js +194 -0
- package/dist/BuiltinModule.js.map +1 -0
- package/dist/dto/base.d.ts +6 -0
- package/dist/dto/base.js +28 -0
- package/dist/dto/base.js.map +1 -0
- package/dist/dto/discordEvents.d.ts +31 -0
- package/dist/dto/discordEvents.js +92 -0
- package/dist/dto/discordEvents.js.map +1 -0
- package/dist/dto/gameEvents.d.ts +84 -0
- package/dist/dto/gameEvents.js +190 -0
- package/dist/dto/gameEvents.js.map +1 -0
- package/dist/dto/index.d.ts +37 -0
- package/dist/dto/index.js +18 -0
- package/dist/dto/index.js.map +1 -0
- package/dist/dto/takaroEvents.d.ts +150 -0
- package/dist/dto/takaroEvents.js +422 -0
- package/dist/dto/takaroEvents.js.map +1 -0
- package/dist/main.d.ts +4 -0
- package/dist/main.js +31 -0
- package/dist/main.js.map +1 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.js +18 -0
- package/dist/modules/chatBridge/hooks/DiscordToGame.js.map +1 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.js +14 -0
- package/dist/modules/chatBridge/hooks/GameToDiscord.js.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.js +9 -0
- package/dist/modules/chatBridge/hooks/PlayerConnected.js.map +1 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.d.ts +1 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js +9 -0
- package/dist/modules/chatBridge/hooks/PlayerDisconnected.js.map +1 -0
- package/dist/modules/chatBridge/index.d.ts +4 -0
- package/dist/modules/chatBridge/index.js +54 -0
- package/dist/modules/chatBridge/index.js.map +1 -0
- package/dist/modules/economyUtils/commands/balance.d.ts +1 -0
- package/dist/modules/economyUtils/commands/balance.js +7 -0
- package/dist/modules/economyUtils/commands/balance.js.map +1 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.d.ts +1 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.js +38 -0
- package/dist/modules/economyUtils/commands/confirmTransfer.js.map +1 -0
- package/dist/modules/economyUtils/commands/grantCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/grantCurrency.js +31 -0
- package/dist/modules/economyUtils/commands/grantCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.js +31 -0
- package/dist/modules/economyUtils/commands/revokeCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/topCurrency.d.ts +1 -0
- package/dist/modules/economyUtils/commands/topCurrency.js +22 -0
- package/dist/modules/economyUtils/commands/topCurrency.js.map +1 -0
- package/dist/modules/economyUtils/commands/transfer.d.ts +1 -0
- package/dist/modules/economyUtils/commands/transfer.js +55 -0
- package/dist/modules/economyUtils/commands/transfer.js.map +1 -0
- package/dist/modules/economyUtils/index.d.ts +4 -0
- package/dist/modules/economyUtils/index.js +117 -0
- package/dist/modules/economyUtils/index.js.map +1 -0
- package/dist/modules/geoBlock/hooks/IPDetected.d.ts +1 -0
- package/dist/modules/geoBlock/hooks/IPDetected.js +50 -0
- package/dist/modules/geoBlock/hooks/IPDetected.js.map +1 -0
- package/dist/modules/geoBlock/index.d.ts +8 -0
- package/dist/modules/geoBlock/index.js +321 -0
- package/dist/modules/geoBlock/index.js.map +1 -0
- package/dist/modules/gimme/commands/gimme.d.ts +1 -0
- package/dist/modules/gimme/commands/gimme.js +23 -0
- package/dist/modules/gimme/commands/gimme.js.map +1 -0
- package/dist/modules/gimme/index.d.ts +4 -0
- package/dist/modules/gimme/index.js +43 -0
- package/dist/modules/gimme/index.js.map +1 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.d.ts +1 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.js +54 -0
- package/dist/modules/highPingKicker/cronJobs/Ping check.js.map +1 -0
- package/dist/modules/highPingKicker/index.d.ts +4 -0
- package/dist/modules/highPingKicker/index.js +34 -0
- package/dist/modules/highPingKicker/index.js.map +1 -0
- package/dist/modules/lottery/commands/buyTicket.d.ts +1 -0
- package/dist/modules/lottery/commands/buyTicket.js +54 -0
- package/dist/modules/lottery/commands/buyTicket.js.map +1 -0
- package/dist/modules/lottery/commands/nextDraw.d.ts +1 -0
- package/dist/modules/lottery/commands/nextDraw.js +34 -0
- package/dist/modules/lottery/commands/nextDraw.js.map +1 -0
- package/dist/modules/lottery/commands/viewTickets.d.ts +1 -0
- package/dist/modules/lottery/commands/viewTickets.js +23 -0
- package/dist/modules/lottery/commands/viewTickets.js.map +1 -0
- package/dist/modules/lottery/cronJobs/drawLottery.d.ts +1 -0
- package/dist/modules/lottery/cronJobs/drawLottery.js +96 -0
- package/dist/modules/lottery/cronJobs/drawLottery.js.map +1 -0
- package/dist/modules/lottery/index.d.ts +4 -0
- package/dist/modules/lottery/index.js +73 -0
- package/dist/modules/lottery/index.js.map +1 -0
- package/dist/modules/playerOnboarding/commands/starterkit.d.ts +1 -0
- package/dist/modules/playerOnboarding/commands/starterkit.js +34 -0
- package/dist/modules/playerOnboarding/commands/starterkit.js.map +1 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.d.ts +1 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.js +11 -0
- package/dist/modules/playerOnboarding/hooks/playerConnected.js.map +1 -0
- package/dist/modules/playerOnboarding/index.d.ts +4 -0
- package/dist/modules/playerOnboarding/index.js +51 -0
- package/dist/modules/playerOnboarding/index.js.map +1 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.d.ts +1 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.js +9 -0
- package/dist/modules/serverMessages/cronJobs/Automated message.js.map +1 -0
- package/dist/modules/serverMessages/index.d.ts +4 -0
- package/dist/modules/serverMessages/index.js +35 -0
- package/dist/modules/serverMessages/index.js.map +1 -0
- package/dist/modules/teleports/commands/deletetp.d.ts +1 -0
- package/dist/modules/teleports/commands/deletetp.js +20 -0
- package/dist/modules/teleports/commands/deletetp.js.map +1 -0
- package/dist/modules/teleports/commands/deletewaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/deletewaypoint.js +54 -0
- package/dist/modules/teleports/commands/deletewaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/listwaypoints.d.ts +1 -0
- package/dist/modules/teleports/commands/listwaypoints.js +36 -0
- package/dist/modules/teleports/commands/listwaypoints.js.map +1 -0
- package/dist/modules/teleports/commands/setprivate.d.ts +1 -0
- package/dist/modules/teleports/commands/setprivate.js +31 -0
- package/dist/modules/teleports/commands/setprivate.js.map +1 -0
- package/dist/modules/teleports/commands/setpublic.d.ts +1 -0
- package/dist/modules/teleports/commands/setpublic.js +55 -0
- package/dist/modules/teleports/commands/setpublic.js.map +1 -0
- package/dist/modules/teleports/commands/settp.d.ts +1 -0
- package/dist/modules/teleports/commands/settp.js +42 -0
- package/dist/modules/teleports/commands/settp.js.map +1 -0
- package/dist/modules/teleports/commands/setwaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/setwaypoint.js +88 -0
- package/dist/modules/teleports/commands/setwaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/teleport.d.ts +1 -0
- package/dist/modules/teleports/commands/teleport.js +74 -0
- package/dist/modules/teleports/commands/teleport.js.map +1 -0
- package/dist/modules/teleports/commands/teleportwaypoint.d.ts +1 -0
- package/dist/modules/teleports/commands/teleportwaypoint.js +50 -0
- package/dist/modules/teleports/commands/teleportwaypoint.js.map +1 -0
- package/dist/modules/teleports/commands/tplist.d.ts +1 -0
- package/dist/modules/teleports/commands/tplist.js +45 -0
- package/dist/modules/teleports/commands/tplist.js.map +1 -0
- package/dist/modules/teleports/functions/utils.d.ts +2 -0
- package/dist/modules/teleports/functions/utils.js +18 -0
- package/dist/modules/teleports/functions/utils.js.map +1 -0
- package/dist/modules/teleports/index.d.ts +4 -0
- package/dist/modules/teleports/index.js +184 -0
- package/dist/modules/teleports/index.js.map +1 -0
- package/dist/modules/utils/commands/help.d.ts +1 -0
- package/dist/modules/utils/commands/help.js +29 -0
- package/dist/modules/utils/commands/help.js.map +1 -0
- package/dist/modules/utils/commands/ping.d.ts +1 -0
- package/dist/modules/utils/commands/ping.js +6 -0
- package/dist/modules/utils/commands/ping.js.map +1 -0
- package/dist/modules/utils/index.d.ts +4 -0
- package/dist/modules/utils/index.js +35 -0
- package/dist/modules/utils/index.js.map +1 -0
- package/dist/modules.json +478 -0
- package/package.json +26 -0
- package/scripts/buildBuiltinJson.ts +14 -0
- package/src/BuiltinModule.ts +125 -0
- package/src/__tests__/aliases.integration.test.ts +54 -0
- package/src/__tests__/builtinmodule.unit.test.ts +13 -0
- package/src/__tests__/commandArgs.integration.test.ts +285 -0
- package/src/__tests__/economyUtils.integration.test.ts +488 -0
- package/src/__tests__/geoblock.integration.test.ts +380 -0
- package/src/__tests__/gimme.integration.test.ts +97 -0
- package/src/__tests__/help.integration.test.ts +133 -0
- package/src/__tests__/lottery.integration.test.ts +332 -0
- package/src/__tests__/modulePermission.integration.test.ts +192 -0
- package/src/__tests__/onboarding.integration.test.ts +123 -0
- package/src/__tests__/ping.integration.test.ts +36 -0
- package/src/__tests__/roleExpiry.integration.test.ts +74 -0
- package/src/__tests__/serverMessages.integration.test.ts +104 -0
- package/src/__tests__/systemConfigCost.integration.test.ts +196 -0
- package/src/__tests__/teleports/listtp.integration.test.ts +115 -0
- package/src/__tests__/teleports/publicteleports.integration.test.ts +350 -0
- package/src/__tests__/teleports/teleport.integration.test.ts +109 -0
- package/src/__tests__/teleports/tpManagement.integration.test.ts +175 -0
- package/src/__tests__/teleports/waypoints.integration.test.ts +613 -0
- package/src/dto/base.ts +13 -0
- package/src/dto/discordEvents.ts +69 -0
- package/src/dto/gameEvents.ts +154 -0
- package/src/dto/index.ts +25 -0
- package/src/dto/takaroEvents.ts +290 -0
- package/src/main.ts +36 -0
- package/src/modules/.eslintrc +5 -0
- package/src/modules/chatBridge/hooks/DiscordToGame.js +18 -0
- package/src/modules/chatBridge/hooks/GameToDiscord.js +18 -0
- package/src/modules/chatBridge/hooks/PlayerConnected.js +11 -0
- package/src/modules/chatBridge/hooks/PlayerDisconnected.js +11 -0
- package/src/modules/chatBridge/index.ts +59 -0
- package/src/modules/economyUtils/commands/balance.js +8 -0
- package/src/modules/economyUtils/commands/confirmTransfer.js +55 -0
- package/src/modules/economyUtils/commands/grantCurrency.js +38 -0
- package/src/modules/economyUtils/commands/revokeCurrency.js +38 -0
- package/src/modules/economyUtils/commands/topCurrency.js +29 -0
- package/src/modules/economyUtils/commands/transfer.js +73 -0
- package/src/modules/economyUtils/index.ts +125 -0
- package/src/modules/geoBlock/hooks/IPDetected.js +52 -0
- package/src/modules/geoBlock/index.ts +331 -0
- package/src/modules/gimme/commands/gimme.js +28 -0
- package/src/modules/gimme/index.ts +49 -0
- package/src/modules/highPingKicker/cronJobs/Ping check.js +66 -0
- package/src/modules/highPingKicker/index.ts +39 -0
- package/src/modules/lottery/commands/buyTicket.js +68 -0
- package/src/modules/lottery/commands/nextDraw.js +45 -0
- package/src/modules/lottery/commands/viewTickets.js +32 -0
- package/src/modules/lottery/cronJobs/drawLottery.js +124 -0
- package/src/modules/lottery/index.ts +80 -0
- package/src/modules/playerOnboarding/commands/starterkit.js +47 -0
- package/src/modules/playerOnboarding/hooks/playerConnected.js +14 -0
- package/src/modules/playerOnboarding/index.ts +58 -0
- package/src/modules/serverMessages/cronJobs/Automated message.js +12 -0
- package/src/modules/serverMessages/index.ts +40 -0
- package/src/modules/teleports/commands/deletetp.js +25 -0
- package/src/modules/teleports/commands/deletewaypoint.js +77 -0
- package/src/modules/teleports/commands/listwaypoints.js +55 -0
- package/src/modules/teleports/commands/setprivate.js +39 -0
- package/src/modules/teleports/commands/setpublic.js +71 -0
- package/src/modules/teleports/commands/settp.js +54 -0
- package/src/modules/teleports/commands/setwaypoint.js +112 -0
- package/src/modules/teleports/commands/teleport.js +93 -0
- package/src/modules/teleports/commands/teleportwaypoint.js +72 -0
- package/src/modules/teleports/commands/tplist.js +61 -0
- package/src/modules/teleports/functions/utils.js +20 -0
- package/src/modules/teleports/index.ts +193 -0
- package/src/modules/utils/commands/help.js +38 -0
- package/src/modules/utils/commands/ping.js +7 -0
- package/src/modules/utils/index.ts +40 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +9 -0
- package/typedoc.json +3 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { EventTypes } from './dto/index.js';
|
|
2
|
+
import { TakaroDTO } from '@takaro/util';
|
|
3
|
+
export declare class ICommandArgument extends TakaroDTO<ICommandArgument> {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
helpText?: string;
|
|
7
|
+
defaultValue?: string | null;
|
|
8
|
+
position?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class ICommand extends TakaroDTO<ICommand> {
|
|
11
|
+
name: string;
|
|
12
|
+
function: string;
|
|
13
|
+
trigger: string;
|
|
14
|
+
helpText?: string;
|
|
15
|
+
arguments: ICommandArgument[];
|
|
16
|
+
}
|
|
17
|
+
export declare class IHook extends TakaroDTO<IHook> {
|
|
18
|
+
name: string;
|
|
19
|
+
function: string;
|
|
20
|
+
eventType: EventTypes;
|
|
21
|
+
}
|
|
22
|
+
export declare class ICronJob extends TakaroDTO<ICronJob> {
|
|
23
|
+
name: string;
|
|
24
|
+
function: string;
|
|
25
|
+
temporalValue: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class IFunction extends TakaroDTO<IFunction> {
|
|
28
|
+
name: string;
|
|
29
|
+
function: string;
|
|
30
|
+
}
|
|
31
|
+
export declare class IPermission extends TakaroDTO<IPermission> {
|
|
32
|
+
permission: string;
|
|
33
|
+
description: string;
|
|
34
|
+
friendlyName: string;
|
|
35
|
+
canHaveCount?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare class BuiltinModule<T> extends TakaroDTO<T> {
|
|
38
|
+
constructor(name: string, description: string, configSchema: string, uiSchema?: string);
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
configSchema: string;
|
|
42
|
+
uiSchema: string;
|
|
43
|
+
commands: Array<ICommand>;
|
|
44
|
+
hooks: Array<IHook>;
|
|
45
|
+
cronJobs: Array<ICronJob>;
|
|
46
|
+
functions: Array<IFunction>;
|
|
47
|
+
permissions: IPermission[];
|
|
48
|
+
protected loadFn(type: 'commands' | 'hooks' | 'cronJobs' | 'functions', name: string): string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { readFileSync, readdirSync } from 'fs';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import * as url from 'url';
|
|
13
|
+
import { IsString, IsOptional, IsNumber, IsArray, ValidateNested, IsEnum, IsBoolean } from 'class-validator';
|
|
14
|
+
import { Type } from 'class-transformer';
|
|
15
|
+
import { HookEvents } from './dto/index.js';
|
|
16
|
+
import { TakaroDTO } from '@takaro/util';
|
|
17
|
+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
18
|
+
export class ICommandArgument extends TakaroDTO {
|
|
19
|
+
}
|
|
20
|
+
__decorate([
|
|
21
|
+
IsString(),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], ICommandArgument.prototype, "name", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
IsString(),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], ICommandArgument.prototype, "type", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
IsString(),
|
|
30
|
+
IsOptional(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], ICommandArgument.prototype, "helpText", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
IsString(),
|
|
35
|
+
IsOptional(),
|
|
36
|
+
__metadata("design:type", Object)
|
|
37
|
+
], ICommandArgument.prototype, "defaultValue", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
IsNumber(),
|
|
40
|
+
IsOptional(),
|
|
41
|
+
__metadata("design:type", Number)
|
|
42
|
+
], ICommandArgument.prototype, "position", void 0);
|
|
43
|
+
export class ICommand extends TakaroDTO {
|
|
44
|
+
}
|
|
45
|
+
__decorate([
|
|
46
|
+
IsString(),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], ICommand.prototype, "name", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
IsString(),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], ICommand.prototype, "function", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
IsString(),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], ICommand.prototype, "trigger", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
IsString(),
|
|
59
|
+
IsOptional(),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], ICommand.prototype, "helpText", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
ValidateNested({ each: true }),
|
|
64
|
+
Type(() => ICommandArgument),
|
|
65
|
+
IsOptional(),
|
|
66
|
+
__metadata("design:type", Array)
|
|
67
|
+
], ICommand.prototype, "arguments", void 0);
|
|
68
|
+
export class IHook extends TakaroDTO {
|
|
69
|
+
}
|
|
70
|
+
__decorate([
|
|
71
|
+
IsString(),
|
|
72
|
+
__metadata("design:type", String)
|
|
73
|
+
], IHook.prototype, "name", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
IsString(),
|
|
76
|
+
__metadata("design:type", String)
|
|
77
|
+
], IHook.prototype, "function", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
IsEnum(Object.values(HookEvents)),
|
|
80
|
+
__metadata("design:type", String)
|
|
81
|
+
], IHook.prototype, "eventType", void 0);
|
|
82
|
+
export class ICronJob extends TakaroDTO {
|
|
83
|
+
}
|
|
84
|
+
__decorate([
|
|
85
|
+
IsString(),
|
|
86
|
+
__metadata("design:type", String)
|
|
87
|
+
], ICronJob.prototype, "name", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
IsString(),
|
|
90
|
+
__metadata("design:type", String)
|
|
91
|
+
], ICronJob.prototype, "function", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
IsString(),
|
|
94
|
+
__metadata("design:type", String)
|
|
95
|
+
], ICronJob.prototype, "temporalValue", void 0);
|
|
96
|
+
export class IFunction extends TakaroDTO {
|
|
97
|
+
}
|
|
98
|
+
__decorate([
|
|
99
|
+
IsString(),
|
|
100
|
+
__metadata("design:type", String)
|
|
101
|
+
], IFunction.prototype, "name", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
IsString(),
|
|
104
|
+
__metadata("design:type", String)
|
|
105
|
+
], IFunction.prototype, "function", void 0);
|
|
106
|
+
export class IPermission extends TakaroDTO {
|
|
107
|
+
constructor() {
|
|
108
|
+
super(...arguments);
|
|
109
|
+
this.canHaveCount = false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
__decorate([
|
|
113
|
+
IsString(),
|
|
114
|
+
__metadata("design:type", String)
|
|
115
|
+
], IPermission.prototype, "permission", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
IsString(),
|
|
118
|
+
__metadata("design:type", String)
|
|
119
|
+
], IPermission.prototype, "description", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
IsString(),
|
|
122
|
+
__metadata("design:type", String)
|
|
123
|
+
], IPermission.prototype, "friendlyName", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
IsOptional(),
|
|
126
|
+
IsBoolean(),
|
|
127
|
+
__metadata("design:type", Boolean)
|
|
128
|
+
], IPermission.prototype, "canHaveCount", void 0);
|
|
129
|
+
export class BuiltinModule extends TakaroDTO {
|
|
130
|
+
constructor(name, description, configSchema, uiSchema = JSON.stringify({})) {
|
|
131
|
+
super();
|
|
132
|
+
this.commands = [];
|
|
133
|
+
this.hooks = [];
|
|
134
|
+
this.cronJobs = [];
|
|
135
|
+
this.functions = [];
|
|
136
|
+
this.permissions = [];
|
|
137
|
+
this.name = name;
|
|
138
|
+
this.description = description;
|
|
139
|
+
this.configSchema = configSchema;
|
|
140
|
+
this.uiSchema = uiSchema;
|
|
141
|
+
}
|
|
142
|
+
loadFn(type, name) {
|
|
143
|
+
const folderPath = path.join(__dirname, 'modules', this.name, type);
|
|
144
|
+
const files = readdirSync(folderPath);
|
|
145
|
+
const file = files.find((file) => file.replace('.js', '') === name);
|
|
146
|
+
if (!file) {
|
|
147
|
+
throw new Error(`Could not find ${name} in ${this.name}'s ${type}. Did you provide a function implementation?`);
|
|
148
|
+
}
|
|
149
|
+
return readFileSync(path.join(folderPath, file), 'utf-8');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
__decorate([
|
|
153
|
+
IsString(),
|
|
154
|
+
__metadata("design:type", String)
|
|
155
|
+
], BuiltinModule.prototype, "name", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
IsString(),
|
|
158
|
+
__metadata("design:type", String)
|
|
159
|
+
], BuiltinModule.prototype, "description", void 0);
|
|
160
|
+
__decorate([
|
|
161
|
+
IsString(),
|
|
162
|
+
__metadata("design:type", String)
|
|
163
|
+
], BuiltinModule.prototype, "configSchema", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
IsString(),
|
|
166
|
+
__metadata("design:type", String)
|
|
167
|
+
], BuiltinModule.prototype, "uiSchema", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
ValidateNested({ each: true }),
|
|
170
|
+
Type(() => ICommand),
|
|
171
|
+
__metadata("design:type", Array)
|
|
172
|
+
], BuiltinModule.prototype, "commands", void 0);
|
|
173
|
+
__decorate([
|
|
174
|
+
ValidateNested({ each: true }),
|
|
175
|
+
Type(() => IHook),
|
|
176
|
+
__metadata("design:type", Array)
|
|
177
|
+
], BuiltinModule.prototype, "hooks", void 0);
|
|
178
|
+
__decorate([
|
|
179
|
+
ValidateNested({ each: true }),
|
|
180
|
+
Type(() => ICronJob),
|
|
181
|
+
__metadata("design:type", Array)
|
|
182
|
+
], BuiltinModule.prototype, "cronJobs", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
ValidateNested({ each: true }),
|
|
185
|
+
Type(() => IFunction),
|
|
186
|
+
__metadata("design:type", Array)
|
|
187
|
+
], BuiltinModule.prototype, "functions", void 0);
|
|
188
|
+
__decorate([
|
|
189
|
+
IsArray(),
|
|
190
|
+
Type(() => IPermission),
|
|
191
|
+
ValidateNested({ each: true }),
|
|
192
|
+
__metadata("design:type", Array)
|
|
193
|
+
], BuiltinModule.prototype, "permissions", void 0);
|
|
194
|
+
//# sourceMappingURL=BuiltinModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuiltinModule.js","sourceRoot":"","sources":["../src/BuiltinModule.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC/C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,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|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { TakaroDTO } from '@takaro/util';
|
|
11
|
+
import { IsISO8601, IsString } from 'class-validator';
|
|
12
|
+
import { Exclude } from 'class-transformer';
|
|
13
|
+
export class BaseEvent extends TakaroDTO {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.timestamp = new Date().toISOString();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
__decorate([
|
|
20
|
+
IsISO8601(),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], BaseEvent.prototype, "timestamp", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
IsString(),
|
|
25
|
+
Exclude({ toPlainOnly: true }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], BaseEvent.prototype, "type", void 0);
|
|
28
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/dto/base.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,MAAM,OAAO,SAAa,SAAQ,SAAY;IAA9C;;QAEE,cAAS,GAAW,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAK/C,CAAC;CAAA;AALC;IADC,SAAS,EAAE;;4CACiC;AAI7C;IAFC,QAAQ,EAAE;IACV,OAAO,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;;uCACd"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TakaroDTO } from '@takaro/util';
|
|
2
|
+
import { ValueOf } from 'type-fest';
|
|
3
|
+
import { BaseEvent } from './base.js';
|
|
4
|
+
export declare const DiscordEvents: {
|
|
5
|
+
readonly DISCORD_MESSAGE: "discord-message";
|
|
6
|
+
};
|
|
7
|
+
export declare class BaseDiscordEvent<T> extends BaseEvent<T> {
|
|
8
|
+
type: ValueOf<typeof DiscordEvents>;
|
|
9
|
+
msg: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class EventDiscordUser extends TakaroDTO<EventDiscordUser> {
|
|
12
|
+
id: string;
|
|
13
|
+
username: string;
|
|
14
|
+
displayName: string;
|
|
15
|
+
isBot: boolean;
|
|
16
|
+
isTakaroBot: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class EventDiscordChannel extends TakaroDTO<EventDiscordChannel> {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class HookEventDiscordMessage extends BaseEvent<HookEventDiscordMessage> {
|
|
23
|
+
type: "discord-message";
|
|
24
|
+
msg: string;
|
|
25
|
+
author: EventDiscordUser;
|
|
26
|
+
channel: EventDiscordChannel;
|
|
27
|
+
}
|
|
28
|
+
export declare function isDiscordMessageEvent(a: unknown): a is HookEventDiscordMessage;
|
|
29
|
+
export declare const DiscordEventsMapping: {
|
|
30
|
+
readonly "discord-message": typeof HookEventDiscordMessage;
|
|
31
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { IsBoolean, IsEnum, IsString, ValidateNested } from 'class-validator';
|
|
11
|
+
import { Type } from 'class-transformer';
|
|
12
|
+
import { TakaroDTO } from '@takaro/util';
|
|
13
|
+
import { BaseEvent } from './base.js';
|
|
14
|
+
export const DiscordEvents = {
|
|
15
|
+
DISCORD_MESSAGE: 'discord-message',
|
|
16
|
+
};
|
|
17
|
+
export class BaseDiscordEvent extends BaseEvent {
|
|
18
|
+
}
|
|
19
|
+
__decorate([
|
|
20
|
+
IsEnum(DiscordEvents),
|
|
21
|
+
__metadata("design:type", Object)
|
|
22
|
+
], BaseDiscordEvent.prototype, "type", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
IsString(),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], BaseDiscordEvent.prototype, "msg", void 0);
|
|
27
|
+
export class EventDiscordUser extends TakaroDTO {
|
|
28
|
+
}
|
|
29
|
+
__decorate([
|
|
30
|
+
IsString(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], EventDiscordUser.prototype, "id", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
IsString(),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], EventDiscordUser.prototype, "username", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
IsString(),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], EventDiscordUser.prototype, "displayName", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
IsBoolean(),
|
|
43
|
+
__metadata("design:type", Boolean)
|
|
44
|
+
], EventDiscordUser.prototype, "isBot", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
IsBoolean(),
|
|
47
|
+
__metadata("design:type", Boolean)
|
|
48
|
+
], EventDiscordUser.prototype, "isTakaroBot", void 0);
|
|
49
|
+
export class EventDiscordChannel extends TakaroDTO {
|
|
50
|
+
}
|
|
51
|
+
__decorate([
|
|
52
|
+
IsString(),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], EventDiscordChannel.prototype, "id", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
IsString(),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], EventDiscordChannel.prototype, "name", void 0);
|
|
59
|
+
export class HookEventDiscordMessage extends BaseEvent {
|
|
60
|
+
constructor() {
|
|
61
|
+
super(...arguments);
|
|
62
|
+
this.type = DiscordEvents.DISCORD_MESSAGE;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
__decorate([
|
|
66
|
+
IsString(),
|
|
67
|
+
__metadata("design:type", Object)
|
|
68
|
+
], HookEventDiscordMessage.prototype, "type", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
IsString(),
|
|
71
|
+
__metadata("design:type", String)
|
|
72
|
+
], HookEventDiscordMessage.prototype, "msg", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
ValidateNested(),
|
|
75
|
+
Type(() => EventDiscordUser),
|
|
76
|
+
__metadata("design:type", EventDiscordUser)
|
|
77
|
+
], HookEventDiscordMessage.prototype, "author", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
ValidateNested(),
|
|
80
|
+
Type(() => EventDiscordChannel),
|
|
81
|
+
__metadata("design:type", EventDiscordChannel)
|
|
82
|
+
], HookEventDiscordMessage.prototype, "channel", void 0);
|
|
83
|
+
export function isDiscordMessageEvent(a) {
|
|
84
|
+
if (typeof a === 'object' && a !== null) {
|
|
85
|
+
return 'type' in a && a.type === DiscordEvents.DISCORD_MESSAGE;
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
export const DiscordEventsMapping = {
|
|
90
|
+
[DiscordEvents.DISCORD_MESSAGE]: HookEventDiscordMessage,
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=discordEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discordEvents.js","sourceRoot":"","sources":["../../src/dto/discordEvents.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,eAAe,EAAE,iBAAiB;CAC1B,CAAC;AAEX,MAAM,OAAO,gBAAoB,SAAQ,SAAY;CAMpD;AAJS;IADP,MAAM,CAAC,aAAa,CAAC;;8CACsB;AAG5C;IADC,QAAQ,EAAE;;6CACC;AAGd,MAAM,OAAO,gBAAiB,SAAQ,SAA2B;CAehE;AAbC;IADC,QAAQ,EAAE;;4CACA;AAGX;IADC,QAAQ,EAAE;;kDACM;AAGjB;IADC,QAAQ,EAAE;;qDACS;AAGpB;IADC,SAAS,EAAE;;+CACG;AAGf;IADC,SAAS,EAAE;;qDACS;AAGvB,MAAM,OAAO,mBAAoB,SAAQ,SAA8B;CAMtE;AAJC;IADC,QAAQ,EAAE;;+CACA;AAGX;IADC,QAAQ,EAAE;;iDACE;AAGf,MAAM,OAAO,uBAAwB,SAAQ,SAAkC;IAA/E;;QAEE,SAAI,GAAG,aAAa,CAAC,eAAe,CAAC;IAYvC,CAAC;CAAA;AAZC;IADC,QAAQ,EAAE;;qDAC0B;AAGrC;IADC,QAAQ,EAAE;;oDACC;AAIZ;IAFC,cAAc,EAAE;IAChB,IAAI,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC;8BACrB,gBAAgB;uDAAC;AAIzB;IAFC,cAAc,EAAE;IAChB,IAAI,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC;8BACvB,mBAAmB;wDAAC;AAG/B,MAAM,UAAU,qBAAqB,CAAC,CAAU;IAC9C,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,eAAe,CAAC;IACjE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,CAAC,aAAa,CAAC,eAAe,CAAC,EAAE,uBAAuB;CAChD,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { TakaroDTO } from '@takaro/util';
|
|
2
|
+
import { BaseEvent } from './base.js';
|
|
3
|
+
import { ValueOf } from 'type-fest';
|
|
4
|
+
export declare const GameEvents: {
|
|
5
|
+
readonly LOG_LINE: "log";
|
|
6
|
+
readonly PLAYER_CONNECTED: "player-connected";
|
|
7
|
+
readonly PLAYER_DISCONNECTED: "player-disconnected";
|
|
8
|
+
readonly CHAT_MESSAGE: "chat-message";
|
|
9
|
+
readonly PLAYER_DEATH: "player-death";
|
|
10
|
+
readonly ENTITY_KILLED: "entity-killed";
|
|
11
|
+
};
|
|
12
|
+
export type GameEventTypes = ValueOf<typeof GameEvents>;
|
|
13
|
+
export declare class IGamePlayer extends TakaroDTO<IGamePlayer> {
|
|
14
|
+
/**
|
|
15
|
+
* Unique identifier for this player, as used by the game
|
|
16
|
+
*/
|
|
17
|
+
gameId: string;
|
|
18
|
+
/**
|
|
19
|
+
* The players username
|
|
20
|
+
*/
|
|
21
|
+
name: string;
|
|
22
|
+
steamId?: string;
|
|
23
|
+
epicOnlineServicesId?: string;
|
|
24
|
+
xboxLiveId?: string;
|
|
25
|
+
platformId?: string;
|
|
26
|
+
ip?: string;
|
|
27
|
+
ping?: number;
|
|
28
|
+
}
|
|
29
|
+
export declare class BaseGameEvent<T> extends BaseEvent<T> {
|
|
30
|
+
type: ValueOf<typeof GameEvents>;
|
|
31
|
+
msg: string;
|
|
32
|
+
}
|
|
33
|
+
export interface IPosition {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
z: number;
|
|
37
|
+
}
|
|
38
|
+
export declare class EventLogLine extends BaseGameEvent<EventLogLine> {
|
|
39
|
+
type: "log";
|
|
40
|
+
}
|
|
41
|
+
export declare class EventPlayerConnected extends BaseGameEvent<EventPlayerConnected> {
|
|
42
|
+
type: "player-connected";
|
|
43
|
+
player: IGamePlayer;
|
|
44
|
+
}
|
|
45
|
+
export declare class EventPlayerDisconnected extends BaseGameEvent<EventPlayerDisconnected> {
|
|
46
|
+
type: "player-disconnected";
|
|
47
|
+
player: IGamePlayer;
|
|
48
|
+
}
|
|
49
|
+
export declare enum ChatChannel {
|
|
50
|
+
GLOBAL = "global",
|
|
51
|
+
TEAM = "team",
|
|
52
|
+
WHISPER = "whisper"
|
|
53
|
+
}
|
|
54
|
+
export declare class EventChatMessage extends BaseGameEvent<EventChatMessage> {
|
|
55
|
+
type: "chat-message";
|
|
56
|
+
player?: IGamePlayer;
|
|
57
|
+
channel: ChatChannel;
|
|
58
|
+
msg: string;
|
|
59
|
+
}
|
|
60
|
+
export declare class IPosition {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
z: number;
|
|
64
|
+
}
|
|
65
|
+
export declare class EventPlayerDeath extends BaseGameEvent<EventPlayerDeath> {
|
|
66
|
+
type: "player-death";
|
|
67
|
+
player: IGamePlayer;
|
|
68
|
+
attacker?: IGamePlayer;
|
|
69
|
+
position: IPosition;
|
|
70
|
+
}
|
|
71
|
+
export declare class EventEntityKilled extends BaseGameEvent<EventEntityKilled> {
|
|
72
|
+
type: "entity-killed";
|
|
73
|
+
player: IGamePlayer;
|
|
74
|
+
entity: string;
|
|
75
|
+
weapon: string;
|
|
76
|
+
}
|
|
77
|
+
export declare const GameEventsMapping: {
|
|
78
|
+
readonly "player-connected": typeof EventPlayerConnected;
|
|
79
|
+
readonly "player-disconnected": typeof EventPlayerDisconnected;
|
|
80
|
+
readonly "chat-message": typeof EventChatMessage;
|
|
81
|
+
readonly "player-death": typeof EventPlayerDeath;
|
|
82
|
+
readonly "entity-killed": typeof EventEntityKilled;
|
|
83
|
+
readonly log: typeof EventLogLine;
|
|
84
|
+
};
|