Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean simpleCheck(String path) {
- try {
- ScriptEngineManager sem = new ScriptEngineManager();
- ScriptEngine engine = sem.getEngineByName("nashorn");
- File js = new File(path);
- String script = FileUtils.readFileToString(js, StandardCharsets.UTF_8);
- engine.eval(script);
- Invocable iv = (Invocable) engine;
- ScriptEngine scriptengine = (ScriptEngine) iv;
- scriptengine.put("cm", new TestA());
- iv.invokeFunction("start");
- return false;
- } catch (Throwable ex) {
- ex.printStackTrace();
- return ex.getMessage().contains("is not a function");
- }
- }
- public static class TestA {
- private final TestPlayer player = new TestPlayer();
- public TestPlayer getPlayer() {
- return player;
- }
- public void dispose() {
- }
- public int getNumberFromQuestInfo(int i, String s) {
- return 0;
- }
- }
- public static class TestPlayer {
- public String getInfoQuest(int i) {
- return "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment