2019-09-22 15:31:52 +00:00
|
|
|
import { plugin as pluginApi } from '@ms/api'
|
|
|
|
import { plugin, interfaces, cmd, listener, tab } from '@ms/plugin'
|
2019-09-24 02:12:57 +00:00
|
|
|
import { inject } from '@ms/container';
|
2019-09-10 09:22:56 +00:00
|
|
|
|
2020-01-16 09:27:24 +00:00
|
|
|
import * as reflect from '@ms/common/dist/reflect';
|
|
|
|
import http from '@ms/common/dist/http';
|
|
|
|
|
2019-09-22 15:31:52 +00:00
|
|
|
@plugin({ name: 'Test', version: '1.0.0', author: 'MiaoWoo', source: __filename })
|
2019-09-10 09:22:56 +00:00
|
|
|
export class Test extends interfaces.Plugin {
|
2019-09-22 15:31:52 +00:00
|
|
|
@inject(pluginApi.PluginManager)
|
|
|
|
private PluginManager: pluginApi.PluginManager;
|
|
|
|
|
2019-09-10 09:22:56 +00:00
|
|
|
load() {
|
2019-09-22 15:31:52 +00:00
|
|
|
this.logger.log('Test Plugin load from MiaoScript Plugin System...');
|
2019-09-10 09:22:56 +00:00
|
|
|
}
|
2019-09-22 15:31:52 +00:00
|
|
|
|
2019-09-10 09:22:56 +00:00
|
|
|
enable() {
|
2019-09-22 15:31:52 +00:00
|
|
|
this.logger.log('Test Plugin enable from MiaoScript Plugin System...');
|
2019-09-10 09:22:56 +00:00
|
|
|
}
|
2019-09-22 15:31:52 +00:00
|
|
|
|
2019-09-10 09:22:56 +00:00
|
|
|
disable() {
|
2019-09-22 15:31:52 +00:00
|
|
|
this.logger.log('Test Plugin disable from MiaoScript Plugin System...');
|
|
|
|
}
|
|
|
|
|
|
|
|
@cmd()
|
|
|
|
test(sender: any, command: string, args: string[]) {
|
|
|
|
switch (args[0]) {
|
|
|
|
case "run":
|
|
|
|
var script = args.slice(1).join(' ');
|
|
|
|
console.sender(sender, '§b运行脚本:§r', script);
|
|
|
|
console.sender(sender, '§a返回结果:§r', eval(script) || '§4没有返回结果!');
|
|
|
|
break;
|
|
|
|
case "reload":
|
|
|
|
this.PluginManager.reload(this);
|
|
|
|
break;
|
|
|
|
case "yaml":
|
|
|
|
let yaml = require("js-yaml");
|
|
|
|
this.logger.log(yaml.safeDump({ key: 'value', map: { k1: 1, k2: '2' } }));
|
|
|
|
break;
|
|
|
|
case "speed":
|
|
|
|
this.logger.sender(sender, sender.location);
|
|
|
|
break;
|
|
|
|
case "top":
|
|
|
|
let loc = sender.location;
|
|
|
|
let topY = loc.world.getHighestBlockYAt(loc);
|
|
|
|
loc.y = topY;
|
|
|
|
sender.teleport(loc);
|
|
|
|
break;
|
|
|
|
case "up":
|
|
|
|
if (!sender.openInventory) { return; }
|
2019-09-24 02:12:57 +00:00
|
|
|
let player = sender;
|
|
|
|
let location = player.location;
|
2019-09-22 15:31:52 +00:00
|
|
|
player.velocity = player.velocity.setY(0.5);
|
|
|
|
setTimeout(() => location.block.type = Java.type('org.bukkit.Material').STONE, 8);
|
|
|
|
break;
|
2019-09-24 02:12:57 +00:00
|
|
|
case "add":
|
2020-01-16 09:27:24 +00:00
|
|
|
break;
|
|
|
|
case "get":
|
|
|
|
let result = http.get('https://www.baidu.com');
|
|
|
|
this.logger.sender(sender, JSON.stringify(result));
|
|
|
|
// 好了 扯结束 继续咸鱼
|
|
|
|
break;
|
|
|
|
case "ws":
|
|
|
|
let Sponge = Java.type('org.spongepowered.api.Sponge');
|
|
|
|
// let promise = reflect.on(Bukkit.server).get('console').get('field_147144_o').get('field_151274_e').get().get(0);
|
|
|
|
console.log(reflect.on(Sponge.server).get('field_147144_o').get())
|
|
|
|
// let channel = reflect.on(promise).get('channel').get().pipeline().first();
|
|
|
|
// console.log(channel);
|
2019-09-24 02:12:57 +00:00
|
|
|
break;
|
2019-09-22 15:31:52 +00:00
|
|
|
default:
|
|
|
|
this.logger.log(sender, command, args);
|
|
|
|
sender.sendMessage(JSON.stringify({ command, ...args }))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@tab()
|
|
|
|
tabtest(_sender: any, _command: string, _args: string[]) {
|
|
|
|
return ['run', 'reload', 'channel', 'add', 'yaml', 'speed', 'top', 'up']
|
|
|
|
}
|
|
|
|
|
2020-01-17 09:43:45 +00:00
|
|
|
@listener({ servers: ['bukkit'] })
|
2019-09-22 15:31:52 +00:00
|
|
|
playerjoin(event: any) {
|
|
|
|
this.logger.console('PlayerJoinEvent: ', event.player.name)
|
2019-09-10 09:22:56 +00:00
|
|
|
}
|
|
|
|
}
|