mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
The Great HealingWaters Overhaul
Changes to HealingWaters: - HealingWaters will now remove negative potion effects on the user or the target Changes to Methods: - Added checks for negative potion effects, positive potion effects, and neutral potion effects which can be used in the future by us in the creation of abilities, or by developers utilizing the Ability API
This commit is contained in:
parent
9971e1fc44
commit
711f4eeedd
2 changed files with 63 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue