Skip to content

Commit

Permalink
Merge pull request #158 from BentoBoxWorld/157_permission_acid_damage…
Browse files Browse the repository at this point in the history
…_reduction

Add permissions to reduce acid damage
  • Loading branch information
tastybento authored Jul 22, 2024
2 parents 3e72891 + 48d5b63 commit 3d90d98
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main/java/world/bentobox/acidisland/listeners/AcidEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,14 @@ protected boolean checkForRain(Player player) {
// Check they are still in this world
} else if (wetPlayers.containsKey(player) && wetPlayers.get(player) < System.currentTimeMillis()) {
double protection = addon.getSettings().getAcidRainDamage() * getDamageReduced(player);
double totalDamage = Math.max(0, addon.getSettings().getAcidRainDamage() - protection);

User user = User.getInstance(player);
// Get the percentage reduction and ensure the value is between 0 and 100
double percent = (100
- Math.max(0, Math.min(100, user.getPermissionValue("acidisland.protection.rain", 0)))) / 100D;

double totalDamage = Math.max(0, addon.getSettings().getAcidRainDamage() - protection) * percent;

AcidRainEvent event = new AcidRainEvent(player, totalDamage, protection,
addon.getSettings().getAcidRainEffects());
Bukkit.getPluginManager().callEvent(event);
Expand Down Expand Up @@ -206,7 +213,14 @@ protected boolean continuouslyHurtPlayer(Player player) {
return true;
} else if (burningPlayers.containsKey(player) && burningPlayers.get(player) < System.currentTimeMillis()) {
double protection = addon.getSettings().getAcidDamage() * getDamageReduced(player);
double totalDamage = Math.max(0, addon.getSettings().getAcidDamage() - protection);

User user = User.getInstance(player);
// Get the percentage reduction and ensure the value is between 0 and 100
double percent = (100
- Math.max(0, Math.min(100, user.getPermissionValue("acidisland.protection.acid", 0)))) / 100D;

double totalDamage = Math.max(0, addon.getSettings().getAcidDamage() - protection) * percent;

AcidEvent event = new AcidEvent(player, totalDamage, protection, addon.getSettings().getAcidEffects());
addon.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
Expand Down

0 comments on commit 3d90d98

Please sign in to comment.