From 1eb472b576dea4ef72e7f2ff3c912447a37c1d4a Mon Sep 17 00:00:00 2001 From: Ruakij Date: Tue, 11 May 2021 09:52:22 +0200 Subject: [PATCH] Added check when no safe-location could be found --- .../listener/OnCustomPlayerMove.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCustomPlayerMove.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCustomPlayerMove.java index d5b537c..e201a9f 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCustomPlayerMove.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCustomPlayerMove.java @@ -84,9 +84,6 @@ public class OnCustomPlayerMove implements CustomPlayerMoveEventListener { else{ // TODO: Check if beacon is active - // Set player as ignored on target-LinkedBeaconTeleporter (so he wont trigger the teleport again) - playerBeaconLocation.put(uuid, lbtBlockPartner); - // Get safe-location on top of other beacon Block safeBlock = Function.searchForMaterial( lbtBlockPartner.block().getLocation().add(0, 1, 0), @@ -94,8 +91,16 @@ public class OnCustomPlayerMove implements CustomPlayerMoveEventListener { Material.AIR, Function.transparentMaterials ); + + if(safeBlock == null){ + // No safe location found + return; + } // TODO: Check if there is enough space for a player + // Set player as ignored on target-LinkedBeaconTeleporter (so he wont trigger the teleport again) + playerBeaconLocation.put(uuid, lbtBlockPartner); + // Teleport e.player().teleport( safeBlock.getLocation().add(0.5, 0, 0.5)