diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 3192bd0..dabd13c 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java b/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java index 0409bab..d7f95cc 100644 --- a/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java +++ b/src/sig/plugin/TwosideKeeper/ActionBarBuffUpdater.java @@ -14,6 +14,14 @@ import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; public class ActionBarBuffUpdater{ + + /* + * LIST OF BUFFS: + * basename / icon string + * + * Poison ChatColor.YELLOW+"☣" + * DeathMark ChatColor.DARK_RED+"☠" + */ public static String getActionBarPrefix(LivingEntity p) { StringBuilder actionbardisplay = new StringBuilder(""); @@ -199,11 +207,11 @@ public class ActionBarBuffUpdater{ effectString.append(ChatColor.WHITE); effectString.append("➠"); } else - if (pet.equals(PotionEffectType.POISON) || + /*if (pet.equals(PotionEffectType.POISON) || (pet.equals(PotionEffectType.BLINDNESS) && (p instanceof LivingEntity && !(p instanceof Player)))) { effectString.append(ChatColor.YELLOW); effectString.append("☣"); - } else + } else*/ /*if ((pet.equals(PotionEffectType.UNLUCK) && (p instanceof LivingEntity && !(p instanceof Player)))) { effectString.append(ChatColor.DARK_RED); effectString.append("☠"); diff --git a/src/sig/plugin/TwosideKeeper/Boss/EliteZombie.java b/src/sig/plugin/TwosideKeeper/Boss/EliteZombie.java index 17e753a..89f945c 100644 --- a/src/sig/plugin/TwosideKeeper/Boss/EliteZombie.java +++ b/src/sig/plugin/TwosideKeeper/Boss/EliteZombie.java @@ -92,14 +92,17 @@ public class EliteZombie extends EliteMonster{ protected void createBossHealthbar() { List currentplayers = bar.getPlayers(); - for (int i=0;i currentplayers = bar.getPlayers(); - for (int i=0;i=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 { LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(l); - les.buffs.put(name, buff); + 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); + 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) { @@ -147,6 +183,13 @@ public class Buff { public void refreshDuration(int duration) { expireTime=TwosideKeeper.getServerTickTime()+duration; } + + public boolean isGoodBuff() { + return isGoodBuff; + } + public boolean isDebuff() { + return !isGoodBuff; + } private static boolean hasBuffExpired(Buff b) { if (b.expireTime *     IGNOREDODGE - Ignores all Dodge and invulnerability checks.
*     TRUEDMG - Ignores all additional calculations/reductions, applying the damage directly.
+ *     IGNORE_DAMAGE_TICK - Ignores the fact the entity is in an invulnerable state and applies the damage.
*
Combining flags example: 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. */ @@ -439,11 +444,12 @@ public class CustomDamage { target.setMaximumNoDamageTicks(0); damage = subtractAbsorptionHearts(damage,target); 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. TwosideKeeper.log("Dealing "+damage+" damage.", 5); TwosideKeeper.log("Sending out "+(damage+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER)+" damage.",5); 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 if (!(getDamagerEntity(damager) instanceof LivingEntity) || (damage!=0 && isFlagSet(flags,SPECIALATTACK))) { //TwosideKeeper.log("Sending out "+damage+" damage.",2); @@ -451,6 +457,10 @@ public class CustomDamage { 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. Player p = (Player)target; TwosideKeeper.setPlayerMaxHealth(p); @@ -586,7 +596,8 @@ public class CustomDamage { target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,20*5,slownesslv)); } 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); @@ -684,11 +695,12 @@ public class CustomDamage { } if (ItemSet.HasSetBonusBasedOnSetBonusCount(GenericFunctions.getBaubles(p), p, ItemSet.MOONSHADOW, 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); } else { 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() { @@ -1239,11 +1251,28 @@ public class CustomDamage { } if (target instanceof Wither) { Wither w = (Wither)target; - for (UUID id : TwosideKeeper.custommonsters.keySet()) { + /*for (UUID id : TwosideKeeper.custommonsters.keySet()) { if (id.equals(w.getUniqueId())) { sig.plugin.TwosideKeeper.Monster.Wither wi = (sig.plugin.TwosideKeeper.Monster.Wither)TwosideKeeper.custommonsters.get(id); 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,23 +2544,36 @@ public class CustomDamage { } if (PlayerMode.isRanger(p) && GenericFunctions.getBowMode(p)==BowMode.DEBILITATION) { - if (m.hasPotionEffect(PotionEffectType.BLINDNESS) && isheadshot) { - //Add to the current stack of BLINDNESS. - for (PotionEffect pe : m.getActivePotionEffects()) { - if (pe.getType().equals(PotionEffectType.BLINDNESS)) { - int lv = pe.getAmplifier(); - TwosideKeeper.log("New BLINDNESS level: "+lv,5); - SoundUtils.playLocalSound(p, Sound.ENTITY_RABBIT_ATTACK, 0.1f, 0.1f+((lv+1)*0.5f)); - m.removePotionEffect(PotionEffectType.BLINDNESS); - m.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,400,lv+1),true); - break; - } - } - } else { - m.removePotionEffect(PotionEffectType.BLINDNESS); - m.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,400,0)); + if (isheadshot) { + /*if (m.hasPotionEffect(PotionEffectType.BLINDNESS)) { + //Add to the current stack of BLINDNESS. + for (PotionEffect pe : m.getActivePotionEffects()) { + if (pe.getType().equals(PotionEffectType.BLINDNESS)) { + int lv = pe.getAmplifier(); + TwosideKeeper.log("New BLINDNESS level: "+lv,5); + SoundUtils.playLocalSound(p, Sound.ENTITY_RABBIT_ATTACK, 0.1f, 0.1f+((lv+1)*0.5f)); + m.removePotionEffect(PotionEffectType.BLINDNESS); + m.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,400,lv+1),true); + break; + } + } + } else { + m.removePotionEffect(PotionEffectType.BLINDNESS); + m.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,400,0)); + 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)); + } } } } @@ -2649,6 +2691,21 @@ public class CustomDamage { } 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%. static boolean isCriticalStrike(double chance) { @@ -2684,8 +2741,11 @@ public class CustomDamage { if (target.hasPotionEffect(PotionEffectType.POISON)) { 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; + }*/ + if (Buff.hasBuff(target, "Poison")) { + mult += Buff.getBuff(target, "Poison").getAmplifier()*0.5; } } TwosideKeeper.log("Mult is "+mult, 5); diff --git a/src/sig/plugin/TwosideKeeper/CustomMonster.java b/src/sig/plugin/TwosideKeeper/CustomMonster.java index 451d5a7..47153a8 100644 --- a/src/sig/plugin/TwosideKeeper/CustomMonster.java +++ b/src/sig/plugin/TwosideKeeper/CustomMonster.java @@ -4,6 +4,7 @@ import java.io.File; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; +import org.bukkit.entity.Player; public class CustomMonster { protected LivingEntity m; @@ -34,7 +35,18 @@ public class CustomMonster { } } + public static boolean recognizeMonsterConditions(LivingEntity m) { + return false; + } + public void runTick() { } + + public void customHitHandler() { + + } + public void customHitHandler(Player p, double dmg) { + + } } diff --git a/src/sig/plugin/TwosideKeeper/EliteMonster.java b/src/sig/plugin/TwosideKeeper/EliteMonster.java index fbc9c65..5ff91ae 100644 --- a/src/sig/plugin/TwosideKeeper/EliteMonster.java +++ b/src/sig/plugin/TwosideKeeper/EliteMonster.java @@ -112,11 +112,13 @@ public class EliteMonster { } protected void createBossHealthbar() { - if (m instanceof Wither || m instanceof EnderDragon) { + /*if (m instanceof Wither || m instanceof EnderDragon) { bar.removeAll(); willpower_bar.removeAll(); return; - } + }*/ + bar.removeAll(); + willpower_bar.removeAll(); List currentplayers = bar.getPlayers(); for (int i=0;i81) { while (myspawn.getBlock().getRelative(0, -1, 0).getType()==Material.AIR && myspawn.getY()>1) { diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index fcae179..83d352d 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -2538,7 +2538,7 @@ public class GenericFunctions { deathmarkBuff.refreshDuration(99); stackamt = deathmarkBuff.getAmplifier(); } 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; } RefreshBuffColor(ent, stackamt); @@ -5076,7 +5076,18 @@ public class GenericFunctions { } 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 poisondur = GenericFunctions.getPotionEffectDuration(PotionEffectType.BLINDNESS, ent); totalpoisonlv+=poisonlv+1; @@ -5084,7 +5095,7 @@ public class GenericFunctions { GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.BLINDNESS, 20*15, poisonlv, ent, true); } 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.setAbsorptionHearts(p, CustomDamage.getAbsorptionHearts(p)+totalpoisonstacks*4); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/Classes/MovementModifier.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/Classes/MovementModifier.java new file mode 100644 index 0000000..4c41918 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/Classes/MovementModifier.java @@ -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); + } + +} diff --git a/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java b/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java index d893834..03ba570 100644 --- a/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java +++ b/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java @@ -29,6 +29,7 @@ public class LivingEntityStructure { public boolean hasRallied=false; public HashMap buffs = new HashMap(); public long lastpotionparticles=0; + public long lastPoisonTick=0; public LivingEntityStructure(LivingEntity m) { target=null; diff --git a/src/sig/plugin/TwosideKeeper/Monster/Dummy.java b/src/sig/plugin/TwosideKeeper/Monster/Dummy.java new file mode 100644 index 0000000..af46937 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/Monster/Dummy.java @@ -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 playerHitList = new ArrayList(); + + 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; + } +} diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index c7171d9..a4f2554 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -9,6 +9,7 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -199,6 +200,7 @@ public class PlayerStructure { public boolean equiparmor=true; 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 long lastPoisonTick=0; List equipmentset = new ArrayList(); @@ -404,6 +406,13 @@ public class PlayerStructure { workable.set("COOLDOWN_lastmock", last_mock); workable.set("COOLDOWN_lastassassinatetime", lastassassinatetime); 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) { workable.set("restartloc_x", restartLoc.getX()); 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. public void loadConfig(){ Player p = Bukkit.getPlayer(name); @@ -480,6 +499,7 @@ public class PlayerStructure { workable.addDefault("COOLDOWN_lastmock", last_mock); workable.addDefault("COOLDOWN_lastassassinatetime", lastassassinatetime); workable.addDefault("COOLDOWN_lastlifesavertime", lastlifesavertime); + workable.addDefault("BUFFCOUNT", 0); 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")); } + int buffcount = workable.getInt("BUFFCOUNT"); + for (int i=0;i deathlootlist = new ArrayList(); //ConfigurationSection deathlootsection = workable.getConfigurationSection("deathloot"); diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 8ca75cc..623ce39 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -78,6 +78,7 @@ import org.bukkit.entity.Snowball; import org.bukkit.entity.Snowman; import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.TippedArrow; +import org.bukkit.entity.Villager; import org.bukkit.entity.Witch; import org.bukkit.entity.Wither; 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.LootLogger; import sig.plugin.TwosideKeeper.Logging.MysteriousEssenceLogger; +import sig.plugin.TwosideKeeper.Monster.Dummy; import sig.plugin.TwosideKeeper.Monster.HellfireGhast; import sig.plugin.TwosideKeeper.Monster.HellfireSpider; 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+"☣"), });*/ }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) { Player p = ev.getPlayer(); PlayerStructure pd = PlayerStructure.GetPlayerStructure(ev.getPlayer()); if (ev.getRightClicked() instanceof LivingEntity && !(ev.getRightClicked() instanceof Player)) { LivingEntity ent = (LivingEntity)ev.getRightClicked(); + if (Dummy.isDummy(ent)) { + ev.setCancelled(true); + } if (Christmas.isWinterSolsticeAugury(p.getEquipment().getItemInMainHand()) && pd.icewandused+GenericFunctions.GetModifiedCooldown(TwosideKeeper.ICEWAND_COOLDOWN,ev.getPlayer())0.9) { + return 200; + } else { + return (1d/(1d-CustomDamage.getPoisonResistance(ent)))*20; + } + } + private void createPotionParticles(LivingEntity l) { if (l instanceof Player) { PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); @@ -897,7 +924,7 @@ final class runServerHeartbeat implements Runnable { } else { AddEliteStructureIfOneDoesNotExist(ms); 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. 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); @@ -910,6 +937,8 @@ final class runServerHeartbeat implements Runnable { TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Create Potion Particles", (int)(System.nanoTime()-time));time=System.nanoTime(); LivingEntityStructure.UpdateMobName(ms.m); 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(); } } }