Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to fix expr change problems of #122 #123

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public String toString() {
}
}

static Throwable lastError;
public static Throwable lastError;

private final LRUCache<Descriptor, Collection<MethodHandle>> callSiteCache = new LRUCache<>(8);

Expand Down
Loading