diff options
author | gennyble <gen@nyble.dev> | 2023-11-08 21:36:31 -0600 |
---|---|---|
committer | gennyble <gen@nyble.dev> | 2023-11-08 21:36:31 -0600 |
commit | 60592fd01111e75335245835e2518f900e8d35d1 (patch) | |
tree | db7ac341d787acedaaa85640654edeb47fc32bbd /src/main/java | |
parent | 5cb15d5b38bac88b66584bdf897457a356e14d38 (diff) | |
download | sunfright-60592fd01111e75335245835e2518f900e8d35d1.tar.gz sunfright-60592fd01111e75335245835e2518f900e8d35d1.zip |
fix
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/dev/nyble/sunfright/Damager.java (renamed from src/main/java/dev/genbyte/sunfright/Damager.java) | 50 | ||||
-rw-r--r-- | src/main/java/dev/nyble/sunfright/Sunfright.java (renamed from src/main/java/dev/genbyte/sunfright/Sunfright.java) | 4 | ||||
-rw-r--r-- | src/main/java/dev/nyble/sunfright/events/HelmetHandler.java (renamed from src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java) | 4 |
3 files changed, 32 insertions, 26 deletions
diff --git a/src/main/java/dev/genbyte/sunfright/Damager.java b/src/main/java/dev/nyble/sunfright/Damager.java index 4ee7615..890bb98 100644 --- a/src/main/java/dev/genbyte/sunfright/Damager.java +++ b/src/main/java/dev/nyble/sunfright/Damager.java @@ -1,4 +1,4 @@ -package dev.genbyte.sunfright; +package dev.nyble.sunfright; import java.util.Collection; import java.util.Random; @@ -37,21 +37,22 @@ public class Damager extends BukkitRunnable { int y = loc.getBlockY(); int z = loc.getBlockZ(); // Returns one lower than it should? - int highestY = sunnedWorld.getHighestBlockAt(loc).getLocation().getBlockY()+1; + int highestY = sunnedWorld.getHighestBlockAt(loc).getLocation().getBlockY() + 1; for (int i = y; i < highestY; ++i) { Block current = sunnedWorld.getBlockAt(x, i, z); if (!blockShouldDamage(current.getType())) { - /* player rulled to be safe. Remove their helmet if it's the one we gave, but - only do so if the skylight is less than three. This will keep us from - removing the starter helmet if they're just chopping down a tree */ + /* + * player rulled to be safe. Remove their helmet if it's the one we gave, but + * only do so if the skylight is less than three. This will keep us from + * removing the starter helmet if they're just chopping down a tree + */ if (player.getInventory().getHelmet() != null && - player.getLocation().getBlock().getLightFromSky() > 3 && - player.getInventory().getHelmet().getEnchantmentLevel(Enchantment.VANISHING_CURSE) == 2) - { - player.getInventory().setHelmet(new ItemStack(Material.AIR)); - } + player.getLocation().getBlock().getLightFromSky() > 3 && + player.getInventory().getHelmet().getEnchantmentLevel(Enchantment.VANISHING_CURSE) == 2) { + player.getInventory().setHelmet(new ItemStack(Material.AIR)); + } return; } @@ -67,11 +68,12 @@ public class Damager extends BukkitRunnable { long time = sunnedWorld.getTime(); boolean storming = sunnedWorld.hasStorm(); boolean thundering = sunnedWorld.isThundering(); - - // Times are pulled from Minecraft Gamepedia page on Light, specifically the internal light + + // Times are pulled from Minecraft Gamepedia page on Light, specifically the + // internal light // level section. https://minecraft.gamepedia.com/Light // Times correspond to when the light level is over 8. - if (storming && !thundering) { + if (storming && !thundering) { if (time >= 12734 && time <= 23266) { return false; } @@ -86,20 +88,24 @@ public class Damager extends BukkitRunnable { } /* - Material.isTransparent() is buggy and awful and only gives true for some things. This function - checks if a material lets light pass and should damage the player. - I've never seen it give a false positive, only a false negative, so it is one of the first - things we check. - */ + * Material.isTransparent() is buggy and awful and only gives true for some + * things. This function + * checks if a material lets light pass and should damage the player. + * I've never seen it give a false positive, only a false negative, so it is one + * of the first + * things we check. + */ @SuppressWarnings("deprecation") private boolean blockShouldDamage(Material mat) { String key = mat.getKey().getKey().toLowerCase(); - + if (mat == Material.BLACK_STAINED_GLASS) { return false; } - return mat.isTransparent() || key.indexOf("glass") != -1 || key.indexOf("leaves") != -1 || key.indexOf("sign") != -1 || key.indexOf("trapdoor") != -1 || key.indexOf("fence") != -1 || key.indexOf("bed") != -1 || mat == Material.ICE || mat == Material.HOPPER || mat == Material.COBWEB; + return mat.isTransparent() || key.indexOf("glass") != -1 || key.indexOf("leaves") != -1 + || key.indexOf("sign") != -1 || key.indexOf("trapdoor") != -1 || key.indexOf("fence") != -1 + || key.indexOf("bed") != -1 || mat == Material.ICE || mat == Material.HOPPER || mat == Material.COBWEB; } private class DoDamage extends BukkitRunnable { @@ -146,8 +152,8 @@ public class Damager extends BukkitRunnable { // Origintal is 60 + (40 / (level+1)) but we subtract one from fireProtLevel // so the +1 cancels int chanceToDamage = 60 + (40 / (fireProtLevel)); - - if (rand.nextInt(99)+1 <= chanceToDamage) { + + if (rand.nextInt(99) + 1 <= chanceToDamage) { int calculatedDamage = (int) Math.ceil(damage / 2); helmetDamageable.setDamage(helmetDamage + calculatedDamage); helmet.setItemMeta((ItemMeta) helmetDamageable); diff --git a/src/main/java/dev/genbyte/sunfright/Sunfright.java b/src/main/java/dev/nyble/sunfright/Sunfright.java index 13dfa69..6661ab6 100644 --- a/src/main/java/dev/genbyte/sunfright/Sunfright.java +++ b/src/main/java/dev/nyble/sunfright/Sunfright.java @@ -1,4 +1,4 @@ -package dev.genbyte.sunfright; +package dev.nyble.sunfright; import java.util.logging.Level; @@ -6,7 +6,7 @@ import org.bukkit.World; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; -import dev.genbyte.sunfright.events.HelmetHandler; +import dev.nyble.sunfright.events.HelmetHandler; public class Sunfright extends JavaPlugin { public World sunnedWorld; diff --git a/src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java b/src/main/java/dev/nyble/sunfright/events/HelmetHandler.java index 6c8afc9..e744a33 100644 --- a/src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java +++ b/src/main/java/dev/nyble/sunfright/events/HelmetHandler.java @@ -1,4 +1,4 @@ -package dev.genbyte.sunfright.events; +package dev.nyble.sunfright.events; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -11,7 +11,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import dev.genbyte.sunfright.Sunfright; +import dev.nyble.sunfright.Sunfright; public class HelmetHandler implements Listener { private final Sunfright sf; |