about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGenny <gen@nyble.dev>2020-06-14 04:19:56 -0500
committerGenny <gen@nyble.dev>2020-06-14 04:19:56 -0500
commitd08bfe8e05c2e44ad41b82b3a77464fe44648efe (patch)
treeb635303febd91482273b5f7c5fff50d7e1ac5a4f
parent52b942fe4306d39ac068f88898825e2f0743aa46 (diff)
downloadsunfright-d08bfe8e05c2e44ad41b82b3a77464fe44648efe.tar.gz
sunfright-d08bfe8e05c2e44ad41b82b3a77464fe44648efe.zip
Fix nullptr exception on ray trace in damager
-rw-r--r--pom.xml2
-rw-r--r--src/main/java/dev/genbyte/sunfright/Damager.java14
2 files changed, 10 insertions, 6 deletions
diff --git a/pom.xml b/pom.xml
index 7c008ae..da0d501 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
   <groupId>dev.genbyte.sunfright</groupId>
   <artifactId>sunfright</artifactId>
   <packaging>jar</packaging>
-  <version>0.6.1</version>
+  <version>0.6.2</version>
 
   <name>sunfright</name>
   <description>Burn me to a crisp, large glowing orb!</description>
diff --git a/src/main/java/dev/genbyte/sunfright/Damager.java b/src/main/java/dev/genbyte/sunfright/Damager.java
index 093dbb6..c3bbe44 100644
--- a/src/main/java/dev/genbyte/sunfright/Damager.java
+++ b/src/main/java/dev/genbyte/sunfright/Damager.java
@@ -78,15 +78,19 @@ public class Damager extends BukkitRunnable {
 		public void run() {
 			Location loc = player.getLocation();
 			World world = loc.getWorld();
-			Block topBlock = player.getWorld().rayTraceBlocks(
+			RayTraceResult rtr = player.getWorld().rayTraceBlocks(
 				loc,
 				new Vector(0, 1, 0),
 				world.getMaxHeight()-loc.getY()
-			).getHitBlock();
+			);
 	
-			if (topBlock.getLocation().getY() > player.getLocation().getY()
-					&& topBlock.getType().equals(Material.BLACK_STAINED_GLASS)) {
-				return;
+			if (rtr != null) {
+				Block topBlock = rtr.getHitBlock();
+				if (topBlock != null && topBlock.getLocation().getY() > player.getLocation().getY()
+					&& topBlock.getType().equals(Material.BLACK_STAINED_GLASS)
+				) {
+					return;
+				}
 			}
 
 			ItemStack helmet = player.getInventory().getHelmet();