Skip to content

Commit

Permalink
forgot to push on release
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Oct 6, 2020
1 parent 499c1dd commit 0e80a1f
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 60 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation name: "jsmacros-1.16.2-1.2.4-beta-921af6a-dev"
modImplementation name: "jsmacros-1.16.3-1.2.7-beta-21df5de-dev"

//partial fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api-base:${project.api_base_version}"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.8.8+build.202

# Mod Properties
mod_version = 1.0.5
mod_version = 1.0.6
maven_group = xyz.wagyourtail
archives_base_name = jsmacros-jython

Expand Down
13 changes: 7 additions & 6 deletions src/main/java/xyz/wagyourtail/jsmacrosjython/JsMacrosJython.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import org.python.util.PythonInterpreter;

import net.fabricmc.api.ClientModInitializer;
import xyz.wagyourtail.jsmacros.api.sharedinterfaces.IEvent;
import xyz.wagyourtail.jsmacros.config.RawMacro;
import xyz.wagyourtail.jsmacros.extensionbase.Functions;
import xyz.wagyourtail.jsmacros.extensionbase.ILanguage;
import xyz.wagyourtail.jsmacros.runscript.RunScript;
import xyz.wagyourtail.jsmacros.runscript.functions.Functions;
import xyz.wagyourtail.jsmacrosjython.functions.consumerFunctions;
import xyz.wagyourtail.jsmacrosjython.functions.FConsumerJython;

public class JsMacrosJython implements ClientModInitializer {
public static boolean hasJEP = false;
Expand All @@ -25,14 +27,13 @@ public void onInitializeClient() {
}

// register language
RunScript.addLanguage(new RunScript.Language() {
private Functions consumerFix = new consumerFunctions("consumer");
RunScript.addLanguage(new ILanguage() {
private Functions consumerFix = new FConsumerJython("consumer");

@Override
public void exec(RawMacro macro, File file, String event, Map<String, Object> args) throws Exception {
public void exec(RawMacro macro, File file, IEvent event) throws Exception {
try (PythonInterpreter interp = new PythonInterpreter()) {
interp.set("event", event);
interp.set("args", args);
interp.set("file", file);

for (Functions f : RunScript.standardLib) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package xyz.wagyourtail.jsmacrosjython.functions;

import java.util.List;

import org.python.core.PyFunction;

import xyz.wagyourtail.jsmacros.extensionbase.Functions;
import xyz.wagyourtail.jsmacros.extensionbase.IFConsumer;
import xyz.wagyourtail.jsmacros.extensionbase.MethodWrapper;

public class FConsumerJython extends Functions implements IFConsumer<PyFunction, PyFunction, PyFunction> {


public FConsumerJython(String libName) {
super(libName);
}

public FConsumerJython(String libName, List<String> exclude) {
super(libName, exclude);
}


@Override
public MethodWrapper<Object, Object> autoWrap(PyFunction c) {
return new MethodWrapper<Object, Object>() {

private void acceptInt(Object...args) {
Thread t = new Thread(() -> {
c._jcall(args);
});
t.start();
}

@Override
public void accept(Object arg0) {
acceptInt(arg0);

}

@Override
public void accept(Object arg0, Object arg1) {
acceptInt(arg0, arg1);
}
};
}

@Override
public MethodWrapper<Object, Object> autoWrapAsync(PyFunction c) {
return new MethodWrapper<Object, Object>() {

private void acceptInt(Object...args) {
Thread t = new Thread(() -> {
c._jcall(args);
});
t.start();
}

@Override
public void accept(Object arg0) {
acceptInt(arg0);

}

@Override
public void accept(Object arg0, Object arg1) {
acceptInt(arg0, arg1);
}
};
}


@Override
public MethodWrapper<Object, Object> toConsumer(PyFunction c) {
return autoWrap(c);
}

@Override
public MethodWrapper<Object, Object> toBiConsumer(PyFunction c) {
return autoWrap(c);
}

@Override
public MethodWrapper<Object, Object> toAsyncConsumer(PyFunction c) {
return autoWrapAsync(c);
}

@Override
public MethodWrapper<Object, Object> toAsyncBiConsumer(PyFunction c) {
return autoWrapAsync(c);
}

}

This file was deleted.

0 comments on commit 0e80a1f

Please sign in to comment.