From 5ea78a60e5c23912e2315e89cf7024dded6427de Mon Sep 17 00:00:00 2001 From: coding Date: Sat, 19 May 2018 17:12:08 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EMiaoAuth=E6=8F=92?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/plugins/MiaoAuth.js | 71 ++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/main/resources/plugins/MiaoAuth.js diff --git a/src/main/resources/plugins/MiaoAuth.js b/src/main/resources/plugins/MiaoAuth.js new file mode 100644 index 0000000..187284b --- /dev/null +++ b/src/main/resources/plugins/MiaoAuth.js @@ -0,0 +1,71 @@ +'use strict'; +/** + * MiaoAuth简易登录系统 + */ +/*global Java, base, module, exports, require*/ + +var event = require('api/event'); +var wrapper = require('api/wrapper'); +var command = require('api/command'); +var server = require('api/server'); +var fs = require('fs'); + +var description = { + name: 'MiaoAuth', + version: '1.0', + commands: { + 'l': { + description: 'MiaoAuth登录命令' + }, + 'r': { + description: 'MiaoAuth注册命令' + } + } +}; + +function load() { + console.log('载入 MiaoAuth 插件!'); +} + +function enable() { + command.on(this, 'l', { + cmd: function (sender, command, args) { + return true; + } + }); + command.on(this, 'r', { + cmd: function (sender, command, args) { + return true; + } + }); + console.log('启用 MiaoAuth 测试插件!'); + switch (DetectServerType) { + case ServerType.Bukkit: + event.on(this, 'playerloginevent', function join(event) { + send(wrapper.player(event.player)); + }); + break; + case ServerType.Sponge: + event.on(this, 'clientconnectionevent.join', function join(event) { + send(wrapper.player(event.targetEntity)); + }); + break; + } +} + +function send(player) { + setTimeout(function sendMessage() { + player.sendMessage('§a输入 /l <密码> 以登录!'); + }, 1000); +} + +function disable() { + console.log('卸载 MiaoAuth 测试插件!'); +} + +module.exports = { + description: description, + load: load, + enable: enable, + disable: disable +};