about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGenny <gen@nyble.dev>2020-12-02 16:48:28 -0600
committerGenny <gen@nyble.dev>2020-12-02 16:48:28 -0600
commita9bed0624745250e8d447ae858bdc632fe84555e (patch)
tree6066916e6a402b43fb724371e4ceef7af42bb1fe
parenta4a675713a663e404e0b7abeb869953a46fae331 (diff)
downloadsunfright-a9bed0624745250e8d447ae858bdc632fe84555e.tar.gz
sunfright-a9bed0624745250e8d447ae858bdc632fe84555e.zip
Add respawn helmet configuration option
-rw-r--r--README.md33
-rw-r--r--pom.xml6
-rw-r--r--src/main/java/dev/genbyte/sunfright/Damager.java3
-rw-r--r--src/main/java/dev/genbyte/sunfright/Sunfright.java7
-rw-r--r--src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java2
-rw-r--r--src/main/resources/config.yml3
6 files changed, 42 insertions, 12 deletions
diff --git a/README.md b/README.md
index f81fec4..9501935 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,32 @@ to break on the default damage value. Data is pulled from the
 
 [mcwiki-helmets]: https://minecraft.gamepedia.com/Helmet#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`
+
+This is the game world you would like the plugin to operate in.
+
+##### `damagePerSecond`
+Default: `2`
+
+The amount of damage you want the player to take from the sun. If they're
+wearing a helmet with Fire Protection, it will take half of this damage rounded
+up to the nearest whole number. One damage is equal to 1 half-heart.
+
+##### `enableRespawnHelmet`
+Default: `true`
+
+Whether or not you get a helmet that protects you from the sun on respawn. It's
+setup in such a way that the helmet can only last 5 minutes in the sun and will
+disappear the instant you're safe from the sun.
+
 ## Damage Conditions
 You will be damaged if you are in direct sunlight and not under a solid block
 (or black stained glass) and the time falls in any of these ranges:
@@ -43,9 +69,4 @@ In addition to these conditions, your helmet may not take damage if you have
 a Fire Protection level higher than I. If you do, then the extra Fire Protection
 levels act as Unbreaking. So if you have Fire Protection IV, then it is
 equivalent to Unbreaking III and the sun has a 30% chance to not damage your
-helmet. Fire Protection III has a 27% chance to not damage, and II a 20%.
-
-### Notes
-- 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.
+helmet. Fire Protection III has a 27% chance to not damage, and II a 20%.
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 6404dfa..7f5b7e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,11 +4,11 @@
   <modelVersion>4.0.0</modelVersion>
 
   <groupId>dev.genbyte.sunfright</groupId>
-  <artifactId>sunfright</artifactId>
+  <artifactId>Sunfright</artifactId>
   <packaging>jar</packaging>
-  <version>0.7.0</version>
+  <version>1.0.0</version>
 
-  <name>sunfright</name>
+  <name>Sunfright</name>
   <description>Burn me to a crisp, large glowing orb!</description>
   <url>https://genbyte.dev</url><!-- TODO: add URL -->
 
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