-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.ts
81 lines (73 loc) · 2 KB
/
plugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import type { PluginContext } from '@rcv-prod-toolkit/types'
import StaticData from './StaticData'
module.exports = async (ctx: PluginContext) => {
const namespace = ctx.plugin.module.getName()
const configRes = await ctx.LPTE.request({
meta: {
type: 'request',
namespace: 'plugin-config',
version: 1
}
})
if (configRes === undefined) {
return ctx.log.warn(`${namespace} config could not be loaded`)
}
const config = configRes.config
const staticData = new StaticData(ctx, config)
ctx.LPTE.emit({
meta: {
type: 'add-serves',
namespace: 'ui',
version: 1
},
serves: [
{
frontend: 'frontend',
id: namespace
}
]
})
staticData.onReady(() => {
const gameStatic = {
seasons: require(`../frontend/data/constants/seasons.json`),
queues: require(`../frontend/data/constants/queues.json`),
maps: require(`../frontend/data/en_US/map.json`),
gameModes: require(`../frontend/data/constants/gameModes.json`),
gameTypes: require(`../frontend/data/constants/gameTypes.json`),
perks: require(`../frontend/data/en_US/runesReforged.json`),
champions: Object.values(
require(`../frontend/data/en_US/champion.json`).data
),
items: Object.values(require(`../frontend/data/en_US/item.json`).data),
itemBin: Object.values(require(`../frontend/data/item.bin.json`)),
version: staticData.version
}
ctx.LPTE.on(namespace, 'request-constants', (e: any) => {
ctx.LPTE.emit({
meta: {
type: e.meta.reply,
namespace: 'reply',
version: 1,
reply: e.meta.reply
},
constants: gameStatic
})
})
ctx.LPTE.emit({
meta: {
namespace,
type: 'static-loaded',
version: 1
},
constants: gameStatic
})
ctx.LPTE.emit({
meta: {
type: 'plugin-status-change',
namespace: 'lpt',
version: 1
},
status: 'RUNNING'
})
})
}