Skip to content

Commit

Permalink
interface改为abstract class
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Jan 27, 2022
1 parent a931372 commit 91f871b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ servers:
- servers/
profileEndpoint: https://api.mojang.com/profiles/minecraft
plugins:
- test
# - test
14 changes: 8 additions & 6 deletions src/plugin-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import {Client} from './client'
import {Config} from './config'
import {ProxyServer} from './proxy-server'

export interface IPlugin {
name: string
new(server: ProxyServer, plugin: PluginHook)
export abstract class MinecraftProxyPlugin {
abstract name: string
protected constructor(
protected readonly server: ProxyServer, protected readonly plugin: PluginHook,
) {}
}

@Service()
Expand All @@ -24,7 +26,7 @@ export class PluginHook {
},
})

public readonly plugins = new Map<string, IPlugin>()
public readonly plugins = new Map<string, MinecraftProxyPlugin>()

private readonly logger: Logger = createLogger({name: 'plugin'})

Expand Down Expand Up @@ -59,8 +61,8 @@ export class PluginHook {
}
}

private constructPlugin(plugin: unknown): IPlugin {
private constructPlugin(plugin: unknown): MinecraftProxyPlugin {
if (!is.class_(plugin)) throw new VError(`${plugin} is not a constructor`)
return new plugin(this.server, this) as IPlugin
return new plugin(this.server, this) as MinecraftProxyPlugin
}
}

0 comments on commit 91f871b

Please sign in to comment.