From 195bed14ee803241463ecdb80affc7cc03478933 Mon Sep 17 00:00:00 2001 From: Sobki Date: Sat, 3 Sep 2016 11:21:47 +1000 Subject: [PATCH] RaiseEarth works on gravel, Illumination only works in darkness (#570) --- .../projectkorra/ability/EarthAbility.java | 2 ++ .../configuration/ConfigManager.java | 1 + .../firebending/Illumination.java | 32 +++++++++++++------ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/com/projectkorra/projectkorra/ability/EarthAbility.java b/src/com/projectkorra/projectkorra/ability/EarthAbility.java index d65372e9..94d63bdd 100644 --- a/src/com/projectkorra/projectkorra/ability/EarthAbility.java +++ b/src/com/projectkorra/projectkorra/ability/EarthAbility.java @@ -477,6 +477,8 @@ public abstract class EarthAbility extends ElementalAbility { } else { target.setType(Material.SANDSTONE); } + } else if (info.getState().getType() == Material.GRAVEL) { + target.setType(Material.STONE); } else { target.setType(info.getState().getType()); target.setData(info.getState().getRawData()); diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 35bafcfe..824282d1 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -1028,6 +1028,7 @@ public class ConfigManager { config.addDefault("Abilities.Fire.Illumination.Enabled", true); config.addDefault("Abilities.Fire.Illumination.Range", 5); config.addDefault("Abilities.Fire.Illumination.Cooldown", 500); + config.addDefault("Abilities.Fire.Illumination.LightThreshold", 7); config.addDefault("Abilities.Fire.Lightning.Enabled", true); config.addDefault("Abilities.Fire.Lightning.Damage", 4.0); diff --git a/src/com/projectkorra/projectkorra/firebending/Illumination.java b/src/com/projectkorra/projectkorra/firebending/Illumination.java index ed73091d..e5839a40 100644 --- a/src/com/projectkorra/projectkorra/firebending/Illumination.java +++ b/src/com/projectkorra/projectkorra/firebending/Illumination.java @@ -19,12 +19,19 @@ public class Illumination extends FireAbility { private byte normalData; private long cooldown; private double range; + private int lightThreshold; private Material normalType; private Block block; + private int oldLevel; public Illumination(Player player) { super(player); + this.range = getConfig().getDouble("Abilities.Fire.Illumination.Range"); + this.cooldown = getConfig().getLong("Abilities.Fire.Illumination.Cooldown"); + this.range = getDayFactor(this.range); + this.lightThreshold = getConfig().getInt("Abilities.Fire.Illumination.LightThreshold"); + Illumination oldIllum = getAbility(player, Illumination.class); if (oldIllum != null) { oldIllum.remove(); @@ -36,18 +43,17 @@ public class Illumination extends FireAbility { return; } - this.range = getConfig().getDouble("Abilities.Fire.Illumination.Range"); - this.cooldown = getConfig().getLong("Abilities.Fire.Illumination.Cooldown"); - - this.range = getDayFactor(this.range); - if (bPlayer.isOnCooldown(this)) { return; } - set(); - start(); - bPlayer.addCooldown(this); + if (player.getLocation().getBlock().getLightLevel() < this.lightThreshold) { + oldLevel = player.getLocation().getBlock().getLightLevel(); + bPlayer.addCooldown(this); + set(); + start(); + } + } @Override @@ -62,6 +68,11 @@ public class Illumination extends FireAbility { return; } + if (oldLevel > this.lightThreshold) { + remove(); + return; + } + set(); } @@ -77,6 +88,7 @@ public class Illumination extends FireAbility { BLOCKS.remove(block); block.setType(normalType); block.setData(normalData); + oldLevel = player.getLocation().getBlock().getLightLevel(); } } @@ -88,7 +100,7 @@ public class Illumination extends FireAbility { if (standBlock.getType() == Material.GLOWSTONE) { revert(); } else if ((BlazeArc.isIgnitable(player, standingBlock) - && standBlock.getType() != Material.LEAVES && standBlock .getType() != Material.LEAVES_2) + && standBlock.getType() != Material.LEAVES && standBlock.getType() != Material.LEAVES_2) && block == null && !BLOCKS.containsKey(standBlock)) { block = standingBlock; normalType = block.getType(); @@ -97,7 +109,7 @@ public class Illumination extends FireAbility { block.setType(Material.TORCH); BLOCKS.put(block, player); } else if ((BlazeArc.isIgnitable(player, standingBlock) - && standBlock.getType() != Material.LEAVES && standBlock .getType() != Material.LEAVES_2) + && standBlock.getType() != Material.LEAVES && standBlock.getType() != Material.LEAVES_2) && !block.equals(standBlock) && !BLOCKS.containsKey(standBlock) && GeneralMethods.isSolid(standBlock)) {