diff options
author | Genny <gen@nyble.dev> | 2020-06-14 03:41:55 -0500 |
---|---|---|
committer | Genny <gen@nyble.dev> | 2020-06-14 03:41:55 -0500 |
commit | 52b942fe4306d39ac068f88898825e2f0743aa46 (patch) | |
tree | 0004089249f8c9f4c9d513a8ddace16eeaf278b0 /src | |
parent | bd67ded0284e4a9f65c6938862d289801e7ce04b (diff) | |
download | sunfright-52b942fe4306d39ac068f88898825e2f0743aa46.tar.gz sunfright-52b942fe4306d39ac068f88898825e2f0743aa46.zip |
Reimplement black glass safety but correctly
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/dev/genbyte/sunfright/Damager.java | 17 |
1 files changed, 17 insertions, 0 deletions
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) { |