Bleed doesn't suck anymore.

This commit is contained in:
nossr50
2019-01-21 15:14:01 -08:00
parent 848cee18a9
commit 11c8374f6c
18 changed files with 137 additions and 60 deletions

View File

@ -5,6 +5,8 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -17,6 +19,7 @@ import java.util.Map.Entry;
public class BleedTimerTask extends BukkitRunnable {
private final static int MAX_BLEED_TICKS = 10;
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
private static Map<LivingEntity, Integer> bleedDamage = new HashMap<LivingEntity, Integer>();
@Override
public void run() {
@ -31,8 +34,16 @@ public class BleedTimerTask extends BukkitRunnable {
double damage;
//Play Bleed Sound
SoundManager.worldSendSound(entity.getWorld(), entity.getLocation(), SoundType.BLEED);
if (entity instanceof Player) {
damage = AdvancedConfig.getInstance().getBleedDamagePlayer();
damage = AdvancedConfig.getInstance().getRuptureDamagePlayer();
//Above Bleed Rank 3 deals 50% more damage
if(bleedDamage.get(entity) >= 3)
damage = damage * 1.5;
Player player = (Player) entity;
if (!player.isOnline()) {
@ -52,7 +63,7 @@ public class BleedTimerTask extends BukkitRunnable {
}
}
else {
damage = AdvancedConfig.getInstance().getBleedDamageMobs();
damage = AdvancedConfig.getInstance().getRuptureDamageMobs();
// Anticipate the entity's death to prevent CME because of our EntityDeathEvent listener
if (entity.getHealth() - damage > 0) {
@ -75,8 +86,9 @@ public class BleedTimerTask extends BukkitRunnable {
*/
public static void bleedOut(LivingEntity entity) {
if (bleedList.containsKey(entity)) {
CombatUtils.dealDamage(entity, bleedList.get(entity) * 2);
CombatUtils.dealNoInvulnerabilityTickDamage(entity, bleedList.get(entity) * 2, null);
bleedList.remove(entity);
bleedDamage.remove(entity);
}
}
@ -88,6 +100,7 @@ public class BleedTimerTask extends BukkitRunnable {
public static void remove(LivingEntity entity) {
if (bleedList.containsKey(entity)) {
bleedList.remove(entity);
bleedDamage.remove(entity);
}
}
@ -97,15 +110,20 @@ public class BleedTimerTask extends BukkitRunnable {
* @param entity LivingEntity to add
* @param ticks Number of bleeding ticks
*/
public static void add(LivingEntity entity, int ticks) {
public static void add(LivingEntity entity, int ticks, int bleedRank) {
int newTicks = ticks;
if (bleedList.containsKey(entity)) {
newTicks += bleedList.get(entity);
bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS));
//Override the current bleed rank only if this one is higher
if(bleedDamage.get(entity) < bleedRank)
bleedDamage.put(entity, bleedRank);
}
else {
bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS));
bleedDamage.put(entity, bleedRank);
}
}