feat: update server filter

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2020-01-17 17:43:45 +08:00
parent 85fe0cf87a
commit 5642a93974
2 changed files with 13 additions and 7 deletions

View File

@ -57,23 +57,29 @@ export class HelloWorld extends interfaces.Plugin {
return ['world'] return ['world']
} }
@listener({ servertype: 'bukkit' }) @listener({ servers: ['bukkit'] })
playerjoin(event: org.bukkit.event.player.PlayerJoinEvent) { PlayerJoin(event: org.bukkit.event.player.PlayerJoinEvent) {
let plyaer = event.getPlayer(); let plyaer = event.getPlayer();
this.logger.console(`§cBukkit §aPlayerJoinEvent: §b${plyaer.getName()}`) this.logger.console(`§cBukkit §aPlayerJoinEvent: §b${plyaer.getName()}`)
setTimeout(() => this.logger.sender(plyaer, `§a欢迎来到 §bMiaoScript §a的世界!`), 10); setTimeout(() => this.logger.sender(plyaer, `§a欢迎来到 §bMiaoScript §a的世界!`), 10);
} }
@listener({ servertype: 'sponge' }) @listener({ servers: ['sponge'] })
clientconnectionevent$join(event: org.spongepowered.api.event.network.ClientConnectionEvent.Join) { ClientConnectionEvent$Join(event: org.spongepowered.api.event.network.ClientConnectionEvent.Join) {
this.logger.console(`§cSponge §aClientConnectionEvent.Join: §b${event.getTargetEntity().getName()}`) this.logger.console(`§cSponge §aClientConnectionEvent.Join: §b${event.getTargetEntity().getName()}`)
setTimeout(() => this.logger.sender(event.getTargetEntity(), `§a欢迎来到 §bMiaoScript §a的世界!`), 10); setTimeout(() => this.logger.sender(event.getTargetEntity(), `§a欢迎来到 §bMiaoScript §a的世界!`), 10);
} }
@listener({ servertype: 'bungee' }) @listener({ servers: ['bungee'] })
serverconnected(e: any) { ServerConnected(e: any) {
let event = e as net.md_5.bungee.api.event.ServerConnectedEvent let event = e as net.md_5.bungee.api.event.ServerConnectedEvent
this.logger.console(`§cBungeeCord §aServerConnectedEvent: §b${event.getPlayer().getDisplayName()}`) this.logger.console(`§cBungeeCord §aServerConnectedEvent: §b${event.getPlayer().getDisplayName()}`)
setTimeout(() => this.logger.sender(event.getPlayer(), `§a欢迎来到 §bMiaoScript §a的世界 §6来自 §cBungeeCord §6的问候!`), 10); setTimeout(() => this.logger.sender(event.getPlayer(), `§a欢迎来到 §bMiaoScript §a的世界 §6来自 §cBungeeCord §6的问候!`), 10);
} }
@listener({ servers: ["bungee"] })
PluginMessage(e: any) {
let event = e as net.md_5.bungee.api.event.PluginMessageEvent
this.logger.console(`§cBungeeCord §aPluginMessageEvent: §b${event.getTag()}`)
}
} }

View File

@ -78,7 +78,7 @@ export class Test extends interfaces.Plugin {
return ['run', 'reload', 'channel', 'add', 'yaml', 'speed', 'top', 'up'] return ['run', 'reload', 'channel', 'add', 'yaml', 'speed', 'top', 'up']
} }
@listener({ servertype: 'bukkit' }) @listener({ servers: ['bukkit'] })
playerjoin(event: any) { playerjoin(event: any) {
this.logger.console('PlayerJoinEvent: ', event.player.name) this.logger.console('PlayerJoinEvent: ', event.player.name)
} }