Skip to content

Commit e9c9002

Browse files
committed
Adds check to see if mod already executed
1 parent 9d683bb commit e9c9002

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/net/comcraft/src/ModLoader.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import javax.microedition.io.file.FileConnection;
1212

1313
import com.google.minijoe.sys.JsFunction;
14+
import com.google.minijoe.sys.JsSystem;
1415
import com.java4ever.apime.io.GZIP;
1516

1617
import net.comcraft.client.Comcraft;
@@ -168,7 +169,13 @@ private void ReadModFile(DataInputStream dis, Mod mod) throws IOException {
168169
public boolean executeModInNs(String package_, String fname) throws Exception {
169170
Hashtable pkg;
170171
if (packages.containsKey(package_) && (pkg = (Hashtable) packages.get(package_)).containsKey(fname)) {
171-
JsFunction.exec(new DataInputStream(new ByteArrayInputStream((byte[]) pkg.get(fname))), ModAPI.getInstance());
172+
if (pkg.get(fname) != JsSystem.JS_NULL) {
173+
// Once executed, the namespace contains the resulting stack.
174+
// Therefore only execute if we haven't already.
175+
// Use of JsSystem.JS_NULL because hashtables can't contain null.
176+
JsFunction.exec(new DataInputStream(new ByteArrayInputStream((byte[]) pkg.get(fname))), ModAPI.getInstance());
177+
pkg.put(fname, JsSystem.JS_NULL);
178+
}
172179
return true;
173180
}
174181
return false;

0 commit comments

Comments
 (0)