2020-05-02 16:14:47 +00:00
|
|
|
/// <reference types="@ccms/types/dist/typings/bukkit" />
|
|
|
|
/// <reference types="@ccms/types/dist/typings/sponge" />
|
|
|
|
/// <reference types="@ccms/types/dist/typings/bungee" />
|
|
|
|
/// <reference types="@ccms/types/dist/typings/nukkit" />
|
2020-01-16 09:27:24 +00:00
|
|
|
|
2020-05-02 16:14:47 +00:00
|
|
|
import { server } from '@ccms/api';
|
|
|
|
import { inject } from '@ccms/container';
|
|
|
|
import { plugin, interfaces, cmd, listener, tab } from '@ccms/plugin'
|
2019-09-22 10:02:59 +00:00
|
|
|
|
|
|
|
@plugin({ name: 'HelloWorld', version: '1.0.0', author: 'MiaoWoo', source: __filename })
|
|
|
|
export class HelloWorld extends interfaces.Plugin {
|
2020-02-15 11:40:25 +00:00
|
|
|
@inject(server.Server)
|
|
|
|
private Server: server.Server
|
|
|
|
|
2019-09-22 10:02:59 +00:00
|
|
|
load() {
|
2020-02-15 11:40:25 +00:00
|
|
|
this.logger.log('Plugin load from MiaoScript Plugin System...');
|
2019-09-22 10:02:59 +00:00
|
|
|
}
|
|
|
|
enable() {
|
2020-02-15 11:40:25 +00:00
|
|
|
this.logger.log('Plugin enable from MiaoScript Plugin System...');
|
2019-09-22 10:02:59 +00:00
|
|
|
}
|
|
|
|
disable() {
|
2020-02-15 11:40:25 +00:00
|
|
|
this.logger.log('Plugin disable from MiaoScript Plugin System...');
|
2019-09-22 10:02:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bukkitload() {
|
2020-02-27 09:59:06 +00:00
|
|
|
this.logger.log('Plugin Load When ServerType is Bukkit!')
|
2019-09-22 10:02:59 +00:00
|
|
|
}
|
|
|
|
bukkitenable() {
|
2020-02-27 09:59:06 +00:00
|
|
|
this.logger.log('Plugin Enable When ServerType is Bukkit!')
|
2019-09-22 10:02:59 +00:00
|
|
|
}
|
|
|
|
bukkitdisable() {
|
2020-02-27 09:59:06 +00:00
|
|
|
this.logger.log('Plugin Disable When ServerType is Bukkit!')
|
2019-09-22 10:02:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
spongeload() {
|
2020-02-27 09:59:06 +00:00
|
|
|
this.logger.log('Plugin Load When ServerType is Sponge!')
|
2019-09-22 10:02:59 +00:00
|
|
|
}
|
|
|
|
spongeenable() {
|
2020-02-27 09:59:06 +00:00
|
|
|
this.logger.log('Plugin Enable When ServerType is Sponge!')
|
2019-09-22 10:02:59 +00:00
|
|
|
}
|
|
|
|
spongedisable() {
|
2020-02-27 09:59:06 +00:00
|
|
|
this.logger.log('Plugin Disable When ServerType is Sponge!')
|
2019-09-22 10:02:59 +00:00
|
|
|
}
|
|
|
|
|
2020-01-16 09:27:24 +00:00
|
|
|
bungeeload() {
|
2020-02-27 09:59:06 +00:00
|
|
|
this.logger.log('Plugin Load When ServerType is BungeeCord!')
|
2020-01-16 09:27:24 +00:00
|
|
|
}
|
|
|
|
bungeeenable() {
|
2020-02-27 09:59:06 +00:00
|
|
|
this.logger.log('Plugin Enable When ServerType is BungeeCord!')
|
2020-01-16 09:27:24 +00:00
|
|
|
}
|
|
|
|
bungeedisable() {
|
2020-02-27 09:59:06 +00:00
|
|
|
this.logger.log('Plugin Disable When ServerType is BungeeCord!')
|
|
|
|
}
|
|
|
|
|
|
|
|
nukkitload() {
|
|
|
|
this.logger.log('Plugin Load When ServerType is Nukkit!')
|
|
|
|
}
|
|
|
|
nukkitenable() {
|
|
|
|
this.logger.log('Plugin Enable When ServerType is Nukkit!')
|
|
|
|
}
|
|
|
|
nukkitdisable() {
|
|
|
|
this.logger.log('Plugin Disable When ServerType is Nukkit!')
|
2020-01-16 09:27:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-22 10:02:59 +00:00
|
|
|
@cmd()
|
|
|
|
hello(sender: any, command: string, args: string[]) {
|
|
|
|
this.logger.log(sender, command, args);
|
|
|
|
sender.sendMessage(JSON.stringify({ command, ...args }))
|
|
|
|
}
|
|
|
|
|
|
|
|
@tab()
|
|
|
|
tabhello(_sender: any, _command: string, _args: string[]) {
|
|
|
|
return ['world']
|
|
|
|
}
|
|
|
|
|
2020-02-23 20:02:29 +00:00
|
|
|
@listener({ servers: ['bukkit', 'nukkit'] })
|
2020-01-17 09:43:45 +00:00
|
|
|
PlayerJoin(event: org.bukkit.event.player.PlayerJoinEvent) {
|
2020-01-16 09:27:24 +00:00
|
|
|
let plyaer = event.getPlayer();
|
|
|
|
this.logger.console(`§cBukkit §aPlayerJoinEvent: §b${plyaer.getName()}`)
|
2020-02-15 11:40:25 +00:00
|
|
|
setTimeout(() => this.sendWelcome(plyaer), 10);
|
2019-09-22 10:02:59 +00:00
|
|
|
}
|
|
|
|
|
2020-01-17 09:43:45 +00:00
|
|
|
@listener({ servers: ['sponge'] })
|
|
|
|
ClientConnectionEvent$Join(event: org.spongepowered.api.event.network.ClientConnectionEvent.Join) {
|
2020-01-16 09:27:24 +00:00
|
|
|
this.logger.console(`§cSponge §aClientConnectionEvent.Join: §b${event.getTargetEntity().getName()}`)
|
2020-02-15 11:40:25 +00:00
|
|
|
setTimeout(() => this.sendWelcome(event.getTargetEntity()), 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
private sendWelcome(player: any) {
|
|
|
|
this.logger.sender(player, `§a欢迎来到 §bMiaoScript §a的世界!`)
|
|
|
|
this.logger.sender(player, `§6当前版本: §c${this.Server.getVersion()}`)
|
2020-01-16 09:27:24 +00:00
|
|
|
}
|
|
|
|
|
2020-01-17 09:43:45 +00:00
|
|
|
@listener({ servers: ['bungee'] })
|
|
|
|
ServerConnected(e: any) {
|
2020-01-16 09:27:24 +00:00
|
|
|
let event = e as net.md_5.bungee.api.event.ServerConnectedEvent
|
|
|
|
this.logger.console(`§cBungeeCord §aServerConnectedEvent: §b${event.getPlayer().getDisplayName()}`)
|
|
|
|
setTimeout(() => this.logger.sender(event.getPlayer(), `§a欢迎来到 §bMiaoScript §a的世界 §6来自 §cBungeeCord §6的问候!`), 10);
|
2019-09-22 10:02:59 +00:00
|
|
|
}
|
|
|
|
}
|