Make check an NPE check and failure

This commit is contained in:
tastybento 2021-12-20 15:30:29 -08:00
parent 3ece0d049a
commit 7fbae58bb2
2 changed files with 3 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import world.bentobox.bentobox.util.Util;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
@ -64,8 +65,7 @@ public class SafeSpotTeleport {
this.runnable = builder.getRunnable();
this.failRunnable = builder.getFailRunnable();
this.result = builder.getResult();
this.world = location.getWorld();
assert world != null;
this.world = Objects.requireNonNull(location.getWorld());
this.maxHeight = world.getMaxHeight() - 20;
// Try to go
Util.getChunkAtAsync(location).thenRun(() -> tryToGo(builder.getFailureMessage()));

View File

@ -146,7 +146,7 @@ public class SafeSpotTeleportTest {
/**
* Test method for {@link world.bentobox.bentobox.util.teleport.SafeSpotTeleport#SafeSpotTeleport(world.bentobox.bentobox.util.teleport.SafeSpotTeleport.Builder)}.
*/
@Test(expected = AssertionError.class)
@Test(expected = NullPointerException.class)
public void testSafeSpotTeleportNullWorld() {
when(location.getWorld()).thenReturn(null);
sst = new SafeSpotTeleport(builder);