Well since it is was change or removed or whatever; what do I change it to now?
my scriptmanager class goes as follow:
Code:
package org.rs2server.rs2;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import com.sun.script.javascript.RhinoScriptEngine;
/**
* Manages server scripts.
* @author blakeman8192
*
*/
public class ScriptManager {
/**
* The singleton of this class.
*/
private static final ScriptManager INSTANCE = new ScriptManager();
/**
* Gets the ScriptManager singleton.
* @return The ScriptManager singleton.
*/
public static ScriptManager getScriptManager() {
return INSTANCE;
}
/**
* The ScriptEngineManager.
*/
@SuppressWarnings("unused")
private ScriptEngineManager mgr;
/**
* The JavaScript Engine.
*/
private ScriptEngine jsEngine;
/**
* The logger for this manager.
*/
private final Logger logger = Logger.getLogger(this.toString());
/**
* Creates the script manager.
*/
private ScriptManager() {
mgr = new ScriptEngineManager();
jsEngine = new RhinoScriptEngine();
logger.info("Loading scripts...");
}
/**
* Invokes a JavaScript function.
* @param identifier The identifier of the function.
* @param args The function arguments.
* @return if the script was found
*/
public boolean invokeWithFailTest(String identifier, Object... args) {
Invocable invEngine = (Invocable) jsEngine;
try {
invEngine.invokeFunction(identifier, args);
return true;
} catch (NoSuchMethodException ex) {
return false;
} catch (ScriptException ex) {
logger.log(Level.WARNING, "ScriptException thrown!", ex);
return false;
}
}
/**
* Invokes a JavaScript function.
* @param identifier The identifier of the function.
* @param args The function arguments.
*/
public void invoke(String identifier, Object... args) {
Invocable invEngine = (Invocable) jsEngine;
try {
invEngine.invokeFunction(identifier, args);
} catch (NoSuchMethodException ex) {
logger.log(Level.WARNING, "No such method: " + identifier, ex);
} catch (ScriptException ex) {
logger.log(Level.WARNING, "ScriptException thrown!", ex);
}
}
/**
* Loads JavaScript files into the JavaScript ScriptEngine from the argued
* path.
* @param dirPath The path of the directory to load the JavaScript source files
* from.
*/
public void loadScripts(String dirPath) {
File dir = new File(dirPath);
if (dir.exists() && dir.isDirectory()) {
File[] children = dir.listFiles();
for (File child : children) {
if (child.isFile() && child.getName().endsWith(".js"))
try {
jsEngine.eval(new InputStreamReader(
new FileInputStream(child)));
} catch (ScriptException ex) {
logger.log(Level.SEVERE, "Unable to load script!", ex);
} catch (FileNotFoundException ex) {
logger.log(Level.SEVERE, "Unable to find script!", ex);
}
else if (child.isDirectory())
loadScripts(child.getPath());
}
}
}
}
what's highlighted in red are where the errors are, i have no idea what to do so just a little guidance would be great ;D