about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGenny <gen@nyble.dev>2020-06-14 03:41:55 -0500
committerGenny <gen@nyble.dev>2020-06-14 03:41:55 -0500
commit52b942fe4306d39ac068f88898825e2f0743aa46 (patch)
tree0004089249f8c9f4c9d513a8ddace16eeaf278b0
parentbd67ded0284e4a9f65c6938862d289801e7ce04b (diff)
downloadsunfright-52b942fe4306d39ac068f88898825e2f0743aa46.tar.gz
sunfright-52b942fe4306d39ac068f88898825e2f0743aa46.zip
Reimplement black glass safety but correctly
-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) {