about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pom.xml2
-rw-r--r--src/main/java/dev/genbyte/sunfright/Damager.java17
2 files changed, 18 insertions, 1 deletions
diff --git a/pom.xml b/pom.xml
index d0d5811..7c008ae 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.0</version>
+  <version>0.6.1</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 83c57e7..093dbb6 100644
--- a/src/main/java/dev/genbyte/sunfright/Damager.java
+++ b/src/main/java/dev/genbyte/sunfright/Damager.java
@@ -4,14 +4,18 @@ import java.util.Collection;
 import java.util.Random;
 import java.util.logging.Level;
 
+import org.bukkit.Location;
 import org.bukkit.Material;
 import org.bukkit.World;
+import org.bukkit.block.Block;
 import org.bukkit.enchantments.Enchantment;
 import org.bukkit.entity.Player;
 import org.bukkit.inventory.ItemStack;
 import org.bukkit.inventory.meta.Damageable;
 import org.bukkit.inventory.meta.ItemMeta;
 import org.bukkit.scheduler.BukkitRunnable;
+import org.bukkit.util.RayTraceResult;
+import org.bukkit.util.Vector;
 
 public class Damager extends BukkitRunnable {
 	private final Sunfright sf;
@@ -72,6 +76,19 @@ public class Damager extends BukkitRunnable {
 		}
 
 		public void run() {
+			Location loc = player.getLocation();
+			World world = loc.getWorld();
+			Block topBlock = 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;
+			}
+
 			ItemStack helmet = player.getInventory().getHelmet();
 
 			if (helmet != null) {