Fixed double death message bug.

This commit is contained in:
sigonasr2 2017-06-14 22:46:24 -05:00
parent abe745c0ac
commit 15e872803f
5 changed files with 237 additions and 230 deletions

Binary file not shown.

View File

@ -804,6 +804,7 @@ public class CustomDamage {
damage = preventPoisonDamageFromKilling(p, damage, reason);
if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) {
TwosideKeeper.log("Is a Slayer.", 2);
//PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (damage>2) {
damage=2;
@ -827,8 +828,8 @@ public class CustomDamage {
damage=0;
}
if (p.getHealth()-damage<0) {
p.damage(damage);
/*(if (p.getHealth()-damage<0) {
p.damage(p.getHealth());
final double DMG = damage;
Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, ()->{
if (p!=null && !p.isDead()) {
@ -837,7 +838,7 @@ public class CustomDamage {
TwosideKeeper.log("WARNING!! Player "+p.getName()+" was supposed to die! ["+TwosideKeeper.getServerTickTime()+"] Damage Taken: "+DMG+" from "+damagesource+",Reason: "+reasoning, 1);
}
}, 1);
}
}*/
//pd.customtitle.updateTitle(p);
pd.customtitle.updateCombatBar(p, getDamagerEntity(damager));

View File

@ -3707,6 +3707,7 @@ public class GenericFunctions {
boolean revived=false;
boolean fromRoom=false;
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
DebugUtils.showStackTrace();
if (p.getHealth()<=dmg || (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER && pd.slayermodehp<=dmg)) {
//This means we would die from this attack. Attempt to revive the player.
//Check all artifact armor for a perk.
@ -3801,7 +3802,6 @@ public class GenericFunctions {
if (!fromRoom) {
RandomlyBreakBaubles(p);
}
runServerHeartbeat.UpdatePlayerScoreboardAndHealth(p);
}
return revived;
}

View File

@ -127,7 +127,7 @@ public enum PlayerMode {
}
public static PlayerMode getPlayerMode(Player p) {
if (p!=null && p.isValid() && p.isOnline()) {
if (p!=null && p.isValid() && p.isOnline() && !p.isDead()) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (needsUpdating(pd)) {
if (Check_isSlayer(p)) {

View File

@ -481,7 +481,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static final int REJUVENATE_COOLDOWN=6000;
public static final int ASSASSINATE_COOLDOWN=200;
public static final int LIFESAVER_COOLDOWN=6000;
public static final int ARROWBARRAGE_COOLDOWN=200;
public static final int ARROWBARRAGE_COOLDOWN=2400;
public static final int SIPHON_COOLDOWN = 900;
public static final int MOCK_COOLDOWN = 400;
public static final int ICEWAND_COOLDOWN = 1200;
@ -7854,25 +7854,29 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
Player p = (Player)ev.getEntity();
};*/
CustomDamage.setupTrueDamage(ev);
ev.setDamage(DamageModifier.BASE, dmgdealt);
log("Damage from this event is "+dmgdealt,4);
EntityDamagedEvent event = new EntityDamagedEvent((LivingEntity)ev.getEntity(),null,dmgdealt,ev.getCause().name(),CustomDamage.TRUEDMG);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
dmgdealt=0;
ev.setDamage(DamageModifier.BASE,0d);
ev.setCancelled(true);
return;
} else {
if (!(ev.getEntity() instanceof Player && PlayerMode.getPlayerMode((Player)(ev.getEntity()))==PlayerMode.SLAYER)) {
if (dmgdealt < 1) {
ev.setDamage(DamageModifier.BASE,dmgdealt);
} else {
ev.setDamage(DamageModifier.BASE,1d);
((LivingEntity)ev.getEntity()).setHealth(Math.max(((LivingEntity)ev.getEntity()).getHealth() - (dmgdealt - 1d), 0.5));
}
if (dmgdealt>0) {
ev.setDamage(DamageModifier.BASE, dmgdealt);
log("Damage from this event is "+dmgdealt,4);
EntityDamagedEvent event = new EntityDamagedEvent((LivingEntity)ev.getEntity(),null,dmgdealt,ev.getCause().name(),CustomDamage.TRUEDMG);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
dmgdealt=0;
ev.setDamage(DamageModifier.BASE,0d);
ev.setCancelled(true);
return;
} else {
if (!(ev.getEntity() instanceof Player && PlayerMode.getPlayerMode((Player)(ev.getEntity()))==PlayerMode.SLAYER)) {
if (dmgdealt < 1) {
ev.setDamage(DamageModifier.BASE,dmgdealt);
} else {
ev.setDamage(DamageModifier.BASE,1d);
((LivingEntity)ev.getEntity()).setHealth(Math.max(((LivingEntity)ev.getEntity()).getHealth() - (dmgdealt - 1d), 0.5));
}
}
}
} else {
ev.setCancelled(true);
}
if (ev.getEntity() instanceof Player) {
Player p = (Player)ev.getEntity();
@ -11666,230 +11670,232 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static void setPlayerMaxHealth(Player p, Double ratio, boolean force) {
//Determine player max HP based on armor being worn.
if (EquipmentUpdated(p) || force) {
TwosideKeeper.log("Equipment updated. Checking health...", 5);
double hp=10; //Get the base max health.
double bonushp=0; //Bonus Health.
//Get all equips.
ItemStack[] equipment = {p.getInventory().getHelmet(),p.getInventory().getChestplate(),p.getInventory().getLeggings(),p.getInventory().getBoots()};
double maxdeduction=1;
long equiplooptime = System.nanoTime();
for (ItemStack equip : equipment) {
if (equip!=null) {
boolean is_block_form=false;
//Determine if the piece is block form.
//If this is an artifact armor, we totally override the base damage reduction.
if (GenericFunctions.isArmor(equip) && Artifact.isArtifact(equip)) {
//Let's change up the damage.
log("This is getting through",5);
/*int dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(equip.getType())).getHealthAmt(equip.getEnchantmentLevel(Enchantment.LUCK));
if (dmgval!=-1) {
hp += dmgval;
}*/
} else {
long time = System.nanoTime();
if (equip.hasItemMeta() &&
equip.getItemMeta().hasLore()) {
for (int j=0;j<equip.getItemMeta().getLore().size();j++) {
if (equip.getItemMeta().getLore().get(j).contains(ChatColor.GRAY+"Breaks Remaining:")) {
//This is a block version.
is_block_form=true;
break;
}
}
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Is Block Form Check", (int)(System.nanoTime()-time));time = System.nanoTime();
if (equip.getType().toString().contains("LEATHER")) {
//This is a leather piece.
bonushp+=ARMOR_LEATHER_HP;
} else if (equip.getType().toString().contains("IRON")) {
//This is an iron piece.
bonushp+=(is_block_form)?ARMOR_IRON2_HP:ARMOR_IRON_HP;
} else if (equip.getType().toString().contains("GOLD")) {
//This is a gold piece.
bonushp+=(is_block_form)?ARMOR_GOLD2_HP:ARMOR_GOLD_HP;
} else if (equip.getType().toString().contains("DIAMOND")) {
//This is a diamond piece.
bonushp+=(is_block_form)?ARMOR_DIAMOND2_HP:ARMOR_DIAMOND_HP;
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Increase Health for Block Armor", (int)(System.nanoTime()-time));time = System.nanoTime();
}
if (GenericFunctions.isArtifactEquip(equip)) {
//log("Add in "+GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip),5);
if (PlayerMode.getPlayerMode(p)==PlayerMode.RANGER) {
long time = System.nanoTime();
hp += (double)GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip,p)/2;
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Increase Health for Ranger Armor", (int)(System.nanoTime()-time));time = System.nanoTime();
if (!p.isDead() && p.getHealth()>0) {
if (EquipmentUpdated(p) || force) {
TwosideKeeper.log("Equipment updated. Checking health...", 5);
double hp=10; //Get the base max health.
double bonushp=0; //Bonus Health.
//Get all equips.
ItemStack[] equipment = {p.getInventory().getHelmet(),p.getInventory().getChestplate(),p.getInventory().getLeggings(),p.getInventory().getBoots()};
double maxdeduction=1;
long equiplooptime = System.nanoTime();
for (ItemStack equip : equipment) {
if (equip!=null) {
boolean is_block_form=false;
//Determine if the piece is block form.
//If this is an artifact armor, we totally override the base damage reduction.
if (GenericFunctions.isArmor(equip) && Artifact.isArtifact(equip)) {
//Let's change up the damage.
log("This is getting through",5);
/*int dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(equip.getType())).getHealthAmt(equip.getEnchantmentLevel(Enchantment.LUCK));
if (dmgval!=-1) {
hp += dmgval;
}*/
} else {
long time = System.nanoTime();
hp += (double)GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip,p);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Increase Health for Normal Armor", (int)(System.nanoTime()-time));time = System.nanoTime();
if (equip.hasItemMeta() &&
equip.getItemMeta().hasLore()) {
for (int j=0;j<equip.getItemMeta().getLore().size();j++) {
if (equip.getItemMeta().getLore().get(j).contains(ChatColor.GRAY+"Breaks Remaining:")) {
//This is a block version.
is_block_form=true;
break;
}
}
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Is Block Form Check", (int)(System.nanoTime()-time));time = System.nanoTime();
if (equip.getType().toString().contains("LEATHER")) {
//This is a leather piece.
bonushp+=ARMOR_LEATHER_HP;
} else if (equip.getType().toString().contains("IRON")) {
//This is an iron piece.
bonushp+=(is_block_form)?ARMOR_IRON2_HP:ARMOR_IRON_HP;
} else if (equip.getType().toString().contains("GOLD")) {
//This is a gold piece.
bonushp+=(is_block_form)?ARMOR_GOLD2_HP:ARMOR_GOLD_HP;
} else if (equip.getType().toString().contains("DIAMOND")) {
//This is a diamond piece.
bonushp+=(is_block_form)?ARMOR_DIAMOND2_HP:ARMOR_DIAMOND_HP;
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Increase Health for Block Armor", (int)(System.nanoTime()-time));time = System.nanoTime();
}
long time = System.nanoTime();
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)) {
maxdeduction /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)?2:1;
if (GenericFunctions.isArtifactEquip(equip)) {
//log("Add in "+GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip),5);
if (PlayerMode.getPlayerMode(p)==PlayerMode.RANGER) {
long time = System.nanoTime();
hp += (double)GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip,p)/2;
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Increase Health for Ranger Armor", (int)(System.nanoTime()-time));time = System.nanoTime();
} else {
long time = System.nanoTime();
hp += (double)GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip,p);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Increase Health for Normal Armor", (int)(System.nanoTime()-time));time = System.nanoTime();
}
long time = System.nanoTime();
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)) {
maxdeduction /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)?2:1;
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Decrease Health based on Greed", (int)(System.nanoTime()-time));time = System.nanoTime();
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Decrease Health based on Greed", (int)(System.nanoTime()-time));time = System.nanoTime();
}
}
}
TwosideKeeper.HeartbeatLogger.AddEntry("----]> Equipment Check", (int)(System.nanoTime()-equiplooptime));
TwosideKeeper.HeartbeatLogger.AddEntry("----]> Equipment Check", (int)(System.nanoTime()-equiplooptime));
long time = System.nanoTime();
//Check the hotbar for set equips.
bonushp+=ItemSet.GetTotalBaseAmount(p, ItemSet.GLADOMAIN);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Gladomain Set Increase", (int)(System.nanoTime()-time));time = System.nanoTime();
log("Health is now "+hp,5);
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())) {
maxdeduction /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())?2:1;
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Greed Reduction Main Hand", (int)(System.nanoTime()-time));time = System.nanoTime();
log("maxdeduction is "+maxdeduction,5);
if (PlayerMode.isDefender(p)) {
bonushp+=10;
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Defender HP and Regeneration", (int)(System.nanoTime()-time));time = System.nanoTime();
if (PlayerMode.isBarbarian(p)) {
double red = 1-CustomDamage.CalculateDamageReduction(1,p,null);
bonushp+=(red*2)*100;
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Barbarian HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
long time = System.nanoTime();
//Check the hotbar for set equips.
bonushp+=ItemSet.GetTotalBaseAmount(p, ItemSet.GLADOMAIN);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Gladomain Set Increase", (int)(System.nanoTime()-time));time = System.nanoTime();
log("Health is now "+hp,5);
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())) {
maxdeduction /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())?2:1;
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Greed Reduction Main Hand", (int)(System.nanoTime()-time));time = System.nanoTime();
log("maxdeduction is "+maxdeduction,5);
if (PlayerMode.isDefender(p)) {
bonushp+=10;
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Defender HP and Regeneration", (int)(System.nanoTime()-time));time = System.nanoTime();
if (PlayerMode.isBarbarian(p)) {
double red = 1-CustomDamage.CalculateDamageReduction(1,p,null);
bonushp+=(red*2)*100;
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Barbarian HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.GetTotalBaseAmount(p, ItemSet.DAWNTRACKER);
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DAWNTRACKER, 4, 4);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Dawntracker HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.SONGSTEEL, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Songsteel HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
/*
if (p.hasPotionEffect(PotionEffectType.ABSORPTION)) {
Collection<PotionEffect> player_effects = p.getActivePotionEffects();
for (int i=0;i<player_effects.size();i++) {
if (Iterables.get(player_effects, i).getType().equals(PotionEffectType.ABSORPTION)) {
hp += (Iterables.get(player_effects, i).getAmplifier()+1)*4;
bonushp+=ItemSet.GetTotalBaseAmount(p, ItemSet.DAWNTRACKER);
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DAWNTRACKER, 4, 4);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Dawntracker HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.SONGSTEEL, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Songsteel HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
/*
if (p.hasPotionEffect(PotionEffectType.ABSORPTION)) {
Collection<PotionEffect> player_effects = p.getActivePotionEffects();
for (int i=0;i<player_effects.size();i++) {
if (Iterables.get(player_effects, i).getType().equals(PotionEffectType.ABSORPTION)) {
hp += (Iterables.get(player_effects, i).getAmplifier()+1)*4;
}
}
}*/
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.ALIKAHN, 2, 2)+ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.ALIKAHN, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Alikahn HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.COMET, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Comet HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.CUPID, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Cupid HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DONNER, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Donner HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.RUDOLPH, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Rudolph HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.OLIVE, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Olive HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DASHER, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Dasher HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DANCER, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Dancer HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.PRANCER, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Prancer HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.VIXEN, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Vixen HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.BLITZEN, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Blitzen HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
/*bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.ALIKAHN, 4, 4)+
ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DARNYS, 4, 4)+
ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.LORASAADI, 4, 4)+
ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.JAMDAK, 4, 4);*/
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.SHARD, 4, 4);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Shard HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.GetTotalBaseAmount(p, ItemSet.SUSTENANCE);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Sustenance HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
if (ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.DAWNTRACKER,6) ||
ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.LEGION,6) ||
ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.PRIDE,6)) {
hp*=1.0+(0.1d*ItemSet.GetItemTier(p.getEquipment().getItemInMainHand()));
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Dawntracker bonus HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (!pd.had3pieceprotecterset && ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.PROTECTOR, 3)) {
//Update all other party members' health.
pd.had3pieceprotecterset=true;
for (Player pl : PartyManager.getPartyMembers(p)) {
if (!pl.equals(p)) {
setPlayerMaxHealth(pl,pl.getHealth()/pl.getMaxHealth(),true);
}
}
} else
if (pd.had3pieceprotecterset && !ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.PROTECTOR, 3)) {
//Update all other party members' health.
pd.had3pieceprotecterset=false;
for (Player pl : PartyManager.getPartyMembers(p)) {
if (!pl.equals(p)) {
setPlayerMaxHealth(pl,pl.getHealth()/pl.getMaxHealth(),true);
}
}
}
}*/
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.ALIKAHN, 2, 2)+ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.ALIKAHN, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Alikahn HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.COMET, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Comet HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.CUPID, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Cupid HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DONNER, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Donner HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.RUDOLPH, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Rudolph HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.OLIVE, 2, 2);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Olive HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DASHER, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Dasher HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DANCER, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Dancer HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.PRANCER, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Prancer HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.VIXEN, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Vixen HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.BLITZEN, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Blitzen HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
/*bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.ALIKAHN, 4, 4)+
ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DARNYS, 4, 4)+
ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.LORASAADI, 4, 4)+
ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.JAMDAK, 4, 4);*/
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.SHARD, 4, 4);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Shard HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
bonushp+=ItemSet.GetTotalBaseAmount(p, ItemSet.SUSTENANCE);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Sustenance HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
if (ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.DAWNTRACKER,6) ||
ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.LEGION,6) ||
ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.PRIDE,6)) {
hp*=1.0+(0.1d*ItemSet.GetItemTier(p.getEquipment().getItemInMainHand()));
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Dawntracker bonus HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (!pd.had3pieceprotecterset && ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.PROTECTOR, 3)) {
//Update all other party members' health.
pd.had3pieceprotecterset=true;
for (Player pl : PartyManager.getPartyMembers(p)) {
if (!pl.equals(p)) {
setPlayerMaxHealth(pl,pl.getHealth()/pl.getMaxHealth(),true);
if (pl!=null && p!=null && !pl.equals(p)) {
//TwosideKeeper.log("Found a Defender: "+pl.getName(), 0);
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(pl, ItemSet.PROTECTOR, 3, 3)*ItemSet.GetPlayerModeSpecificMult(p);
//TwosideKeeper.log("Increased health by: "+(ItemSet.TotalBaseAmountBasedOnSetBonusCount(pl, ItemSet.PROTECTOR, 3, 3)*ItemSet.GetPlayerModeSpecificMult(p))+" HP.", 0);
}
}
} else
if (pd.had3pieceprotecterset && !ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.PROTECTOR, 3)) {
//Update all other party members' health.
pd.had3pieceprotecterset=false;
for (Player pl : PartyManager.getPartyMembers(p)) {
if (!pl.equals(p)) {
setPlayerMaxHealth(pl,pl.getHealth()/pl.getMaxHealth(),true);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Protector Set Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
if (PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL) {
TwosideKeeper.log("Player Mode is Normal.", 5);
bonushp+=10;
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Adventurer Mode HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
hp+=bonushp*(PVP.isPvPing(p)?PlayerMode.isRanger(p)?0.25:0.5:1);
if (PlayerMode.isSlayer(p) && PVP.isPvPing(p)) {
hp/=2;
}
if (Buff.hasBuff(p, "DARKSUBMISSION")) {
Buff b = Buff.getBuff(p, "DARKSUBMISSION");
if (b.getAmplifier()>=50) {
hp*=0.5;
}
}
}
for (Player pl : PartyManager.getPartyMembers(p)) {
if (pl!=null && p!=null && !pl.equals(p)) {
//TwosideKeeper.log("Found a Defender: "+pl.getName(), 0);
bonushp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(pl, ItemSet.PROTECTOR, 3, 3)*ItemSet.GetPlayerModeSpecificMult(p);
//TwosideKeeper.log("Increased health by: "+(ItemSet.TotalBaseAmountBasedOnSetBonusCount(pl, ItemSet.PROTECTOR, 3, 3)*ItemSet.GetPlayerModeSpecificMult(p))+" HP.", 0);
hp*=maxdeduction;
p.resetMaxHealth();
if (p.getHealth()>=hp) {
p.setHealth(hp);
}
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Protector Set Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
if (PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL) {
TwosideKeeper.log("Player Mode is Normal.", 5);
bonushp+=10;
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Adventurer Mode HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
hp+=bonushp*(PVP.isPvPing(p)?PlayerMode.isRanger(p)?0.25:0.5:1);
if (PlayerMode.isSlayer(p) && PVP.isPvPing(p)) {
hp/=2;
}
if (Buff.hasBuff(p, "DARKSUBMISSION")) {
Buff b = Buff.getBuff(p, "DARKSUBMISSION");
if (b.getAmplifier()>=50) {
hp*=0.5;
}
}
hp*=maxdeduction;
p.resetMaxHealth();
if (p.getHealth()>=hp) {
p.setHealth(hp);
}
p.setMaxHealth(hp);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Reset Health", (int)(System.nanoTime()-time));time = System.nanoTime();
if (!p.isDead()) {
if (ratio==null) {
p.setHealth(p.getHealth());
} else {
//TwosideKeeper.log("Hp is "+hp+". Ratio is "+ratio+". Setting to "+, loglv);
p.setHealth(ratio*p.getMaxHealth());
}
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Set Health Ratio", (int)(System.nanoTime()-time));time = System.nanoTime();
if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) {
double slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp;
if (ratio==null) {
if (slayermodehp>p.getMaxHealth()) {
slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp = p.getMaxHealth();
p.setMaxHealth(hp);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Reset Health", (int)(System.nanoTime()-time));time = System.nanoTime();
if (!p.isDead()) {
if (ratio==null) {
p.setHealth(p.getHealth());
} else {
//TwosideKeeper.log("Hp is "+hp+". Ratio is "+ratio+". Setting to "+, loglv);
p.setHealth(ratio*p.getMaxHealth());
}
} else {
slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp = ratio*p.getMaxHealth();
}
p.setHealth(slayermodehp);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Set Health Ratio", (int)(System.nanoTime()-time));time = System.nanoTime();
if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) {
double slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp;
if (ratio==null) {
if (slayermodehp>p.getMaxHealth()) {
slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp = p.getMaxHealth();
}
} else {
slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp = ratio*p.getMaxHealth();
}
p.setHealth(slayermodehp);
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Apply Slayer Mode HP", (int)(System.nanoTime()-time));time = System.nanoTime();
p.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(hp);
p.setHealthScaled(false);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Final Fix", (int)(System.nanoTime()-time));time = System.nanoTime();
runServerHeartbeat.UpdatePlayerScoreboardAndHealth(p);
}
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Apply Slayer Mode HP", (int)(System.nanoTime()-time));time = System.nanoTime();
p.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(hp);
p.setHealthScaled(false);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Final Fix", (int)(System.nanoTime()-time));time = System.nanoTime();
runServerHeartbeat.UpdatePlayerScoreboardAndHealth(p);
}
}