From 34c2da55ca046b89a1a1854f6d755165798e7d7a Mon Sep 17 00:00:00 2001 From: MattBDev Date: Mon, 25 Jul 2016 18:43:11 -0400 Subject: [PATCH] Change Sponge method behavior --- .../java/com/plotsquared/sponge/object/SpongePlayer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java b/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java index 8bc5fd9e4..840d3f5ad 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java @@ -1,6 +1,7 @@ package com.plotsquared.sponge.object; import com.flowpowered.math.vector.Vector3d; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.commands.RequiredType; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -111,8 +112,12 @@ public class SpongePlayer extends PlotPlayer { @Override public void setCompassTarget(Location location) { - TargetedLocationData target = this.player.getOrCreate(TargetedLocationData.class).get(); - target.set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(location).getPosition()); + Optional target = this.player.getOrCreate(TargetedLocationData.class); + if (target.isPresent()) { + target.get().set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(location).getPosition()); + } else { + PS.debug("Failed to set compass target."); + } } @Override