From 60592fd01111e75335245835e2518f900e8d35d1 Mon Sep 17 00:00:00 2001 From: gennyble Date: Wed, 8 Nov 2023 21:36:31 -0600 Subject: fix --- .github/FUNDING.yml | 1 - .github/workflows/java-ci.yml | 16 -- .gitignore | 4 +- LICENSE | 2 +- README.md | 21 +-- pom.xml | 18 +-- src/main/java/dev/genbyte/sunfright/Damager.java | 166 -------------------- src/main/java/dev/genbyte/sunfright/Sunfright.java | 60 ------- .../genbyte/sunfright/events/HelmetHandler.java | 61 -------- src/main/java/dev/nyble/sunfright/Damager.java | 172 +++++++++++++++++++++ src/main/java/dev/nyble/sunfright/Sunfright.java | 60 +++++++ .../dev/nyble/sunfright/events/HelmetHandler.java | 61 ++++++++ 12 files changed, 307 insertions(+), 335 deletions(-) delete mode 100644 .github/FUNDING.yml delete mode 100644 .github/workflows/java-ci.yml delete mode 100644 src/main/java/dev/genbyte/sunfright/Damager.java delete mode 100644 src/main/java/dev/genbyte/sunfright/Sunfright.java delete mode 100644 src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java create mode 100644 src/main/java/dev/nyble/sunfright/Damager.java create mode 100644 src/main/java/dev/nyble/sunfright/Sunfright.java create mode 100644 src/main/java/dev/nyble/sunfright/events/HelmetHandler.java diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 3a4227e..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -ko_fi: genbyte \ No newline at end of file diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml deleted file mode 100644 index ef2dd67..0000000 --- a/.github/workflows/java-ci.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Java CI - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Build with Maven - run: mvn -B package --file pom.xml \ No newline at end of file diff --git a/.gitignore b/.gitignore index b1fcc78..edd2fa2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,12 +2,12 @@ .vscode .settings -# Java things (?) +# Java things .project .classpath # Maven things target/ -# Genuinebyte things +# script things *.sh diff --git a/LICENSE b/LICENSE index db7f181..60ceb94 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2020 Brad Alfirevic +Copyright 2023 Genny Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/README.md b/README.md index 4002426..02463b8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,3 @@ -# Inactive; Unmaintined - -This plugin is no longer maintined. It might still work for your version of the game. If you plan to use it, I recommend testing it first on an unimportant server. I don't think it'd be able to cause much damage, but it's better to be safe. - # Sunfright Inspired by the [404 challenge][404], this is a Spigot plugin that restricts your ability to be in sunlight. @@ -20,7 +16,7 @@ you have a Fire Protection helmet on, the helmet takes half the damage you would be dealt and you don't take any damage. There is a table below listing the types of helmets, their durability, and the time it would take for this helmet to break on the default damage value. Data is pulled from the -[Minecraft Gamepedia page on Helmets][mcwiki-helmets]. +[minecraft.wiki page on Helmets][mcwiki-helmets]. | Material | Durability | Time Exposed to Sunlight | | ------------ | ---------- | ------------------------- | @@ -31,22 +27,9 @@ to break on the default damage value. Data is pulled from the | Turtle Shell | 276 | 4 minutes, 36 seconds | | Diamond | 364 | 6 minutes, 4 seconds | -[mcwiki-helmets]: https://minecraft.gamepedia.com/Helmet#Durability - -## Download -You can get the latest build from [**Curseforge**][curseforge], [**SpigotMC**][spigot], or on the -[**GitHub releases page**][github-releases]. - -[curseforge]: https://www.curseforge.com/minecraft/bukkit-plugins/sunfright -[spigot]: https://www.spigotmc.org/resources/sunfright.86454 -[github-releases]: https://github.com/genuinebyte/sunfright/releases +[mcwiki-helmets]: https://minecraft.wiki/w/Durability#Armor_durability ## Configuration -Currently there are only three configuration options, but more will be made -available as the plugin evolves. If you think something should be configurable, -please [open an issue][issue-tracker]! - -[issue-tracker]: https://github.com/genuinebyte/sunfright/issues **world** Default: `world` diff --git a/pom.xml b/pom.xml index 9943429..ac1df3f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,27 +1,27 @@ - + 4.0.0 - dev.genbyte.sunfright + dev.nyble.sunfright Sunfright jar 1.0.0 Sunfright Burn me to a crisp, large glowing orb! - https://genbyte.dev + https://nyble.dev - Genuinebyte - https://genbyte.dev + Genny + https://nyble.dev - Genuinebyte - dev.genbyte.sunfright.Sunfright + Genny + dev.nyble.sunfright.Sunfright 1.8 1.8 @@ -39,7 +39,7 @@ org.spigotmc spigot-api - 1.16.4-R0.1-SNAPSHOT + 1.17.1-R0.1-SNAPSHOT provided diff --git a/src/main/java/dev/genbyte/sunfright/Damager.java b/src/main/java/dev/genbyte/sunfright/Damager.java deleted file mode 100644 index 4ee7615..0000000 --- a/src/main/java/dev/genbyte/sunfright/Damager.java +++ /dev/null @@ -1,166 +0,0 @@ -package dev.genbyte.sunfright; - -import java.util.Collection; -import java.util.Random; - -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; - -public class Damager extends BukkitRunnable { - private final Sunfright sf; - private final Random rand; - - public Damager(Sunfright sf) { - this.sf = sf; - this.rand = new Random(); - } - - public void run() { - if (!timeShouldDamage()) { - return; - } - - World sunnedWorld = sf.sunnedWorld; - Collection players = sunnedWorld.getPlayers(); - - players.forEach((player) -> { - Location loc = player.getLocation(); - int x = loc.getBlockX(); - int y = loc.getBlockY(); - int z = loc.getBlockZ(); - // Returns one lower than it should? - 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 */ - 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)); - } - - return; - } - } - - new DoDamage(player, sf.damagaPerSecond).runTask(sf); - }); - } - - private boolean timeShouldDamage() { - World sunnedWorld = sf.sunnedWorld; - - 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 - // level section. https://minecraft.gamepedia.com/Light - // Times correspond to when the light level is over 8. - if (storming && !thundering) { - if (time >= 12734 && time <= 23266) { - return false; - } - } else if (storming && thundering) { - if (time >= 12300 && time <= 23700) { - return false; - } - } else if (time >= 13027 && time <= 22973) { - return false; - } - return true; - } - - /* - 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; - } - - private class DoDamage extends BukkitRunnable { - private final Player player; - private final int damage; - - public DoDamage(Player player, int damage) { - this.player = player; - this.damage = damage; - } - - public void run() { - ItemStack helmet = player.getInventory().getHelmet(); - - if (helmet != null) { - ItemMeta helmetMeta = helmet.getItemMeta(); - - if (helmetMeta instanceof Damageable) { - Damageable helmetDamageable = (Damageable) helmetMeta; - int helmetDamage = helmetDamageable.getDamage(); - int fireProtLevel = helmet.getEnchantmentLevel(Enchantment.PROTECTION_FIRE); - - if (fireProtLevel < 1) { - damagePlayer(); - return; - } - - if (helmetDamage + damage >= helmet.getType().getMaxDurability()) { - if (helmet.getEnchantmentLevel(Enchantment.VANISHING_CURSE) == 2) { - int bindLevel = helmet.getEnchantmentLevel(Enchantment.BINDING_CURSE); - - if (bindLevel < 5) { - helmetDamageable.setDamage(0); - helmet.setItemMeta((ItemMeta) helmetDamageable); - helmet.addUnsafeEnchantment(Enchantment.BINDING_CURSE, bindLevel + 1); - - return; - } - } - - player.getInventory().setHelmet(new ItemStack(Material.AIR)); - } else { - // Formula from https://minecraft.gamepedia.com/Unbreaking - // 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) { - int calculatedDamage = (int) Math.ceil(damage / 2); - helmetDamageable.setDamage(helmetDamage + calculatedDamage); - helmet.setItemMeta((ItemMeta) helmetDamageable); - } - } - } - } else { - damagePlayer(); - } - } - - private void damagePlayer() { - player.damage(damage); - } - } -} diff --git a/src/main/java/dev/genbyte/sunfright/Sunfright.java b/src/main/java/dev/genbyte/sunfright/Sunfright.java deleted file mode 100644 index 13dfa69..0000000 --- a/src/main/java/dev/genbyte/sunfright/Sunfright.java +++ /dev/null @@ -1,60 +0,0 @@ -package dev.genbyte.sunfright; - -import java.util.logging.Level; - -import org.bukkit.World; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitTask; - -import dev.genbyte.sunfright.events.HelmetHandler; - -public class Sunfright extends JavaPlugin { - public World sunnedWorld; - public int damagaPerSecond; - public boolean respawnHelmetEnabled; - private BukkitTask damager; - - @Override - public void onEnable() { - if (!loadConfig()) { - getLogger().log(Level.SEVERE, "Could not load config file, aborting load. Plugin not active!"); - getPluginLoader().disablePlugin(this); - return; - } - - int time = 20; - damager = new Damager(this).runTaskTimerAsynchronously(this, time, time); - - this.getServer().getPluginManager().registerEvents(new HelmetHandler(this), this); - } - - @Override - public void onDisable() { - damager.cancel(); - } - - private boolean loadConfig() { - this.saveDefaultConfig(); - - String world = getConfig().getString("world"); - damagaPerSecond = getConfig().getInt("damagePerSecond"); - - sunnedWorld = getServer().getWorld(world); - if (sunnedWorld == null) { - getLogger().log(Level.SEVERE, "World '" + world + "' is not valid! Aborting loading config!"); - return false; - } - - if (damagaPerSecond == 0) { - getLogger().log(Level.WARNING, "damagePerSecond is 0. Was this intended?"); - } - - if (getConfig().isSet("enableRespawnHelmet")) { - respawnHelmetEnabled = getConfig().getBoolean("enableRespawnHelmet"); - } else { - getLogger().log(Level.WARNING, "enableRespawnHelmet was not set! Defaulting to true!"); - } - - return true; - } -} \ No newline at end of file diff --git a/src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java b/src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java deleted file mode 100644 index 6c8afc9..0000000 --- a/src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -package dev.genbyte.sunfright.events; - -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; - -import dev.genbyte.sunfright.Sunfright; - -public class HelmetHandler implements Listener { - private final Sunfright sf; - - public HelmetHandler(Sunfright sf) { - this.sf = sf; - } - - @EventHandler - public void onPlayerRespawn(PlayerRespawnEvent event) { - setRespawnHelmet(event.getPlayer()); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - Player player = event.getPlayer(); - - if (!player.hasPlayedBefore()) { - setRespawnHelmet(player); - } - } - - @EventHandler - public void onInventoryClick(InventoryClickEvent event) { - if (event.getClickedInventory() instanceof PlayerInventory - && event.getCurrentItem().getEnchantmentLevel(Enchantment.VANISHING_CURSE) == 2) { - - event.setCancelled(true); - event.getView().setItem(event.getRawSlot(), new ItemStack(Material.AIR)); - } - } - - private void setRespawnHelmet(Player player) { - if (!sf.respawnHelmetEnabled || !player.getWorld().equals(sf.sunnedWorld)) { - return; - } - - PlayerInventory inv = player.getInventory(); - - ItemStack stack = new ItemStack(Material.LEATHER_HELMET); - stack.addUnsafeEnchantment(Enchantment.BINDING_CURSE, 1); - stack.addUnsafeEnchantment(Enchantment.VANISHING_CURSE, 2); - stack.addEnchantment(Enchantment.PROTECTION_FIRE, 1); - - inv.setHelmet(stack); - } -} diff --git a/src/main/java/dev/nyble/sunfright/Damager.java b/src/main/java/dev/nyble/sunfright/Damager.java new file mode 100644 index 0000000..890bb98 --- /dev/null +++ b/src/main/java/dev/nyble/sunfright/Damager.java @@ -0,0 +1,172 @@ +package dev.nyble.sunfright; + +import java.util.Collection; +import java.util.Random; + +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; + +public class Damager extends BukkitRunnable { + private final Sunfright sf; + private final Random rand; + + public Damager(Sunfright sf) { + this.sf = sf; + this.rand = new Random(); + } + + public void run() { + if (!timeShouldDamage()) { + return; + } + + World sunnedWorld = sf.sunnedWorld; + Collection players = sunnedWorld.getPlayers(); + + players.forEach((player) -> { + Location loc = player.getLocation(); + int x = loc.getBlockX(); + int y = loc.getBlockY(); + int z = loc.getBlockZ(); + // Returns one lower than it should? + 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 + */ + 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)); + } + + return; + } + } + + new DoDamage(player, sf.damagaPerSecond).runTask(sf); + }); + } + + private boolean timeShouldDamage() { + World sunnedWorld = sf.sunnedWorld; + + 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 + // level section. https://minecraft.gamepedia.com/Light + // Times correspond to when the light level is over 8. + if (storming && !thundering) { + if (time >= 12734 && time <= 23266) { + return false; + } + } else if (storming && thundering) { + if (time >= 12300 && time <= 23700) { + return false; + } + } else if (time >= 13027 && time <= 22973) { + return false; + } + return true; + } + + /* + * 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; + } + + private class DoDamage extends BukkitRunnable { + private final Player player; + private final int damage; + + public DoDamage(Player player, int damage) { + this.player = player; + this.damage = damage; + } + + public void run() { + ItemStack helmet = player.getInventory().getHelmet(); + + if (helmet != null) { + ItemMeta helmetMeta = helmet.getItemMeta(); + + if (helmetMeta instanceof Damageable) { + Damageable helmetDamageable = (Damageable) helmetMeta; + int helmetDamage = helmetDamageable.getDamage(); + int fireProtLevel = helmet.getEnchantmentLevel(Enchantment.PROTECTION_FIRE); + + if (fireProtLevel < 1) { + damagePlayer(); + return; + } + + if (helmetDamage + damage >= helmet.getType().getMaxDurability()) { + if (helmet.getEnchantmentLevel(Enchantment.VANISHING_CURSE) == 2) { + int bindLevel = helmet.getEnchantmentLevel(Enchantment.BINDING_CURSE); + + if (bindLevel < 5) { + helmetDamageable.setDamage(0); + helmet.setItemMeta((ItemMeta) helmetDamageable); + helmet.addUnsafeEnchantment(Enchantment.BINDING_CURSE, bindLevel + 1); + + return; + } + } + + player.getInventory().setHelmet(new ItemStack(Material.AIR)); + } else { + // Formula from https://minecraft.gamepedia.com/Unbreaking + // 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) { + int calculatedDamage = (int) Math.ceil(damage / 2); + helmetDamageable.setDamage(helmetDamage + calculatedDamage); + helmet.setItemMeta((ItemMeta) helmetDamageable); + } + } + } + } else { + damagePlayer(); + } + } + + private void damagePlayer() { + player.damage(damage); + } + } +} diff --git a/src/main/java/dev/nyble/sunfright/Sunfright.java b/src/main/java/dev/nyble/sunfright/Sunfright.java new file mode 100644 index 0000000..6661ab6 --- /dev/null +++ b/src/main/java/dev/nyble/sunfright/Sunfright.java @@ -0,0 +1,60 @@ +package dev.nyble.sunfright; + +import java.util.logging.Level; + +import org.bukkit.World; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitTask; + +import dev.nyble.sunfright.events.HelmetHandler; + +public class Sunfright extends JavaPlugin { + public World sunnedWorld; + public int damagaPerSecond; + public boolean respawnHelmetEnabled; + private BukkitTask damager; + + @Override + public void onEnable() { + if (!loadConfig()) { + getLogger().log(Level.SEVERE, "Could not load config file, aborting load. Plugin not active!"); + getPluginLoader().disablePlugin(this); + return; + } + + int time = 20; + damager = new Damager(this).runTaskTimerAsynchronously(this, time, time); + + this.getServer().getPluginManager().registerEvents(new HelmetHandler(this), this); + } + + @Override + public void onDisable() { + damager.cancel(); + } + + private boolean loadConfig() { + this.saveDefaultConfig(); + + String world = getConfig().getString("world"); + damagaPerSecond = getConfig().getInt("damagePerSecond"); + + sunnedWorld = getServer().getWorld(world); + if (sunnedWorld == null) { + getLogger().log(Level.SEVERE, "World '" + world + "' is not valid! Aborting loading config!"); + return false; + } + + if (damagaPerSecond == 0) { + getLogger().log(Level.WARNING, "damagePerSecond is 0. Was this intended?"); + } + + if (getConfig().isSet("enableRespawnHelmet")) { + respawnHelmetEnabled = getConfig().getBoolean("enableRespawnHelmet"); + } else { + getLogger().log(Level.WARNING, "enableRespawnHelmet was not set! Defaulting to true!"); + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/dev/nyble/sunfright/events/HelmetHandler.java b/src/main/java/dev/nyble/sunfright/events/HelmetHandler.java new file mode 100644 index 0000000..e744a33 --- /dev/null +++ b/src/main/java/dev/nyble/sunfright/events/HelmetHandler.java @@ -0,0 +1,61 @@ +package dev.nyble.sunfright.events; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +import dev.nyble.sunfright.Sunfright; + +public class HelmetHandler implements Listener { + private final Sunfright sf; + + public HelmetHandler(Sunfright sf) { + this.sf = sf; + } + + @EventHandler + public void onPlayerRespawn(PlayerRespawnEvent event) { + setRespawnHelmet(event.getPlayer()); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + Player player = event.getPlayer(); + + if (!player.hasPlayedBefore()) { + setRespawnHelmet(player); + } + } + + @EventHandler + public void onInventoryClick(InventoryClickEvent event) { + if (event.getClickedInventory() instanceof PlayerInventory + && event.getCurrentItem().getEnchantmentLevel(Enchantment.VANISHING_CURSE) == 2) { + + event.setCancelled(true); + event.getView().setItem(event.getRawSlot(), new ItemStack(Material.AIR)); + } + } + + private void setRespawnHelmet(Player player) { + if (!sf.respawnHelmetEnabled || !player.getWorld().equals(sf.sunnedWorld)) { + return; + } + + PlayerInventory inv = player.getInventory(); + + ItemStack stack = new ItemStack(Material.LEATHER_HELMET); + stack.addUnsafeEnchantment(Enchantment.BINDING_CURSE, 1); + stack.addUnsafeEnchantment(Enchantment.VANISHING_CURSE, 2); + stack.addEnchantment(Enchantment.PROTECTION_FIRE, 1); + + inv.setHelmet(stack); + } +} -- cgit 1.4.1-3-g733a5