Properly rethrow an NPE so it doesn't get stuck in labda

This commit is contained in:
CocoTheOwner 2021-02-28 18:09:45 +01:00
parent 6a4a25db40
commit 1edafc40d0

View File

@ -86,6 +86,9 @@ public class IrisEngineCompound implements EngineCompound {
CompletableFuture<Object> cf = new CompletableFuture<>(); CompletableFuture<Object> cf = new CompletableFuture<>();
Object BP = null; Object BP = null;
getBPSafe(clazz, clazzSG, clazzBP, nmsWorld, chunkGenerator).thenAccept(bp -> { getBPSafe(clazz, clazzSG, clazzBP, nmsWorld, chunkGenerator).thenAccept(bp -> {
if (bp == null){
throw new NullPointerException();
}
strongholds.add(new IrisPosition((int) new V(bp, false).invoke("getX"), (int) new V(bp, false).invoke("getY"), (int) new V(bp, false).invoke("getZ"))); strongholds.add(new IrisPosition((int) new V(bp, false).invoke("getX"), (int) new V(bp, false).invoke("getY"), (int) new V(bp, false).invoke("getZ")));
String positions = ""; String positions = "";
for (IrisPosition pos : strongholds){ for (IrisPosition pos : strongholds){
@ -192,7 +195,7 @@ public class IrisEngineCompound implements EngineCompound {
Bukkit.getScheduler().runTask(Iris.instance, () -> { Bukkit.getScheduler().runTask(Iris.instance, () -> {
try { try {
cf.complete(getBP(clazz, clazzSG, clazzBP, nmsWorld, chunkGenerator)); cf.complete(getBP(clazz, clazzSG, clazzBP, nmsWorld, chunkGenerator));
} catch (Exception e){ } catch (Throwable e){
cf.complete(null); cf.complete(null);
} }
}); });