Fixing several issues related to Bleed/Rupture

Rupture now keeps track of who applied the damage and attributes it correctly in events
Rupture's bleed timer task no longer caps at the low value of 10 ticks internally
Ruptures bleed check code has had some minor refactoring
This commit is contained in:
nossr50
2019-01-23 15:22:16 -08:00
parent e5e86246f3
commit 3e5c4bc617
5 changed files with 19 additions and 19 deletions

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.swords.Swords;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
@ -43,7 +42,7 @@ public class SwordsCommand extends SkillCommand {
// SWORDS_RUPTURE
if (canBleed) {
bleedLength = UserManager.getPlayer(player).getSwordsManager().getBleedTicks();
bleedLength = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks();
String[] bleedStrings = calculateAbilityDisplayValues(skillValue, SubSkillType.SWORDS_RUPTURE, isLucky);
bleedChance = bleedStrings[0];
@ -69,7 +68,7 @@ public class SwordsCommand extends SkillCommand {
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
int ruptureTicks = UserManager.getPlayer(player).getSwordsManager().getBleedTicks();
int ruptureTicks = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks();
double ruptureDamagePlayers = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamagePlayer() * 1.5D : AdvancedConfig.getInstance().getRuptureDamagePlayer();
double ruptureDamageMobs = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamageMobs() * 1.5D : AdvancedConfig.getInstance().getRuptureDamageMobs();

View File

@ -511,7 +511,7 @@ public class mcMMO extends JavaPlugin {
// Cleanup the backups folder
new CleanBackupsTask().runTaskAsynchronously(mcMMO.p);
// Bleed timer (Runs every two seconds)
// Bleed timer (Runs every 0.5 seconds)
new BleedTimerTask().runTaskTimer(this, 1 * Misc.TICK_CONVERSION_FACTOR, 1 * (Misc.TICK_CONVERSION_FACTOR / 2));
// Old & Powerless User remover

View File

@ -17,9 +17,10 @@ import java.util.Map;
import java.util.Map.Entry;
public class BleedTimerTask extends BukkitRunnable {
private final static int MAX_BLEED_TICKS = 10;
private final static int MAX_BLEED_TICKS = 100; //The cap has been raised :)
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
private static Map<LivingEntity, Integer> bleedDamage = new HashMap<LivingEntity, Integer>();
private static Map<LivingEntity, LivingEntity> attackerMap = new HashMap<>();
@Override
public void run() {
@ -73,7 +74,8 @@ public class BleedTimerTask extends BukkitRunnable {
bleedIterator.remove();
}
CombatUtils.dealNoInvulnerabilityTickDamage(entity, damage, null);
CombatUtils.dealNoInvulnerabilityTickDamage(entity, damage, attackerMap.get(entity));
ParticleEffectUtils.playBleedEffect(entity);
}
}
@ -86,9 +88,10 @@ public class BleedTimerTask extends BukkitRunnable {
*/
public static void bleedOut(LivingEntity entity) {
if (bleedList.containsKey(entity)) {
CombatUtils.dealNoInvulnerabilityTickDamage(entity, bleedList.get(entity) * 2, null);
CombatUtils.dealNoInvulnerabilityTickDamage(entity, bleedList.get(entity) * 2, attackerMap.get(entity));
bleedList.remove(entity);
bleedDamage.remove(entity);
attackerMap.remove(entity);
}
}
@ -101,6 +104,7 @@ public class BleedTimerTask extends BukkitRunnable {
if (bleedList.containsKey(entity)) {
bleedList.remove(entity);
bleedDamage.remove(entity);
attackerMap.remove(entity);
}
}
@ -110,20 +114,21 @@ public class BleedTimerTask extends BukkitRunnable {
* @param entity LivingEntity to add
* @param ticks Number of bleeding ticks
*/
public static void add(LivingEntity entity, int ticks, int bleedRank) {
public static void add(LivingEntity entity, LivingEntity attacker, int ticks, int bleedRank) {
int newTicks = ticks;
if (bleedList.containsKey(entity)) {
newTicks += bleedList.get(entity);
bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS));
bleedList.put(entity, Math.min(MAX_BLEED_TICKS, newTicks));
//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));
bleedList.put(entity, Math.min(MAX_BLEED_TICKS, newTicks));
bleedDamage.put(entity, bleedRank);
attackerMap.put(entity, attacker);
}
}

View File

@ -61,12 +61,7 @@ public class SwordsManager extends SkillManager {
}
}
if (getSkillLevel() >= AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.SWORDS_RUPTURE)) {
BleedTimerTask.add(target, getBleedTicks(), RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE));
}
else {
BleedTimerTask.add(target, getBleedTicks(), RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE));
}
BleedTimerTask.add(target, getRuptureBleedTicks(), RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE));
if (mcMMOPlayer.useChatNotifications()) {
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding");
@ -74,7 +69,7 @@ public class SwordsManager extends SkillManager {
}
}
public int getBleedTicks()
public int getRuptureBleedTicks()
{
int bleedTicks = 2 * RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE);