Skip to content
This repository was archived by the owner on Apr 16, 2022. It is now read-only.

Commit ff007fa

Browse files
committed
Added plugins loaded in process title
1 parent 287ac81 commit ff007fa

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/bewss/plugin/pluginManager.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface examplePlugin {
2121
class pluginManager {
2222
private bewss: bewss
2323
private plugins = new Map<string, { config: examplePluginConfig, plugin: examplePlugin }>() // path: { config, plugin }
24+
private pluginNames: Array<string> = []
2425
private latestInterface = "https://raw.githubusercontent.com/PMK744/Node-BEWSS/main/src/bewss/%40interface/bewss.i.ts"
2526
public root = path.resolve(process.cwd())
2627
public pluginsPath = path.resolve(this.root, './plugins')
@@ -123,6 +124,7 @@ class pluginManager {
123124
const plugin: examplePlugin = require(entryPoint)
124125
const newPlugin: examplePlugin = new plugin(new pluginApi(this.bewss, config, path))
125126
this.info(`Successfully loaded plugin "${config.displayName || path}"`)
127+
this.pluginNames.push(config.displayName || config.name || path)
126128
this.plugins.set(path, {
127129
config,
128130
plugin: newPlugin,
@@ -332,6 +334,9 @@ class pluginManager {
332334
return true
333335
}
334336

337+
getPlugins(): Array<string> {
338+
return this.pluginNames
339+
}
335340

336341
private info(...content: unknown[]): void {
337342
console.log(`${chalk.gray(moment().format("HH:mm:ss"))} ${chalk.blue("[PluginManager]")} ${chalk.cyan("[Info]")}`, ...content)

src/bewss/server/serverManager.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class serverManager extends EventEmitter {
77
private ws: Websocket.Server
88
private server: Websocket
99
private port: number
10+
private inv
1011

1112
constructor (bewss: bewss, port: number) {
1213
super()
@@ -15,11 +16,12 @@ class serverManager extends EventEmitter {
1516
}
1617

1718
async onEnabled(): Promise<void> {
18-
process.title = 'Minecraft Bedrock Edition - BeWss'
19+
this.startProcessTitle()
1920
await this.createServer()
2021
}
2122

2223
async onDisabled(): Promise<void> {
24+
clearInterval(this.inv)
2325
this.ws.close()
2426
this.emit('wssclosed')
2527
this.bewss.getLogger().info('Websocket server closed.')
@@ -56,6 +58,16 @@ class serverManager extends EventEmitter {
5658
})
5759
}
5860

61+
private startProcessTitle(): void {
62+
this.inv = setInterval(() => {
63+
const plugins = this.bewss.getPluginManager().getPlugins()
64+
let pluginDisplay = plugins.join(', ')
65+
if (plugins.length == 0) pluginDisplay = 'None'
66+
67+
process.title = `Minecraft Bedrock Edition - BeWss | Plugins Loaded - ${pluginDisplay}`
68+
}, 10)
69+
}
70+
5971
sendJSON(json: JSON): void {
6072
this.server.send(JSON.stringify(json))
6173
}

0 commit comments

Comments
 (0)