Fix restoring schematics for the latest WorldEdit dev builds

- Fixes #447
- Thanks pmme and x1p for reporting the issue!
This commit is contained in:
Thijs Wiefferink 2018-10-28 17:58:09 +01:00
parent a6863ae782
commit 93fd4e96cb
1 changed files with 20 additions and 1 deletions

View File

@ -36,6 +36,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
public class WorldEditHandler7 extends WorldEditInterface {
@ -147,7 +150,23 @@ public class WorldEditHandler7 extends WorldEditInterface {
pluginInterface.debugI(ExceptionUtils.getStackTrace(e));
return false;
}
editSession.flushQueue();
// flushQueue is for worldedit-bukkit-7.0.0-beta-01, later versions have renamed it to flushSession
boolean done = false;
for (String methodName : Arrays.asList("flushSession", "flushQueue")) {
try {
Method method = editSession.getClass().getMethod(methodName);
method.invoke(editSession);
done = true;
} catch (SecurityException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
// Try the next methodName
}
}
if(!done) {
pluginInterface.getLogger().warning("Could not restore schematic of " + regionInterface.getName() + ", flushSession() failed");
}
return true;
}