From 34919ec96198ba310535d590557f8717d02ac4ea Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Tue, 9 Mar 2021 20:36:05 +0100 Subject: [PATCH] Cleanup and prevent crash error --- .../volmit/iris/manager/ProjectManager.java | 9 +++++---- .../com/volmit/iris/manager/WandManager.java | 2 +- .../iris/scaffold/stream/ProceduralStream.java | 9 ++++++++- .../stream/interpolation/Interpolated.java | 18 +++++++++--------- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/volmit/iris/manager/ProjectManager.java b/src/main/java/com/volmit/iris/manager/ProjectManager.java index 501135114..43102fdfe 100644 --- a/src/main/java/com/volmit/iris/manager/ProjectManager.java +++ b/src/main/java/com/volmit/iris/manager/ProjectManager.java @@ -16,6 +16,7 @@ import org.zeroturnaround.zip.commons.FileUtils; import java.io.File; import java.io.FileFilter; import java.io.IOException; +import java.util.Objects; import java.util.UUID; @Data @@ -308,16 +309,16 @@ public class ProjectManager return cacheListing; } - JSONArray a = new JSONArray(); + JSONArray a; if(cached) { - a = new JSONArray(Iris.getCached("cachedlisting", LISTING)); + a = new JSONArray(Objects.requireNonNull(Iris.getCached("cachedlisting", LISTING))); } else { - a = new JSONArray(Iris.getNonCached(!cached + "listing", LISTING)); + a = new JSONArray(Iris.getNonCached(true + "listing", LISTING)); } KMap l = new KMap<>(); @@ -331,7 +332,7 @@ public class ProjectManager l.put(v[0], v[1]); } - catch(Throwable e) + catch(Throwable ignored) { } diff --git a/src/main/java/com/volmit/iris/manager/WandManager.java b/src/main/java/com/volmit/iris/manager/WandManager.java index 1b60eee1f..a5c8d2f81 100644 --- a/src/main/java/com/volmit/iris/manager/WandManager.java +++ b/src/main/java/com/volmit/iris/manager/WandManager.java @@ -150,7 +150,7 @@ public class WandManager implements Listener { try { - if(e.getHand().equals(EquipmentSlot.HAND) && isWand(e.getPlayer().getInventory().getItemInMainHand())) + if(Objects.equals(e.getHand(), EquipmentSlot.HAND) && isWand(e.getPlayer().getInventory().getItemInMainHand())) { if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)) { diff --git a/src/main/java/com/volmit/iris/scaffold/stream/ProceduralStream.java b/src/main/java/com/volmit/iris/scaffold/stream/ProceduralStream.java index 5172a977e..d65fad7fe 100644 --- a/src/main/java/com/volmit/iris/scaffold/stream/ProceduralStream.java +++ b/src/main/java/com/volmit/iris/scaffold/stream/ProceduralStream.java @@ -1,5 +1,6 @@ package com.volmit.iris.scaffold.stream; +import com.volmit.iris.Iris; import com.volmit.iris.scaffold.hunk.Hunk; import com.volmit.iris.scaffold.stream.arithmetic.*; import com.volmit.iris.scaffold.stream.convert.*; @@ -15,7 +16,13 @@ public interface ProceduralStream extends ProceduralLayer, Interpolated { public static ProceduralStream ofDouble(Function2 f) { - return of(f, Interpolated.DOUBLE); + try { + return of(f, Interpolated.DOUBLE); + } catch (IncompatibleClassChangeError e){ + Iris.warn(f.toString()); + e.printStackTrace(); + return null; + } } public static ProceduralStream ofDouble(Function3 f) diff --git a/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolated.java b/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolated.java index 15dbd1ffa..a24bf2c0c 100644 --- a/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolated.java +++ b/src/main/java/com/volmit/iris/scaffold/stream/interpolation/Interpolated.java @@ -10,16 +10,16 @@ import java.util.function.Function; public interface Interpolated { - public static final Interpolated BLOCK_DATA = of((t) -> 0D, (t) -> null); - public static final Interpolated> CAVE_RESULTS = of((t) -> 0D, (t) -> null); - public static final Interpolated RNG = of((t) -> 0D, (t) -> null); - public static final Interpolated DOUBLE = of((t) -> t, (t) -> t); - public static final Interpolated INT = of(Double::valueOf, Double::intValue); - public static final Interpolated LONG = of(Double::valueOf, Double::longValue); + Interpolated BLOCK_DATA = of((t) -> 0D, (t) -> null); + Interpolated> CAVE_RESULTS = of((t) -> 0D, (t) -> null); + Interpolated RNG = of((t) -> 0D, (t) -> null); + Interpolated DOUBLE = of((t) -> t, (t) -> t); + Interpolated INT = of(Double::valueOf, Double::intValue); + Interpolated LONG = of(Double::valueOf, Double::longValue); - public double toDouble(T t); + double toDouble(T t); - public T fromDouble(double d); + T fromDouble(double d); default InterpolatorFactory interpolate() { @@ -31,7 +31,7 @@ public interface Interpolated return null; } - public static Interpolated of(Function a, Function b) + static Interpolated of(Function a, Function b) { return new Interpolated() {