From 94faaad338f884868f92d3b3e74ae0d1f6d16d09 Mon Sep 17 00:00:00 2001 From: Genny Date: Fri, 21 Feb 2020 01:00:43 -0600 Subject: Implement sunlight filtering with black glass --- README.md | 18 +++++++++--------- pom.xml | 2 +- src/main/java/dev/genbyte/sunfright/Damager.java | 8 ++++++++ src/main/resources/plugin.yml | 1 + 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0e80d07..a7d0f37 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # Sunfright +[todo.sr.ht][tickets] + +[tickets]: https://todo.sr.ht/~genbyte/sunfright + Inspired by the [404 challenge][404], this is a Spigot plugin that restricts your ability to be in sunlight. @@ -26,12 +30,8 @@ from the [Minecraft wiki][mcwiki-helmets], is listed below. [mcwiki-helmets]: https://minecraft.gamepedia.com/Helmet#Durability -### TODO: - -- Black Stained Glass to shield the sun -- Higher levels of Fire Protection give more resistance to the sun (like - unbreaking on the helmet). -- ~~Respawn helmet disappears when no longer exposed to sunlight.~~ DONE! -- Allow custom death messages when players burnt by the sun -- ~~Configure damage taken by sun~~ DONE! -- Option to adjust by difficulty +### Notes +- Black glass can shield you from the sun if it is directly above you. +- Respawn helmets disappear when you are safe. +- You must have at least Fire Protection I on a helmet to stay safe from + sunlight above level 3. diff --git a/pom.xml b/pom.xml index 7e3c1b9..d35225e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ dev.genbyte.sunfright sunfright jar - 0.3.1 + 0.4.0 sunfright Burn me to a crisp, large glowing orb! diff --git a/src/main/java/dev/genbyte/sunfright/Damager.java b/src/main/java/dev/genbyte/sunfright/Damager.java index 42d6133..bfb977f 100644 --- a/src/main/java/dev/genbyte/sunfright/Damager.java +++ b/src/main/java/dev/genbyte/sunfright/Damager.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.logging.Level; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -43,6 +44,13 @@ public class Damager extends BukkitRunnable { public void run() { ItemStack helmet = player.getInventory().getHelmet(); + Block topBlock = player.getWorld().getBlockAt( + player.getWorld().getHighestBlockAt(player.getLocation()).getLocation().subtract(0, 1, 0)); + + if (topBlock.getLocation().getY() > player.getLocation().getY() + && topBlock.getType().equals(Material.BLACK_STAINED_GLASS)) { + return; + } if (helmet != null) { ItemMeta helmetMeta = helmet.getItemMeta(); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 991a8e4..c26f3ca 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,4 +4,5 @@ description: ${description} author: ${author} website: ${url} +api-version: 1.13 main: ${mainClass} \ No newline at end of file -- cgit 1.4.1-3-g733a5