Make all reactor script invocations thread safe

Might be a bit overkill to force synchronization
for every single method invocation when the only
scheduling done in reactor scripts are:
- 5511000 (summon Targa)
- 5511001 (summon Scarlion)
This commit is contained in:
P0nk
2021-05-20 21:30:46 +02:00
parent 2ce6041ef8
commit cdfb7074ec
2 changed files with 25 additions and 16 deletions

View File

@@ -13,10 +13,14 @@ import javax.script.ScriptException;
public class SynchronizedInvocable implements Invocable {
private final Invocable invocable;
public SynchronizedInvocable(Invocable invocable) {
private SynchronizedInvocable(Invocable invocable) {
this.invocable = invocable;
}
public static Invocable of(Invocable invocable) {
return new SynchronizedInvocable(invocable);
}
@Override
public synchronized Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException {
return invocable.invokeMethod(thiz, name, args);