Merge pull request #17 from Anonymous1432/master

The Great HealingWaters Overhaul
This commit is contained in:
MistPhizzle 2014-08-11 10:59:27 -04:00
commit a873b684a3
2 changed files with 63 additions and 3 deletions

View file

@ -45,6 +45,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import com.massivecraft.factions.listeners.FactionsListenerMain;
@ -1782,5 +1783,40 @@ public class Methods {
public Methods(ProjectKorra plugin) {
Methods.plugin = plugin;
}
public static boolean isNegativeEffect(PotionEffectType effect) {
if(effect.equals(PotionEffectType.POISON)) return true;
if(effect.equals(PotionEffectType.BLINDNESS)) return true;
if(effect.equals(PotionEffectType.CONFUSION)) return true;
if(effect.equals(PotionEffectType.HARM)) return true;
if(effect.equals(PotionEffectType.HUNGER)) return true;
if(effect.equals(PotionEffectType.SLOW)) return true;
if(effect.equals(PotionEffectType.SLOW_DIGGING)) return true;
if(effect.equals(PotionEffectType.WEAKNESS)) return true;
if(effect.equals(PotionEffectType.WITHER)) return true;
return false;
}
public static boolean isPositiveEffect(PotionEffectType effect) {
if(effect.equals(PotionEffectType.ABSORPTION)) return true;
if(effect.equals(PotionEffectType.DAMAGE_RESISTANCE)) return true;
if(effect.equals(PotionEffectType.FAST_DIGGING)) return true;
if(effect.equals(PotionEffectType.FIRE_RESISTANCE)) return true;
if(effect.equals(PotionEffectType.HEAL)) return true;
if(effect.equals(PotionEffectType.HEALTH_BOOST)) return true;
if(effect.equals(PotionEffectType.INCREASE_DAMAGE)) return true;
if(effect.equals(PotionEffectType.JUMP)) return true;
if(effect.equals(PotionEffectType.NIGHT_VISION)) return true;
if(effect.equals(PotionEffectType.REGENERATION)) return true;
if(effect.equals(PotionEffectType.SATURATION)) return true;
if(effect.equals(PotionEffectType.SPEED)) return true;
if(effect.equals(PotionEffectType.WATER_BREATHING)) return true;
return false;
}
public static boolean isNeutralEffect(PotionEffectType effect) {
if(effect.equals(PotionEffectType.INVISIBILITY)) return true;
return false;
}
}

View file

@ -51,6 +51,11 @@ public class HealingWaters {
if (!le.isDead() && le.getHealth() < le.getMaxHealth()) {
applyHealingToEntity(le);
}
for(PotionEffect effect : le.getActivePotionEffects()) {
if(Methods.isNegativeEffect(effect.getType())) {
applyHealingToEntity(le);
}
}
}
private static void giveHP(Player player) {
@ -62,6 +67,11 @@ public class HealingWaters {
// player.setHealth(hp);
applyHealing(player);
}
for(PotionEffect effect : player.getActivePotionEffects()) {
if(Methods.isNegativeEffect(effect.getType())) {
applyHealing(player);
}
}
}
@ -79,11 +89,25 @@ public class HealingWaters {
private static void applyHealing(Player player) {
if (!Methods.isRegionProtectedFromBuild(player, "HealingWaters", player.getLocation()))
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 70, 1));
if(player.getHealth() < player.getMaxHealth()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 70, 1));
}
for(PotionEffect effect : player.getActivePotionEffects()) {
if(Methods.isNegativeEffect(effect.getType())) {
player.removePotionEffect(effect.getType());
}
}
}
private static void applyHealingToEntity(LivingEntity le) {
le.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 70, 1));
if(le.getHealth() < le.getMaxHealth()) {
le.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 70, 1));
}
for(PotionEffect effect : le.getActivePotionEffects()) {
if(Methods.isNegativeEffect(effect.getType())) {
le.removePotionEffect(effect.getType());
}
}
}
public static String getDescription() {
@ -92,6 +116,6 @@ public class HealingWaters {
+ "working provided the user has it selected. If the user is sneaking, "
+ "he/she is channeling the healing to their target in front of them. "
+ "In order for this channel to be successful, the user and the target must "
+ "be at least partially submerged in water.";
+ "be at least partially submerged in water. This ability will heal the user or target, and it will also remove any negative potion effects the user or target has.";
}
}