Added compiling information, removed dependency on internal Sun components.

Dieser Commit ist enthalten in:
sk89q 2011-01-30 15:10:48 -08:00
Ursprung c37ccb8df4
Commit 9fed59cf63
4 geänderte Dateien mit 38 neuen und 157 gelöschten Zeilen

36
README.md Normale Datei
Datei anzeigen

@ -0,0 +1,36 @@
WorldEdit
=========
WorldEdit is a voxel and block manipulation library for Minecraft. It is
primarily a library but bindings to Bukkit (included) and SPC (external)
are available.
Compiling
---------
Some dependencies are required:
- TrueZip (http://java.net/projects/truezip) provides snapshot reading
- Bukkit (http://bukkit.org/) is a SMP plugin API
- Rhino (http://www.mozilla.org/rhino/) provides a JavaScript engine
- GroupUsers (http://forums.bukkit.org/threads/639/) provides an
permission system for Bukkit
- Permissions (http://forums.bukkit.org/threads/1403/) provides an
permission system for Bukkit
For links to downloads, check out
http://wiki.sk89q.com/wiki/WorldEdit/Development
To compile a .jar, use the Ant build file with the 'jar' target.
ant jar
Contributing
------------
We happily accept contributions. The best way to do this is to fork
WorldEdit on GitHub, add your changes, and then submit a pull request. We'll
look at it, make comments, and merge it into WorldEdit if everything
works out.
Your submissions have to be licensed under the GNU General Public License v3.

Datei anzeigen

@ -860,13 +860,9 @@ public class WorldEdit {
try { try {
engine = new RhinoCraftScriptEngine(); engine = new RhinoCraftScriptEngine();
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError e) {
try { player.printError("Please install a scripting engine.");
engine = new SunRhinoCraftScriptEngine();
} catch (NoClassDefFoundError e2) {
player.printError("Failed to find an installed script engine.");
return; return;
} }
}
engine.setTimeLimit(config.scriptTimeout); engine.setTimeLimit(config.scriptTimeout);

Datei anzeigen

@ -1,61 +0,0 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.scripting;
import sun.org.mozilla.javascript.internal.*;
public class SunRhinoContextFactory extends ContextFactory {
protected int timeLimit;
public SunRhinoContextFactory(int timeLimit) {
this.timeLimit = timeLimit;
}
protected Context makeContext() {
RhinoContext cx = new RhinoContext(this);
cx.setInstructionObserverThreshold(10000);
return cx;
}
protected void observeInstructionCount(Context cx, int instructionCount) {
RhinoContext mcx = (RhinoContext)cx;
long currentTime = System.currentTimeMillis();
if (currentTime - mcx.startTime > timeLimit) {
throw new Error("Script timed out (" + timeLimit + "ms)");
}
}
protected Object doTopCall(Callable callable, Context cx, Scriptable scope,
Scriptable thisObj, Object[] args) {
RhinoContext mcx = (RhinoContext)cx;
mcx.startTime = System.currentTimeMillis();
return super.doTopCall(callable, cx, scope, thisObj, args);
}
private static class RhinoContext extends Context {
long startTime;
public RhinoContext(ContextFactory factory) {
super();
}
}
}

Datei anzeigen

@ -1,90 +0,0 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.scripting;
import java.util.Map;
import javax.script.ScriptException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import sun.org.mozilla.javascript.internal.*;
public class SunRhinoCraftScriptEngine implements CraftScriptEngine {
private int timeLimit;
@Override
public void setTimeLimit(int milliseconds) {
timeLimit = milliseconds;
}
@Override
public int getTimeLimit() {
return timeLimit;
}
@Override
public Object evaluate(final String script, final String filename,
final Map<String, Object> args)
throws ScriptException, Throwable {
SunRhinoContextFactory factory = new SunRhinoContextFactory(timeLimit);
factory.initApplicationClassLoader(WorldEdit.class.getClassLoader());
try {
return factory.call(new ContextAction() {
public Object run(Context cx) {
Scriptable topLevel = new ImporterTopLevel(cx);
Scriptable scope = cx.initStandardObjects();
topLevel.setParentScope(scope);
for (Map.Entry<String, Object> entry : args.entrySet()) {
ScriptableObject.putProperty(scope, entry.getKey(),
Context.javaToJS(entry.getValue(), scope));
}
return cx.evaluateString(topLevel, script, filename, 1, null);
}
});
} catch (Error e) {
throw new ScriptException(e.getMessage());
} catch (RhinoException e) {
if (e instanceof WrappedException) {
Throwable cause = ((WrappedException)e).getCause();
if (cause instanceof WorldEditException) {
throw ((WrappedException)e).getCause();
}
}
String msg;
int line = (line = e.lineNumber()) == 0 ? -1 : line;
if (e instanceof JavaScriptException) {
msg = String.valueOf(((JavaScriptException)e).getValue());
} else {
msg = e.getMessage();
}
ScriptException scriptException =
new ScriptException(msg, e.sourceName(), line);
scriptException.initCause(e);
throw scriptException;
}
}
}