+>Test Dummies have been scattered throughout various areas in towns.

You can use these to freely test DPS. They will announce DPS results
after you stop hitting them.
+>Fixed Debilitation mode poison application issues. No longer resets
the level of poison on a target when you miss a headshot on a high
poison stack target.
+>Poison deals a true damage DoT based on number of poison stacks every
second. Poison damage ticks are twice as slow on Undead monsters.
(Zombies, Skeletons, Wither)
+>The healthbar of Elite monsters and boss monsters now appears when you
are nearby them.
>Removed the reliance on Minecraft's poison system and debuff system to
determine if a monster is poisoned or not.
This commit is contained in:
sigonasr2 2017-04-18 21:03:23 -05:00
parent ec0fb8e22b
commit 46b7cb9779
15 changed files with 413 additions and 39 deletions

Binary file not shown.

View File

@ -15,6 +15,14 @@ import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public class ActionBarBuffUpdater{ public class ActionBarBuffUpdater{
/*
* LIST OF BUFFS:
* basename / icon string
*
* Poison ChatColor.YELLOW+""
* DeathMark ChatColor.DARK_RED+""
*/
public static String getActionBarPrefix(LivingEntity p) { public static String getActionBarPrefix(LivingEntity p) {
StringBuilder actionbardisplay = new StringBuilder(""); StringBuilder actionbardisplay = new StringBuilder("");
for (PotionEffect pe : p.getActivePotionEffects()) { for (PotionEffect pe : p.getActivePotionEffects()) {
@ -199,11 +207,11 @@ public class ActionBarBuffUpdater{
effectString.append(ChatColor.WHITE); effectString.append(ChatColor.WHITE);
effectString.append(""); effectString.append("");
} else } else
if (pet.equals(PotionEffectType.POISON) || /*if (pet.equals(PotionEffectType.POISON) ||
(pet.equals(PotionEffectType.BLINDNESS) && (p instanceof LivingEntity && !(p instanceof Player)))) { (pet.equals(PotionEffectType.BLINDNESS) && (p instanceof LivingEntity && !(p instanceof Player)))) {
effectString.append(ChatColor.YELLOW); effectString.append(ChatColor.YELLOW);
effectString.append(""); effectString.append("");
} else } else*/
/*if ((pet.equals(PotionEffectType.UNLUCK) && (p instanceof LivingEntity && !(p instanceof Player)))) { /*if ((pet.equals(PotionEffectType.UNLUCK) && (p instanceof LivingEntity && !(p instanceof Player)))) {
effectString.append(ChatColor.DARK_RED); effectString.append(ChatColor.DARK_RED);
effectString.append(""); effectString.append("");

View File

@ -92,14 +92,17 @@ public class EliteZombie extends EliteMonster{
protected void createBossHealthbar() { protected void createBossHealthbar() {
List<Player> currentplayers = bar.getPlayers(); List<Player> currentplayers = bar.getPlayers();
for (int i=0;i<currentplayers.size();i++) { /*for (int i=0;i<currentplayers.size();i++) {
if (!targetlist.contains(currentplayers.get(i))) { if (!targetlist.contains(currentplayers.get(i))) {
bar.removePlayer(currentplayers.get(i)); bar.removePlayer(currentplayers.get(i));
willpower_bar.removePlayer(currentplayers.get(i)); willpower_bar.removePlayer(currentplayers.get(i));
} }
} }*/
bar.removeAll();
willpower_bar.removeAll();
bar.setProgress(m.getHealth()/m.getMaxHealth()); bar.setProgress(m.getHealth()/m.getMaxHealth());
bar.setTitle(GenericFunctions.getDisplayName(m) + ((m.getTarget()!=null && (m.getTarget() instanceof Player))?(ChatColor.DARK_AQUA+" "+arrow+" "+ChatColor.YELLOW+((Player)m.getTarget()).getName()):"")); bar.setTitle(GenericFunctions.getDisplayName(m) + ((m.getTarget()!=null && (m.getTarget() instanceof Player))?(ChatColor.DARK_AQUA+" "+arrow+" "+ChatColor.YELLOW+((Player)m.getTarget()).getName()):""));
displayHealthbarToNearbyPlayers();
for (int i=0;i<targetlist.size();i++) { for (int i=0;i<targetlist.size();i++) {
if (!currentplayers.contains(targetlist.get(i))) { if (!currentplayers.contains(targetlist.get(i))) {
bar.addPlayer(targetlist.get(i)); bar.addPlayer(targetlist.get(i));

View File

@ -5,6 +5,7 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.boss.BarColor; import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag; import org.bukkit.boss.BarFlag;
@ -150,13 +151,15 @@ public class BossMonster {
protected void createBossHealthbar() { protected void createBossHealthbar() {
List<Player> currentplayers = bar.getPlayers(); List<Player> currentplayers = bar.getPlayers();
for (int i=0;i<currentplayers.size();i++) { /*for (int i=0;i<currentplayers.size();i++) {
if (!targetlist.contains(currentplayers.get(i))) { if (!targetlist.contains(currentplayers.get(i))) {
bar.removePlayer(currentplayers.get(i)); bar.removePlayer(currentplayers.get(i));
} }
} }*/
bar.removeAll();
bar.setProgress(m.getHealth()/m.getMaxHealth()); bar.setProgress(m.getHealth()/m.getMaxHealth());
bar.setTitle(GenericFunctions.getDisplayName(m) + ((m instanceof Monster && ((Monster)m).getTarget()!=null && (((Monster)m).getTarget() instanceof Player))?(ChatColor.DARK_AQUA+" "+arrow+" "+ChatColor.YELLOW+((Player)((Monster)m).getTarget()).getName()):"")); bar.setTitle(GenericFunctions.getDisplayName(m) + ((m instanceof Monster && ((Monster)m).getTarget()!=null && (((Monster)m).getTarget() instanceof Player))?(ChatColor.DARK_AQUA+" "+arrow+" "+ChatColor.YELLOW+((Player)((Monster)m).getTarget()).getName()):""));
displayHealthbarToNearbyPlayers();
for (int i=0;i<targetlist.size();i++) { for (int i=0;i<targetlist.size();i++) {
if (!currentplayers.contains(targetlist.get(i))) { if (!currentplayers.contains(targetlist.get(i))) {
bar.addPlayer(targetlist.get(i)); bar.addPlayer(targetlist.get(i));
@ -164,4 +167,12 @@ public class BossMonster {
} }
} }
private void displayHealthbarToNearbyPlayers() {
for (Player p : Bukkit.getOnlinePlayers()) {
if (m.getLocation().distanceSquared(p.getLocation())<=2500) {
bar.addPlayer(p);
}
}
}
} }

View File

@ -16,13 +16,15 @@ public class Buff {
private int level; private int level;
private Color col; private Color col;
private String icon; private String icon;
private boolean isGoodBuff; //If false, it's a debuff.
public Buff(String displayName, long duration, int amplifier, Color buffcolor, String icon) { public Buff(String displayName, long duration, int amplifier, Color buffcolor, String icon, boolean isGoodBuff) {
this.displayName=displayName; this.displayName=displayName;
this.expireTime=TwosideKeeper.getServerTickTime()+duration; this.expireTime=TwosideKeeper.getServerTickTime()+duration;
this.level=amplifier; this.level=amplifier;
this.col=buffcolor; this.col=buffcolor;
this.icon=icon; this.icon=icon;
this.isGoodBuff=isGoodBuff;
} }
public static boolean hasBuffInHashMap(LivingEntity l, String name) { public static boolean hasBuffInHashMap(LivingEntity l, String name) {
@ -109,10 +111,44 @@ public class Buff {
if (l instanceof Player) { if (l instanceof Player) {
Player p = (Player)l; Player p = (Player)l;
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
int oldlv = 0;
long oldduration = 0;
if (hasBuff(p,name)) {
oldlv = pd.buffs.get(name).getAmplifier();
oldduration = pd.buffs.get(name).getRemainingBuffTime();
} else {
pd.buffs.put(name, buff); pd.buffs.put(name, buff);
return;
}
if (buff.getAmplifier()>=oldlv) {
if (buff.getAmplifier()==oldlv) { //Check if duration is longer or same.
if (buff.getRemainingBuffTime()>=oldduration) {
pd.buffs.put(name, buff);
}
} else {
pd.buffs.put(name, buff); //If Buff level is greater than old level.
}
}
} else { } else {
LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l);
int oldlv = 0;
long oldduration = 0;
if (hasBuff(l,name)) {
oldlv = les.buffs.get(name).getAmplifier();
oldduration = les.buffs.get(name).getRemainingBuffTime();
} else {
les.buffs.put(name, buff); les.buffs.put(name, buff);
return;
}
if (buff.getAmplifier()>=oldlv) {
if (buff.getAmplifier()==oldlv) { //Check if duration is longer or same.
if (buff.getRemainingBuffTime()>=oldduration) {
les.buffs.put(name, buff);
}
} else {
les.buffs.put(name, buff); //If Buff level is greater than old level.
}
}
} }
} }
public static void removeBuff(LivingEntity l, String name) { public static void removeBuff(LivingEntity l, String name) {
@ -148,6 +184,13 @@ public class Buff {
expireTime=TwosideKeeper.getServerTickTime()+duration; expireTime=TwosideKeeper.getServerTickTime()+duration;
} }
public boolean isGoodBuff() {
return isGoodBuff;
}
public boolean isDebuff() {
return !isGoodBuff;
}
private static boolean hasBuffExpired(Buff b) { private static boolean hasBuffExpired(Buff b) {
if (b.expireTime<TwosideKeeper.getServerTickTime()) { if (b.expireTime<TwosideKeeper.getServerTickTime()) {
return false; return false;

View File

@ -9,6 +9,7 @@ import java.util.UUID;
import org.bukkit.Achievement; import org.bukkit.Achievement;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Difficulty; import org.bukkit.Difficulty;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -38,7 +39,9 @@ import org.bukkit.entity.Snowball;
import org.bukkit.entity.SpectralArrow; import org.bukkit.entity.SpectralArrow;
import org.bukkit.entity.Spider; import org.bukkit.entity.Spider;
import org.bukkit.entity.TippedArrow; import org.bukkit.entity.TippedArrow;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Wither; import org.bukkit.entity.Wither;
import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -69,6 +72,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.Utils.EntityUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.IndicatorType; import sig.plugin.TwosideKeeper.HelperStructures.Utils.IndicatorType;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils;
import sig.plugin.TwosideKeeper.HolidayEvents.Christmas; import sig.plugin.TwosideKeeper.HolidayEvents.Christmas;
import sig.plugin.TwosideKeeper.Monster.Dummy;
import sig.plugin.TwosideKeeper.Monster.HellfireGhast; import sig.plugin.TwosideKeeper.Monster.HellfireGhast;
import sig.plugin.TwosideKeeper.Monster.HellfireSpider; import sig.plugin.TwosideKeeper.Monster.HellfireSpider;
@ -119,6 +123,7 @@ public class CustomDamage {
* &nbsp;&nbsp;&nbsp;&nbsp;CRITICALSTRIKE - Force a Critical Strike.<br> * &nbsp;&nbsp;&nbsp;&nbsp;CRITICALSTRIKE - Force a Critical Strike.<br>
* &nbsp;&nbsp;&nbsp;&nbsp;IGNOREDODGE - Ignores all Dodge and invulnerability checks.<br> * &nbsp;&nbsp;&nbsp;&nbsp;IGNOREDODGE - Ignores all Dodge and invulnerability checks.<br>
* &nbsp;&nbsp;&nbsp;&nbsp;TRUEDMG - Ignores all additional calculations/reductions, applying the damage directly.<br> * &nbsp;&nbsp;&nbsp;&nbsp;TRUEDMG - Ignores all additional calculations/reductions, applying the damage directly.<br>
* &nbsp;&nbsp;&nbsp;&nbsp;IGNORE_DAMAGE_TICK - Ignores the fact the entity is in an invulnerable state and applies the damage.<br>
* <br><b>Combining flags example:</b> CRITICALSTRIKE|IGNOREDODGE (Force a critical strike AND ignore invulnerability check) * <br><b>Combining flags example:</b> CRITICALSTRIKE|IGNOREDODGE (Force a critical strike AND ignore invulnerability check)
* @return Whether or not this attack actually was applied. Returns false if it was dodged, nodamageticks, cancelled, etc. * @return Whether or not this attack actually was applied. Returns false if it was dodged, nodamageticks, cancelled, etc.
*/ */
@ -439,11 +444,12 @@ public class CustomDamage {
target.setMaximumNoDamageTicks(0); target.setMaximumNoDamageTicks(0);
damage = subtractAbsorptionHearts(damage,target); damage = subtractAbsorptionHearts(damage,target);
damage = applyOnHitEffects(damage,damager,target,weapon,reason,flags); damage = applyOnHitEffects(damage,damager,target,weapon,reason,flags);
EntityUtils.applyDamageIndicator(target, damage, (isFlagSet(flags,IS_CRIT))?IndicatorType.CRIT:IndicatorType.REGULAR);
if (getDamagerEntity(damager) instanceof Player) { //Player dealing damage to living entities does a custom damage modifier. if (getDamagerEntity(damager) instanceof Player) { //Player dealing damage to living entities does a custom damage modifier.
TwosideKeeper.log("Dealing "+damage+" damage.", 5); TwosideKeeper.log("Dealing "+damage+" damage.", 5);
TwosideKeeper.log("Sending out "+(damage+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER)+" damage.",5); TwosideKeeper.log("Sending out "+(damage+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER)+" damage.",5);
target.damage(damage+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER,getDamagerEntity(damager)); target.damage(damage+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER,getDamagerEntity(damager));
PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)getDamagerEntity(damager));
EntityUtils.applyDamageIndicator(target, damage, (isFlagSet(pd.lasthitproperties,IS_CRIT))?IndicatorType.CRIT:IndicatorType.REGULAR);
} else } else
if (!(getDamagerEntity(damager) instanceof LivingEntity) || (damage!=0 && isFlagSet(flags,SPECIALATTACK))) { if (!(getDamagerEntity(damager) instanceof LivingEntity) || (damage!=0 && isFlagSet(flags,SPECIALATTACK))) {
//TwosideKeeper.log("Sending out "+damage+" damage.",2); //TwosideKeeper.log("Sending out "+damage+" damage.",2);
@ -451,6 +457,10 @@ public class CustomDamage {
aPlugin.API.sendEntityHurtAnimation(target); aPlugin.API.sendEntityHurtAnimation(target);
} }
if (damager==null && reason.equalsIgnoreCase("POISON") && !(target instanceof Player)) {
EntityUtils.applyDamageIndicator(target, damage, IndicatorType.DOT);
}
if (target instanceof Player) { //Update player health whenever hit. if (target instanceof Player) { //Update player health whenever hit.
Player p = (Player)target; Player p = (Player)target;
TwosideKeeper.setPlayerMaxHealth(p); TwosideKeeper.setPlayerMaxHealth(p);
@ -586,7 +596,8 @@ public class CustomDamage {
target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,20*5,slownesslv)); target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,20*5,slownesslv));
} }
if (a.hasMetadata("POISON_ARR")) { if (a.hasMetadata("POISON_ARR")) {
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,20*20,0)); //target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,20*20,0));
Buff.addBuff(target,"Poison",new Buff("Poison",20*20,1,Color.YELLOW,ChatColor.YELLOW+"",false));
} }
} }
provokeMonster(target,p,weapon); provokeMonster(target,p,weapon);
@ -684,11 +695,12 @@ public class CustomDamage {
} }
if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.MOONSHADOW, 2)) { if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.MOONSHADOW, 2)) {
int poisonlv = (int)ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.MOONSHADOW, 2, 2); int poisonlv = (int)ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.MOONSHADOW, 2, 2);
if (target.hasPotionEffect(PotionEffectType.BLINDNESS) && GenericFunctions.getPotionEffectLevel(PotionEffectType.BLINDNESS, target)<=poisonlv) { /*if (target.hasPotionEffect(PotionEffectType.BLINDNESS) && GenericFunctions.getPotionEffectLevel(PotionEffectType.BLINDNESS, target)<=poisonlv) {
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.BLINDNESS, 20*15, (int)poisonlv, target); GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.BLINDNESS, 20*15, (int)poisonlv, target);
} else { } else {
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.BLINDNESS, 20*15, (int)poisonlv, target, true); GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.BLINDNESS, 20*15, (int)poisonlv, target, true);
} }*/
Buff.addBuff(target, "Poison", new Buff("Poison",20*15,(int)poisonlv,Color.YELLOW,ChatColor.YELLOW+"",false));
} }
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin,new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin,new Runnable() {
@ -1239,11 +1251,28 @@ public class CustomDamage {
} }
if (target instanceof Wither) { if (target instanceof Wither) {
Wither w = (Wither)target; Wither w = (Wither)target;
for (UUID id : TwosideKeeper.custommonsters.keySet()) { /*for (UUID id : TwosideKeeper.custommonsters.keySet()) {
if (id.equals(w.getUniqueId())) { if (id.equals(w.getUniqueId())) {
sig.plugin.TwosideKeeper.Monster.Wither wi = (sig.plugin.TwosideKeeper.Monster.Wither)TwosideKeeper.custommonsters.get(id); sig.plugin.TwosideKeeper.Monster.Wither wi = (sig.plugin.TwosideKeeper.Monster.Wither)TwosideKeeper.custommonsters.get(id);
wi.runHitEvent(p, dmg); wi.runHitEvent(p, dmg);
} }
}*/
if (TwosideKeeper.custommonsters.containsKey(w.getUniqueId())) {
sig.plugin.TwosideKeeper.Monster.Wither wi = (sig.plugin.TwosideKeeper.Monster.Wither)TwosideKeeper.custommonsters.get(w.getUniqueId());
wi.runHitEvent(p, dmg);
}
}
if (target instanceof Villager) {
Villager v = (Villager)target;
/*for (UUID id : TwosideKeeper.custommonsters.keySet()) {
if (id.equals(v.getUniqueId())) {
sig.plugin.TwosideKeeper.Monster.Wither wi = (sig.plugin.TwosideKeeper.Monster.Wither)TwosideKeeper.custommonsters.get(id);
wi.runHitEvent(p, dmg);
}
}*/
if (TwosideKeeper.custommonsters.containsKey(v.getUniqueId())) {
Dummy dm = (Dummy)TwosideKeeper.custommonsters.get(v.getUniqueId());
dm.customHitHandler(p, dmg);
} }
} }
} }
@ -2515,7 +2544,8 @@ public class CustomDamage {
} }
if (PlayerMode.isRanger(p) && GenericFunctions.getBowMode(p)==BowMode.DEBILITATION) { if (PlayerMode.isRanger(p) && GenericFunctions.getBowMode(p)==BowMode.DEBILITATION) {
if (m.hasPotionEffect(PotionEffectType.BLINDNESS) && isheadshot) { if (isheadshot) {
/*if (m.hasPotionEffect(PotionEffectType.BLINDNESS)) {
//Add to the current stack of BLINDNESS. //Add to the current stack of BLINDNESS.
for (PotionEffect pe : m.getActivePotionEffects()) { for (PotionEffect pe : m.getActivePotionEffects()) {
if (pe.getType().equals(PotionEffectType.BLINDNESS)) { if (pe.getType().equals(PotionEffectType.BLINDNESS)) {
@ -2531,6 +2561,18 @@ public class CustomDamage {
m.removePotionEffect(PotionEffectType.BLINDNESS); m.removePotionEffect(PotionEffectType.BLINDNESS);
m.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,400,0)); m.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,400,0));
SoundUtils.playLocalSound(p, Sound.ENTITY_RABBIT_ATTACK, 0.1f, 0.1f); SoundUtils.playLocalSound(p, Sound.ENTITY_RABBIT_ATTACK, 0.1f, 0.1f);
}*/
if (Buff.hasBuff(target, "Poison")) {
int oldlv = Buff.getBuff(target, "Poison").getAmplifier();
SoundUtils.playLocalSound(p, Sound.ENTITY_RABBIT_ATTACK, 0.1f, 0.1f+((oldlv+1)*0.5f));
Buff.addBuff(target, "Poison", new Buff("Poison",20*20,++oldlv,Color.YELLOW,ChatColor.YELLOW+"",false));
} else {
SoundUtils.playLocalSound(p, Sound.ENTITY_RABBIT_ATTACK, 0.1f, 0.1f);
Buff.addBuff(target, "Poison", new Buff("Poison",20*20,1,Color.YELLOW,ChatColor.YELLOW+"",false));
}
} else {
SoundUtils.playLocalSound(p, Sound.ENTITY_RABBIT_ATTACK, 0.1f, 0.1f);
Buff.addBuff(target, "Poison", new Buff("Poison",20*20,1,Color.YELLOW,ChatColor.YELLOW+"",false));
} }
} }
} }
@ -2650,6 +2692,21 @@ public class CustomDamage {
return critchance; return critchance;
} }
//0.0-1.0. 0% meaning no resistance. 100% meaning full resistance.
public static double getPoisonResistance(LivingEntity target) {
double resist=0.0d;
if (target instanceof Player) {
//Nothing here yet.
} else {
if (target instanceof Zombie ||
target instanceof Skeleton ||
target instanceof Wither) {
resist+=0.5d;
}
}
return resist;
}
//Chance is between 0.0-1.0. 1.0 is 100%. //Chance is between 0.0-1.0. 1.0 is 100%.
static boolean isCriticalStrike(double chance) { static boolean isCriticalStrike(double chance) {
return isCriticalStrike(chance,false); return isCriticalStrike(chance,false);
@ -2684,8 +2741,11 @@ public class CustomDamage {
if (target.hasPotionEffect(PotionEffectType.POISON)) { if (target.hasPotionEffect(PotionEffectType.POISON)) {
mult += (GenericFunctions.getPotionEffectLevel(PotionEffectType.POISON, target)+1)*0.5; mult += (GenericFunctions.getPotionEffectLevel(PotionEffectType.POISON, target)+1)*0.5;
} }
if (target.hasPotionEffect(PotionEffectType.BLINDNESS)) { /*if (target.hasPotionEffect(PotionEffectType.BLINDNESS)) {
mult += (GenericFunctions.getPotionEffectLevel(PotionEffectType.BLINDNESS, target)+1)*0.5; mult += (GenericFunctions.getPotionEffectLevel(PotionEffectType.BLINDNESS, target)+1)*0.5;
}*/
if (Buff.hasBuff(target, "Poison")) {
mult += Buff.getBuff(target, "Poison").getAmplifier()*0.5;
} }
} }
TwosideKeeper.log("Mult is "+mult, 5); TwosideKeeper.log("Mult is "+mult, 5);

View File

@ -4,6 +4,7 @@ import java.io.File;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
public class CustomMonster { public class CustomMonster {
protected LivingEntity m; protected LivingEntity m;
@ -34,7 +35,18 @@ public class CustomMonster {
} }
} }
public static boolean recognizeMonsterConditions(LivingEntity m) {
return false;
}
public void runTick() { public void runTick() {
} }
public void customHitHandler() {
}
public void customHitHandler(Player p, double dmg) {
}
} }

View File

@ -112,11 +112,13 @@ public class EliteMonster {
} }
protected void createBossHealthbar() { protected void createBossHealthbar() {
if (m instanceof Wither || m instanceof EnderDragon) { /*if (m instanceof Wither || m instanceof EnderDragon) {
bar.removeAll(); bar.removeAll();
willpower_bar.removeAll(); willpower_bar.removeAll();
return; return;
} }*/
bar.removeAll();
willpower_bar.removeAll();
List<Player> currentplayers = bar.getPlayers(); List<Player> currentplayers = bar.getPlayers();
for (int i=0;i<currentplayers.size();i++) { for (int i=0;i<currentplayers.size();i++) {
if (!targetlist.contains(currentplayers.get(i))) { if (!targetlist.contains(currentplayers.get(i))) {
@ -126,6 +128,9 @@ public class EliteMonster {
} }
bar.setProgress(m.getHealth()/m.getMaxHealth()); bar.setProgress(m.getHealth()/m.getMaxHealth());
bar.setTitle(GenericFunctions.getDisplayName(m) + ((m.getTarget()!=null && (m.getTarget() instanceof Player))?(ChatColor.DARK_AQUA+" "+arrow+" "+ChatColor.YELLOW+((Player)m.getTarget()).getName()):"")); bar.setTitle(GenericFunctions.getDisplayName(m) + ((m.getTarget()!=null && (m.getTarget() instanceof Player))?(ChatColor.DARK_AQUA+" "+arrow+" "+ChatColor.YELLOW+((Player)m.getTarget()).getName()):""));
if (!(m instanceof Wither || m instanceof EnderDragon)) {
displayHealthbarToNearbyPlayers();
}
for (int i=0;i<targetlist.size();i++) { for (int i=0;i<targetlist.size();i++) {
if (!currentplayers.contains(targetlist.get(i))) { if (!currentplayers.contains(targetlist.get(i))) {
bar.addPlayer(targetlist.get(i)); bar.addPlayer(targetlist.get(i));
@ -133,6 +138,14 @@ public class EliteMonster {
} }
} }
protected void displayHealthbarToNearbyPlayers() {
for (Player p : Bukkit.getOnlinePlayers()) {
if (m.getLocation().distanceSquared(p.getLocation())<=2500) {
bar.addPlayer(p);
}
}
}
protected void resetToSpawn() { protected void resetToSpawn() {
if (!leaping && targetlist.size()==0 && m.getLocation().getWorld().equals(myspawn.getWorld()) && m.getLocation().distanceSquared(myspawn)>81) { if (!leaping && targetlist.size()==0 && m.getLocation().getWorld().equals(myspawn.getWorld()) && m.getLocation().distanceSquared(myspawn)>81) {
while (myspawn.getBlock().getRelative(0, -1, 0).getType()==Material.AIR && myspawn.getY()>1) { while (myspawn.getBlock().getRelative(0, -1, 0).getType()==Material.AIR && myspawn.getY()>1) {

View File

@ -2538,7 +2538,7 @@ public class GenericFunctions {
deathmarkBuff.refreshDuration(99); deathmarkBuff.refreshDuration(99);
stackamt = deathmarkBuff.getAmplifier(); stackamt = deathmarkBuff.getAmplifier();
} else { } else {
buffdata.put("DeathMark", new Buff("Death Mark",99,1,org.bukkit.Color.MAROON,ChatColor.DARK_RED+"")); buffdata.put("DeathMark", new Buff("Death Mark",99,1,org.bukkit.Color.MAROON,ChatColor.DARK_RED+"",false));
stackamt = 1; stackamt = 1;
} }
RefreshBuffColor(ent, stackamt); RefreshBuffColor(ent, stackamt);
@ -5076,7 +5076,18 @@ public class GenericFunctions {
} }
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SLOW, 20*15, poisonlv, ent); GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SLOW, 20*15, poisonlv, ent);
} }
if (ent.hasPotionEffect(PotionEffectType.BLINDNESS)) { if (Buff.hasBuff(ent, "Poison")) {
Buff b = Buff.getBuff(ent, "Poison");
int poisonlv = b.getAmplifier();
long poisondur = b.getRemainingBuffTime();
totalpoisonlv+=poisonlv+1;
if (poisondur<20*15) {
//GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.POISON, 20*15, poisonlv, ent, true);
b.refreshDuration(20*15);
}
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SLOW, 20*15, poisonlv, ent);
}
/*if (ent.hasPotionEffect(PotionEffectType.BLINDNESS)) {
int poisonlv = GenericFunctions.getPotionEffectLevel(PotionEffectType.BLINDNESS, ent); int poisonlv = GenericFunctions.getPotionEffectLevel(PotionEffectType.BLINDNESS, ent);
int poisondur = GenericFunctions.getPotionEffectDuration(PotionEffectType.BLINDNESS, ent); int poisondur = GenericFunctions.getPotionEffectDuration(PotionEffectType.BLINDNESS, ent);
totalpoisonlv+=poisonlv+1; totalpoisonlv+=poisonlv+1;
@ -5084,7 +5095,7 @@ public class GenericFunctions {
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.BLINDNESS, 20*15, poisonlv, ent, true); GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.BLINDNESS, 20*15, poisonlv, ent, true);
} }
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SLOW, 20*15, poisonlv, ent); GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.SLOW, 20*15, poisonlv, ent);
} }*/
CustomDamage.ApplyDamage(totalpoisonlv*10, p, ent, null, "Siphon", CustomDamage.TRUEDMG|CustomDamage.IGNOREDODGE|CustomDamage.IGNORE_DAMAGE_TICK); CustomDamage.ApplyDamage(totalpoisonlv*10, p, ent, null, "Siphon", CustomDamage.TRUEDMG|CustomDamage.IGNOREDODGE|CustomDamage.IGNORE_DAMAGE_TICK);
} }
CustomDamage.setAbsorptionHearts(p, CustomDamage.getAbsorptionHearts(p)+totalpoisonstacks*4); CustomDamage.setAbsorptionHearts(p, CustomDamage.getAbsorptionHearts(p)+totalpoisonstacks*4);

View File

@ -0,0 +1,20 @@
package sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
public class MovementModifier implements Runnable{
LivingEntity l;
Vector v;
public MovementModifier(LivingEntity l, Vector newvel) {
this.l=l;
this.v=newvel;
}
@Override
public void run() {
l.setVelocity(v);
}
}

View File

@ -29,6 +29,7 @@ public class LivingEntityStructure {
public boolean hasRallied=false; public boolean hasRallied=false;
public HashMap<String,Buff> buffs = new HashMap<String,Buff>(); public HashMap<String,Buff> buffs = new HashMap<String,Buff>();
public long lastpotionparticles=0; public long lastpotionparticles=0;
public long lastPoisonTick=0;
public LivingEntityStructure(LivingEntity m) { public LivingEntityStructure(LivingEntity m) {
target=null; target=null;

View File

@ -0,0 +1,104 @@
package sig.plugin.TwosideKeeper.Monster;
import java.util.List;
import java.text.DecimalFormat;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.util.Vector;
import sig.plugin.TwosideKeeper.CustomMonster;
import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.Classes.MovementModifier;
public class Dummy extends CustomMonster{
final static int maxhp = 1000000;
double dmgdealt = 0;
long timeStartedHitting = 0;
long lastHitTime = 0;
int numbOfHits = 0;
Location spawnLoc;
List<Player> playerHitList = new ArrayList<Player>();
public Dummy(LivingEntity m) {
super(m);
m.setCustomName(ChatColor.MAGIC+" "+ChatColor.RESET+"Test Dummy"+ChatColor.MAGIC+" ");
m.setCustomNameVisible(true);
this.spawnLoc = m.getLocation();
//m.setCollidable(false);
m.setMaxHealth(maxhp);
m.setHealth(m.getMaxHealth());
m.setRemoveWhenFarAway(false);
if (m instanceof Villager) {
Villager v = (Villager)m;
v.setAdult();
v.setProfession(Profession.PRIEST);
}
}
public static boolean isDummy(LivingEntity m) {
boolean isDummy = (m.getMaxHealth()==maxhp && m instanceof Villager && ((Villager)m).getProfession()==Profession.PRIEST);
return isDummy;
}
public void runTick() {
if (numbOfHits>0 && lastHitTime+20*5<=TwosideKeeper.getServerTickTime()) {
for (Player p : playerHitList) {
p.sendMessage(getDamageOutput());
}
numbOfHits=0;
}
m.setHealth(maxhp);
m.teleport(spawnLoc);
Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, new MovementModifier(m,new Vector(0,0,0)), 1);
}
private String getDamageOutput() {
StringBuilder sb = new StringBuilder();
sb.append(m.getCustomName());
sb.append(" Results:");
sb.append("\n");
sb.append(ChatColor.GREEN);
sb.append("Total Damage: ");
DecimalFormat df = new DecimalFormat("0.00");
sb.append(df.format(dmgdealt));
sb.append("\n");
sb.append(ChatColor.YELLOW);
sb.append("DPS: ");
long duration = (TwosideKeeper.getServerTickTime()-timeStartedHitting)/20; //In seconds.
sb.append(df.format(dmgdealt/duration));
sb.append("\n");
sb.append(ChatColor.GRAY);
sb.append("Hits: ");
sb.append(numbOfHits);
sb.append(" (");
sb.append(" Avg ");
sb.append(df.format(dmgdealt/numbOfHits));
sb.append(" dmg)");
return sb.toString();
}
public void customHitHandler(Player p, double dmg) {
super.customHitHandler(p,dmg);
if (numbOfHits==0) {
timeStartedHitting=TwosideKeeper.getServerTickTime();
dmgdealt=0;
}
if (!playerHitList.contains(p)) {
playerHitList.add(p);
}
lastHitTime=TwosideKeeper.getServerTickTime();
numbOfHits++;
dmgdealt+=dmg;
}
}

View File

@ -9,6 +9,7 @@ import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -199,6 +200,7 @@ public class PlayerStructure {
public boolean equiparmor=true; public boolean equiparmor=true;
public long lastpotionparticles=0; public long lastpotionparticles=0;
public Location restartLoc = null; //Set to a value when the player has to be re-teleported after being controlled by a camera. public Location restartLoc = null; //Set to a value when the player has to be re-teleported after being controlled by a camera.
public long lastPoisonTick=0;
List<ItemStack> equipmentset = new ArrayList<ItemStack>(); List<ItemStack> equipmentset = new ArrayList<ItemStack>();
@ -404,6 +406,13 @@ public class PlayerStructure {
workable.set("COOLDOWN_lastmock", last_mock); workable.set("COOLDOWN_lastmock", last_mock);
workable.set("COOLDOWN_lastassassinatetime", lastassassinatetime); workable.set("COOLDOWN_lastassassinatetime", lastassassinatetime);
workable.set("COOLDOWN_lastlifesavertime", lastlifesavertime); workable.set("COOLDOWN_lastlifesavertime", lastlifesavertime);
int buffcounter=0;
for (String key : buffs.keySet()) {
Buff b = buffs.get(key);
SaveBuff(workable, buffcounter, key, b);
buffcounter++;
}
workable.set("BUFFCOUNT", buffcounter);
if (restartLoc!=null) { if (restartLoc!=null) {
workable.set("restartloc_x", restartLoc.getX()); workable.set("restartloc_x", restartLoc.getX());
workable.set("restartloc_y", restartLoc.getY()); workable.set("restartloc_y", restartLoc.getY());
@ -420,6 +429,16 @@ public class PlayerStructure {
} }
} }
private void SaveBuff(FileConfiguration workable, int buffcounter, String key, Buff b) {
workable.set("BUFF"+(buffcounter)+"_key", key);
workable.set("BUFF"+(buffcounter)+"_name", b.getDisplayName());
workable.set("BUFF"+(buffcounter)+"_duration", b.getRemainingBuffTime());
workable.set("BUFF"+(buffcounter)+"_amplifier", b.getAmplifier());
workable.set("BUFF"+(buffcounter)+"_color", b.getBuffParticleColor().asRGB());
workable.set("BUFF"+(buffcounter)+"_icon", b.getBuffIcon());
workable.set("BUFF"+(buffcounter)+"_isGoodBuff", b.isGoodBuff());
}
//Create a config for the player. //Create a config for the player.
public void loadConfig(){ public void loadConfig(){
Player p = Bukkit.getPlayer(name); Player p = Bukkit.getPlayer(name);
@ -480,6 +499,7 @@ public class PlayerStructure {
workable.addDefault("COOLDOWN_lastmock", last_mock); workable.addDefault("COOLDOWN_lastmock", last_mock);
workable.addDefault("COOLDOWN_lastassassinatetime", lastassassinatetime); workable.addDefault("COOLDOWN_lastassassinatetime", lastassassinatetime);
workable.addDefault("COOLDOWN_lastlifesavertime", lastlifesavertime); workable.addDefault("COOLDOWN_lastlifesavertime", lastlifesavertime);
workable.addDefault("BUFFCOUNT", 0);
workable.options().copyDefaults(); workable.options().copyDefaults();
@ -543,6 +563,26 @@ public class PlayerStructure {
this.restartLoc = new Location(Bukkit.getWorld(tempworld),workable.getDouble("restartloc_x"),workable.getDouble("restartloc_y"),workable.getDouble("restartloc_z")); this.restartLoc = new Location(Bukkit.getWorld(tempworld),workable.getDouble("restartloc_x"),workable.getDouble("restartloc_y"),workable.getDouble("restartloc_z"));
} }
int buffcount = workable.getInt("BUFFCOUNT");
for (int i=0;i<buffcount;i++) {
/*Buff.addBuff(p, workable.getString("BUFF"+i+"_key"), new Buff(
workable.getString("BUFF"+i+"_name"),
workable.getLong("BUFF"+i+"_duration"),
workable.getInt("BUFF"+i+"_amplifier"),
Color.fromRGB(workable.getInt("BUFF"+i+"_color")),
workable.getString("BUFF"+i+"_icon"),
workable.getBoolean("BUFF"+i+"_isGoodBuff")
));*/
buffs.put(workable.getString("BUFF"+i+"_key"), new Buff(
workable.getString("BUFF"+i+"_name"),
workable.getLong("BUFF"+i+"_duration"),
workable.getInt("BUFF"+i+"_amplifier"),
Color.fromRGB(workable.getInt("BUFF"+i+"_color")),
workable.getString("BUFF"+i+"_icon"),
workable.getBoolean("BUFF"+i+"_isGoodBuff")
));
}
if (this.hasDied) { if (this.hasDied) {
List<ItemStack> deathlootlist = new ArrayList<ItemStack>(); List<ItemStack> deathlootlist = new ArrayList<ItemStack>();
//ConfigurationSection deathlootsection = workable.getConfigurationSection("deathloot"); //ConfigurationSection deathlootsection = workable.getConfigurationSection("deathloot");

View File

@ -78,6 +78,7 @@ import org.bukkit.entity.Snowball;
import org.bukkit.entity.Snowman; import org.bukkit.entity.Snowman;
import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.TippedArrow; import org.bukkit.entity.TippedArrow;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Witch; import org.bukkit.entity.Witch;
import org.bukkit.entity.Wither; import org.bukkit.entity.Wither;
import org.bukkit.entity.WitherSkull; import org.bukkit.entity.WitherSkull;
@ -261,6 +262,7 @@ import sig.plugin.TwosideKeeper.HolidayEvents.TreeBuilder;
import sig.plugin.TwosideKeeper.Logging.BowModeLogger; import sig.plugin.TwosideKeeper.Logging.BowModeLogger;
import sig.plugin.TwosideKeeper.Logging.LootLogger; import sig.plugin.TwosideKeeper.Logging.LootLogger;
import sig.plugin.TwosideKeeper.Logging.MysteriousEssenceLogger; import sig.plugin.TwosideKeeper.Logging.MysteriousEssenceLogger;
import sig.plugin.TwosideKeeper.Monster.Dummy;
import sig.plugin.TwosideKeeper.Monster.HellfireGhast; import sig.plugin.TwosideKeeper.Monster.HellfireGhast;
import sig.plugin.TwosideKeeper.Monster.HellfireSpider; import sig.plugin.TwosideKeeper.Monster.HellfireSpider;
import sig.plugin.TwosideKeeper.Monster.MonsterTemplate; import sig.plugin.TwosideKeeper.Monster.MonsterTemplate;
@ -1819,6 +1821,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
new Buff("Bleeding",20*14,5,Color.MAROON,ChatColor.RED+""), new Buff("Bleeding",20*14,5,Color.MAROON,ChatColor.RED+""),
});*/ });*/
}break; }break;
case "TESTDUMMY":{
Villager dummy = (Villager)p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
custommonsters.put(dummy.getUniqueId(),new Dummy(dummy));
}break;
case "POISON":{
Buff.addBuff(p, "Poison", new Buff("Poison",20*20,Integer.parseInt(args[1]),Color.YELLOW,ChatColor.YELLOW+"",false));
}break;
} }
} }
@ -3106,13 +3115,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
@EventHandler(priority=EventPriority.LOW) @EventHandler(priority=EventPriority.LOW,ignoreCancelled=true)
public void onPlayerInteract(PlayerInteractEntityEvent ev) { public void onPlayerInteract(PlayerInteractEntityEvent ev) {
Player p = ev.getPlayer(); Player p = ev.getPlayer();
PlayerStructure pd = PlayerStructure.GetPlayerStructure(ev.getPlayer()); PlayerStructure pd = PlayerStructure.GetPlayerStructure(ev.getPlayer());
if (ev.getRightClicked() instanceof LivingEntity && if (ev.getRightClicked() instanceof LivingEntity &&
!(ev.getRightClicked() instanceof Player)) { !(ev.getRightClicked() instanceof Player)) {
LivingEntity ent = (LivingEntity)ev.getRightClicked(); LivingEntity ent = (LivingEntity)ev.getRightClicked();
if (Dummy.isDummy(ent)) {
ev.setCancelled(true);
}
if (Christmas.isWinterSolsticeAugury(p.getEquipment().getItemInMainHand()) && if (Christmas.isWinterSolsticeAugury(p.getEquipment().getItemInMainHand()) &&
pd.icewandused+GenericFunctions.GetModifiedCooldown(TwosideKeeper.ICEWAND_COOLDOWN,ev.getPlayer())<getServerTickTime()) { pd.icewandused+GenericFunctions.GetModifiedCooldown(TwosideKeeper.ICEWAND_COOLDOWN,ev.getPlayer())<getServerTickTime()) {
//Freeze the entity in the nearest grid-locked square and set the AI to false. //Freeze the entity in the nearest grid-locked square and set the AI to false.
@ -4272,7 +4284,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (stackamt<5) { if (stackamt<5) {
Buff.removeBuff(m, "DeathMark"); Buff.removeBuff(m, "DeathMark");
} else { } else {
Buff.addBuff(m, "DeathMark", new Buff("Death Mark",99,stackamt/2,Color.MAROON,ChatColor.DARK_RED+"")); Buff.addBuff(m, "DeathMark", new Buff("Death Mark",99,stackamt/2,Color.MAROON,ChatColor.DARK_RED+"",false));
GenericFunctions.RefreshBuffColor(m, stackamt/2); GenericFunctions.RefreshBuffColor(m, stackamt/2);
} }
//player.playSound(m.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f); //player.playSound(m.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f);
@ -5936,6 +5948,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public void updateMonsterFlags(LivingEntity m) { public void updateMonsterFlags(LivingEntity m) {
LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m); LivingEntityStructure ms = LivingEntityStructure.GetLivingEntityStructure(m);
if (Dummy.isDummy(m)) {
TwosideKeeper.custommonsters.put(m.getUniqueId(), new Dummy(m));
return;
}
if (m instanceof Monster) { if (m instanceof Monster) {
MonsterDifficulty md = MonsterController.getMonsterDifficulty((Monster)m); MonsterDifficulty md = MonsterController.getMonsterDifficulty((Monster)m);
if (md == MonsterDifficulty.ELITE) { if (md == MonsterDifficulty.ELITE) {
@ -5945,9 +5961,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
m = MonsterController.convertMonster((Monster)m,md); m = MonsterController.convertMonster((Monster)m,md);
log("Setting a monster with Difficulty "+MonsterController.getMonsterDifficulty((Monster)m).name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5); log("Setting a monster with Difficulty "+MonsterController.getMonsterDifficulty((Monster)m).name()+" w/"+m.getHealth()+"/"+m.getMaxHealth()+" HP to a Leader.",5);
ms.SetLeader(true); ms.SetLeader(true);
return;
} }
if (m instanceof Wither) { if (m instanceof Wither) {
ms.SetLeader(true); ms.SetLeader(true);
return;
} }
if (TwosideKeeper.ELITEGUARDIANS_ACTIVATED) { if (TwosideKeeper.ELITEGUARDIANS_ACTIVATED) {
if (m instanceof Guardian) { if (m instanceof Guardian) {
@ -5956,6 +5974,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ms.SetElite(true); ms.SetElite(true);
g.setCustomName(ChatColor.LIGHT_PURPLE+"Elite Guardian"); g.setCustomName(ChatColor.LIGHT_PURPLE+"Elite Guardian");
g.setCustomNameVisible(true); g.setCustomNameVisible(true);
return;
} }
} }
} }

View File

@ -58,6 +58,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.Utils.MessageUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.PlayerUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.PlayerUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils;
import sig.plugin.TwosideKeeper.HolidayEvents.Christmas; import sig.plugin.TwosideKeeper.HolidayEvents.Christmas;
import sig.plugin.TwosideKeeper.Monster.Dummy;
final class runServerHeartbeat implements Runnable { final class runServerHeartbeat implements Runnable {
/** /**
@ -257,6 +258,8 @@ final class runServerHeartbeat implements Runnable {
ManagePlayerScoreboardAndHealth(p); ManagePlayerScoreboardAndHealth(p);
TwosideKeeper.HeartbeatLogger.AddEntry("Scoreboard/Health Management", (int)(System.nanoTime()-time));time=System.nanoTime(); TwosideKeeper.HeartbeatLogger.AddEntry("Scoreboard/Health Management", (int)(System.nanoTime()-time));time=System.nanoTime();
PerformPoisonTick(p);
if (PlayerMode.isBarbarian(p)) { if (PlayerMode.isBarbarian(p)) {
AutoConsumeFoods(p); AutoConsumeFoods(p);
TwosideKeeper.HeartbeatLogger.AddEntry("Auto Consume Food", (int)(System.nanoTime()-time));time=System.nanoTime(); TwosideKeeper.HeartbeatLogger.AddEntry("Auto Consume Food", (int)(System.nanoTime()-time));time=System.nanoTime();
@ -339,6 +342,30 @@ final class runServerHeartbeat implements Runnable {
TwosideKeeper.HeartbeatLogger.AddEntry(ChatColor.LIGHT_PURPLE+"Total Server Heartbeat", (int)(System.nanoTime()-totaltime));totaltime=System.nanoTime(); TwosideKeeper.HeartbeatLogger.AddEntry(ChatColor.LIGHT_PURPLE+"Total Server Heartbeat", (int)(System.nanoTime()-totaltime));totaltime=System.nanoTime();
} }
private void PerformPoisonTick(LivingEntity ent) {
if (ent instanceof Player) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)ent);
if (Buff.hasBuff(ent, "Poison") && pd.lastPoisonTick+getPoisonTickDelay(ent)<=TwosideKeeper.getServerTickTime()) {
CustomDamage.ApplyDamage(Buff.getBuff(ent, "Poison").getAmplifier(), null, ent, null, "POISON", CustomDamage.IGNOREDODGE|CustomDamage.TRUEDMG);
pd.lastPoisonTick=TwosideKeeper.getServerTickTime();
}
} else {
LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(ent);
if (Buff.hasBuff(ent, "Poison") && les.lastPoisonTick+getPoisonTickDelay(ent)<=TwosideKeeper.getServerTickTime()) {
CustomDamage.ApplyDamage(Buff.getBuff(ent, "Poison").getAmplifier(), null, ent, null, "POISON", CustomDamage.IGNOREDODGE|CustomDamage.TRUEDMG);
les.lastPoisonTick=TwosideKeeper.getServerTickTime();
}
}
}
private double getPoisonTickDelay(LivingEntity ent) {
if (CustomDamage.getPoisonResistance(ent)>0.9) {
return 200;
} else {
return (1d/(1d-CustomDamage.getPoisonResistance(ent)))*20;
}
}
private void createPotionParticles(LivingEntity l) { private void createPotionParticles(LivingEntity l) {
if (l instanceof Player) { if (l instanceof Player) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l);
@ -897,7 +924,7 @@ final class runServerHeartbeat implements Runnable {
} else { } else {
AddEliteStructureIfOneDoesNotExist(ms); AddEliteStructureIfOneDoesNotExist(ms);
TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Add Elite Structure", (int)(System.nanoTime()-time));time=System.nanoTime(); TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Add Elite Structure", (int)(System.nanoTime()-time));time=System.nanoTime();
if (ms.GetTarget()!=null && ms.GetTarget().isValid() && !ms.GetTarget().isDead() && ms.m.hasAI()) { if (ms.GetTarget()!=null && ms.GetTarget().isValid() && !ms.GetTarget().isDead() && ms.m.hasAI() && !Dummy.isDummy(ms.m)) {
//Randomly move this monster a tiny bit in case they are stuck. //Randomly move this monster a tiny bit in case they are stuck.
double xdir=((ms.m.getLocation().getX()>ms.GetTarget().getLocation().getX())?-0.25:0.25)+(Math.random()/8)-(Math.random()/8); double xdir=((ms.m.getLocation().getX()>ms.GetTarget().getLocation().getX())?-0.25:0.25)+(Math.random()/8)-(Math.random()/8);
double zdir=((ms.m.getLocation().getZ()>ms.GetTarget().getLocation().getZ())?-0.25:0.25)+(Math.random()/8)-(Math.random()/8); double zdir=((ms.m.getLocation().getZ()>ms.GetTarget().getLocation().getZ())?-0.25:0.25)+(Math.random()/8)-(Math.random()/8);
@ -910,6 +937,8 @@ final class runServerHeartbeat implements Runnable {
TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Create Potion Particles", (int)(System.nanoTime()-time));time=System.nanoTime(); TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Create Potion Particles", (int)(System.nanoTime()-time));time=System.nanoTime();
LivingEntityStructure.UpdateMobName(ms.m); LivingEntityStructure.UpdateMobName(ms.m);
TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Update Mob Names", (int)(System.nanoTime()-time));time=System.nanoTime(); TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Update Mob Names", (int)(System.nanoTime()-time));time=System.nanoTime();
PerformPoisonTick(ms.m);
TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Perform Poison Tick", (int)(System.nanoTime()-time));time=System.nanoTime();
} }
} }
} }