diff --git a/src/main/java/com/btk5h/skriptmirror/skript/custom/ExprRawExpression.java b/src/main/java/com/btk5h/skriptmirror/skript/custom/ExprRawExpression.java index a4560de..b55da9d 100644 --- a/src/main/java/com/btk5h/skriptmirror/skript/custom/ExprRawExpression.java +++ b/src/main/java/com/btk5h/skriptmirror/skript/custom/ExprRawExpression.java @@ -8,6 +8,7 @@ import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import com.btk5h.skriptmirror.WrappedEvent; +import com.btk5h.skriptmirror.skript.reflect.ExprJavaCall; import com.btk5h.skriptmirror.util.SkriptUtil; import org.bukkit.event.Event; @@ -56,13 +57,19 @@ public void change(Event event, Object[] delta, Changer.ChangeMode changeMode) { return; Expression source = expr.getSource(); - event = ((WrappedEvent) event).getDirectEvent(); - source.change(event, delta, changeMode); + Event unwrappedEvent = ((WrappedEvent) event).getDirectEvent(); + // Ensure acceptChange has been called before change + try { + source.acceptChange(changeMode); + source.change(unwrappedEvent, delta, changeMode); + } catch (Throwable throwable) { + ExprJavaCall.lastError = throwable; + } } @Override - public String toString(Event e, boolean debug) { - return "raw " + expr.toString(e, debug); + public String toString(Event event, boolean debug) { + return "raw " + expr.toString(event, debug); } @Override diff --git a/src/main/java/com/btk5h/skriptmirror/skript/reflect/ExprJavaCall.java b/src/main/java/com/btk5h/skriptmirror/skript/reflect/ExprJavaCall.java index 6a9d7ee..bf52619 100644 --- a/src/main/java/com/btk5h/skriptmirror/skript/reflect/ExprJavaCall.java +++ b/src/main/java/com/btk5h/skriptmirror/skript/reflect/ExprJavaCall.java @@ -87,7 +87,7 @@ public String toString() { } } - static Throwable lastError; + public static Throwable lastError; private final LRUCache> callSiteCache = new LRUCache<>(8);