diff options
author | Genny <gen@nyble.dev> | 2020-12-02 16:48:28 -0600 |
---|---|---|
committer | Genny <gen@nyble.dev> | 2020-12-02 16:48:28 -0600 |
commit | a9bed0624745250e8d447ae858bdc632fe84555e (patch) | |
tree | 6066916e6a402b43fb724371e4ceef7af42bb1fe /src/main | |
parent | a4a675713a663e404e0b7abeb869953a46fae331 (diff) | |
download | sunfright-a9bed0624745250e8d447ae858bdc632fe84555e.tar.gz sunfright-a9bed0624745250e8d447ae858bdc632fe84555e.zip |
Add respawn helmet configuration option
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/dev/genbyte/sunfright/Damager.java | 3 | ||||
-rw-r--r-- | src/main/java/dev/genbyte/sunfright/Sunfright.java | 7 | ||||
-rw-r--r-- | src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java | 2 | ||||
-rw-r--r-- | src/main/resources/config.yml | 3 |
4 files changed, 12 insertions, 3 deletions
diff --git a/src/main/java/dev/genbyte/sunfright/Damager.java b/src/main/java/dev/genbyte/sunfright/Damager.java index 038295d..4ee7615 100644 --- a/src/main/java/dev/genbyte/sunfright/Damager.java +++ b/src/main/java/dev/genbyte/sunfright/Damager.java @@ -148,7 +148,8 @@ public class Damager extends BukkitRunnable { int chanceToDamage = 60 + (40 / (fireProtLevel)); if (rand.nextInt(99)+1 <= chanceToDamage) { - helmetDamageable.setDamage(helmetDamage + (damage/2)); + 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/genbyte/sunfright/Sunfright.java index 6404360..13dfa69 100644 --- a/src/main/java/dev/genbyte/sunfright/Sunfright.java +++ b/src/main/java/dev/genbyte/sunfright/Sunfright.java @@ -11,6 +11,7 @@ import dev.genbyte.sunfright.events.HelmetHandler; public class Sunfright extends JavaPlugin { public World sunnedWorld; public int damagaPerSecond; + public boolean respawnHelmetEnabled; private BukkitTask damager; @Override @@ -48,6 +49,12 @@ public class Sunfright extends JavaPlugin { 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 index 739ee78..6c8afc9 100644 --- a/src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java +++ b/src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java @@ -45,7 +45,7 @@ public class HelmetHandler implements Listener { } private void setRespawnHelmet(Player player) { - if (!player.getWorld().equals(sf.sunnedWorld)) { + if (!sf.respawnHelmetEnabled || !player.getWorld().equals(sf.sunnedWorld)) { return; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9f7bcd9..ff6c3ff 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,2 +1,3 @@ world: world -damagePerSecond: 2 \ No newline at end of file +damagePerSecond: 2 +enableRespawnHelmet: true \ No newline at end of file |