diff --git a/pom.xml b/pom.xml
index ae325a3..8a19d49 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
pw.yumc
MiaoScript
- 1.3.5
+ 0.0.1
502647092
@@ -33,6 +33,8 @@
org.kamranzafar:jtar
+ com.squareup.okhttp3:okhttp
+ com.squareup.okio:okio
@@ -54,10 +56,11 @@
DEV
- §619-08-31 §afeat: 新增 tar 类库 支持 tar.gz 解压;
- §619-08-29 §erefactor: 移动插件文件 默认自带MSPM插件 优化bios
+ §619-09-21 §afeat: 新增 okhttp3 类库;
+ §619-08-31 §afeat: 新增 tar 类库 支持 tar.gz 解压
+ §619-08-29 §erefactor: 移动插件文件 默认自带MSPM插件 优化bios;
§618-5-20 §afeat: 新增MiaoBoard插件;
§618-5-20 §afeat: 新增MiaoAuth插件;
§618-5-20 §afeat: 修改初始化函数名称;
@@ -162,6 +165,11 @@
jtar
2.3
+
+ com.squareup.okhttp3
+ okhttp
+ 4.1.1
+
org.spigotmc
spigot-api
diff --git a/src/main/resources/bios.js b/src/main/resources/bios.js
index 3b8cadb..b87bab0 100644
--- a/src/main/resources/bios.js
+++ b/src/main/resources/bios.js
@@ -2,10 +2,9 @@
var log;
var boot;
var engineDisable;
-// noinspection ThisExpressionReferencesGlobalObjectJS
var global = this;
/**
- * Init Engine Env
+ * Init MiaoScriptEngine Runtime
*/
(function() {
var loader;
@@ -53,7 +52,7 @@ var global = this;
jarPath = "/" + jarPath;
}
var jar = new java.util.jar.JarFile(jarPath);
- var r = new RegExp(regex);// "[core|modules]/.*"
+ var r = new RegExp(regex);
jar.stream().forEach(function(entry) {
try {
if (!entry.isDirectory()) {
diff --git a/src/main/resources/core/ployfill.js b/src/main/resources/core/ployfill.js
index e4a32c2..0684b8a 100644
--- a/src/main/resources/core/ployfill.js
+++ b/src/main/resources/core/ployfill.js
@@ -11,11 +11,11 @@
// Init console and require
global.console = engineLoad(global.root + '/core/console.js')(logger);
global.require = engineLoad(global.root + '/core/require.js')(root);
- // String contains playfill
+ // String contains ployfill
String.prototype.contains = function(searchString, position) {
return String.prototype.indexOf.call(this, searchString, position) > -1;
};
- // ES6 Map Symbol playfill
+ // ES6 Map Symbol ployfill
require('es6-map/implement');
require('es6-symbol/implement');
});
diff --git a/src/main/resources/plugins/MiaoScriptPackageManager.js b/src/main/resources/plugins/MiaoScriptPackageManager.js
deleted file mode 100644
index 4cf0835..0000000
--- a/src/main/resources/plugins/MiaoScriptPackageManager.js
+++ /dev/null
@@ -1,212 +0,0 @@
-'use strict';
-/*global Java, base, module, exports, require, __dirname, __filename, ScriptEngineContextHolder*/
-var task = require('api/task');
-var manager = require('api/plugin');
-var command = require('api/command');
-
-var fs = require('fs');
-var http = require('http');
-var template = require('template');
-
-var pluginCache = [];
-var packageCache = [];
-var packageNameCache = [];
-
-var description = {
- name: 'MiaoScriptPackageManager',
- prefix: 'PM',
- version: '1.0',
- author: 'MiaoWoo',
- description: 'MiaoScript包管理工具',
- commands: {
- 'mpm': {
- description: 'MiaoScriptPackageManager主命令'
- }
- },
- config: {
- center: 'https://ms.yumc.pw/api/package/list',
- template: 'http://paste.yumc.pw/pxus6ap6l/g7di8z/raw'
- }
-};
-
-var help = [
- '§6========= §6[§a' + description.name + '§6] 帮助 §aBy §b喵♂呜 §6=========',
- '§6/mpm §ainstall §e<插件名称> §6- §3安装插件',
- '§6/mpm §alist [install]§6- §3列出仓库插件[已安装的插件]',
- '§6/mpm §aupdate §e<插件名称> §6- §3更新插件(无插件名称则更新源)',
- '§6/mpm §aupgrade §e<插件名称> §6- §3及时更新插件(update需要重启生效)',
- '§6/mpm §areload §e<插件名称> §6- §3重载插件(无插件名称则重载自身)',
- '§6/mpm §arun §e §6- §3运行JS代码',
- '§6/mpm §acreate §e<插件名称> [作者] [版本] [主命令] §6- §3通过模板创建名称',
- '§6/mpm §crestart §6- §4重启MiaoScript脚本引擎'
-];
-
-function load() {
- task.async(function() {
- pluginCache = Object.keys(manager.plugins);
- JSON.parse(http.get(self.config.center)).data.forEach(function cachePackageName(pkg) {
- packageCache[pkg.name] = pkg;
- })
- packageNameCache = Object.keys(packageCache);
- })
-}
-
-function enable() {
- command.on(this, 'mpm', {
- cmd: function(sender, command, args) {
- task.async(function asyncCommand() {
- main(sender, command, args);
- });
- },
- tab: function(sender, command, args) {
- if (args.length === 1) return ['list', 'install', 'update', 'upgrade', 'reload', 'restart', 'run', 'help', 'create'];
- if (args.length > 1) {
- switch (args[0]) {
- case "install":
- return packageNameCache;
- case "update":
- case "upgrade":
- case "reload":
- return pluginCache;
- }
- }
- }
- })
-}
-
-function main(sender, command, args) {
- if (!args[0] || args[1] === 'help') {
- console.sender(sender, help);
- return;
- }
- switch (args[0]) {
- case "list":
- if (args[1]) {
- console.sender(sender, '§6当前 §bMiaoScript §6已安装下列插件:');
- pluginCache.forEach(function listInfo(pluginName) {
- var desc = manager.plugins[pluginName].description;
- console.sender(sender, '§6插件名称: §b%s §6版本: §a%s §6作者: §3%s'.format(desc.name, desc.version || '1.0', desc.author || '未知'))
- })
- } else {
- console.sender(sender, '§6当前 §bMiaoScriptPackageCenter §6中存在下列插件:');
- for (var pkgName in packageCache) {
- var pkg = packageCache[pkgName];
- console.sender(sender, '§6插件名称: §b%s §6版本: §a%s §6作者: §3%s'.format(pkg.name, pkg.version || '1.0', pkg.author || '未知'))
- }
- }
- break;
- case "install":
- if (args.length > 1) {
- download(sender, args[1]);
- } else {
- console.sender(sender, '§c请输入插件名称!')
- }
- break;
- case "update":
- if (args.length > 1) {
- update(sender, args[1]);
- } else {
- load();
- console.sender(sender, "§a仓库缓存刷新成功 共存在 §b" + Object.keys(packageCache).length + " §a个插件!")
- }
- break;
- case "upgrade":
- break;
- case "delete":
- if (args.length > 1) {
- del(sender, args[1]);
- } else {
- console.sender(sender, '§c请输入插件名称!')
- }
- break;
- case "reload":
- if (args.length > 1) {
- var pname = args[1];
- if (pluginCache.indexOf(pname) !== -1) {
- manager.reload(pname)
- console.sender(sender, '§6插件 §b%s §a重载完成!'.format(pname))
- } else {
- console.sender(sender, '§c插件 §b%s §c不存在!'.format(pname))
- }
- } else {
- self.reloadConfig();
- load();
- }
- break;
- case "restart":
- try {
- console.sender(sender, '§6Reloading §3MiaoScript Engine...');
- ScriptEngineContextHolder.disableEngine();
- ScriptEngineContextHolder.enableEngine();
- console.sender(sender, '§3MiaoScript Engine §6Reload §aSuccessful...');
- } catch (ex) {
- console.sender(sender, "§3MiaoScript Engine §6Reload §cError! ERR: " + ex);
- console.sender(sender, console.stack(ex));
- }
- break;
- case "run":
- args.shift(1);
- try {
- var script = args.join(' ')
- console.sender(sender, '§b运行脚本:§r', script)
- console.sender(sender, '§a返回结果:§r', eval(script) || '§4没有返回结果!');
- } catch (ex) {
- console.sender(sender, console.stack(ex))
- }
- break;
- case "create":
- var name = args[1];
- if (!name) {
- console.sender(sender, '§4参数错误 /mpm create <插件名称> [作者] [版本] [主命令]');
- return;
- }
- var result = template.create(http.get(self.config.template)).render({
- name: name,
- author: args[2] || 'MiaoWoo',
- version: args[3] || '1.0',
- command: args[4] || name.toLowerCase(),
- });
- fs.save(fs.file(__dirname, name + '.js'), result);
- console.sender(sender, '§6插件 §a' + name + ' §6已生成到插件目录...');
- break;
- default:
- console.sender(sender, help);
- break;
- }
-}
-
-function del(sender, name) {
- if (pluginCache.indexOf(name) !== -1) {
- console.sender(sender, '§c插件 %s 不存在!'.format(name));
- return;
- }
- manager.disable(name);
- fs.delete(plugin.__FILE__);
- console.sender(sender, '§c插件 §b%s §c删除成功!'.format(name));
-}
-
-function download(sender, name) {
- var plugin = packageCache[name];
- if (!plugin) {
- console.sender(sender, '§c插件 §b%s §c不存在!'.format(name));
- return;
- }
- var pfile = fs.file(__dirname, name + '.js');
- console.sender(sender, '§6开始下载插件: §b%s'.format(plugin.name));
- console.sender(sender, '§6插件下载地址: §b%s'.format(plugin.url));
- fs.save(pfile, http.get(plugin.url));
- console.sender(sender, '§6插件 §b%s §a下载完毕 开始加载 ...'.format(name));
- manager.loadPlugin(pfile);
- console.sender(sender, '§6插件 §b%s §a安装成功!'.format(name));
-}
-
-function disable() {
-
-}
-
-module.exports = {
- description: description,
- load: load,
- enable: enable,
- disable: disable
-};