diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 94fcd75..e7672dc 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/sig/plugin/TwosideKeeper/CustomDamage.java b/src/sig/plugin/TwosideKeeper/CustomDamage.java index fa213d5..11bb6b8 100644 --- a/src/sig/plugin/TwosideKeeper/CustomDamage.java +++ b/src/sig/plugin/TwosideKeeper/CustomDamage.java @@ -315,14 +315,7 @@ public class CustomDamage { if (target instanceof Player) { Player p = (Player)target; if (PlayerMode.isDefender(p)) { - int resistlevel = GenericFunctions.getPotionEffectLevel(PotionEffectType.DAMAGE_RESISTANCE, p); - if (resistlevel<4) { - p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); - p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,100,resistlevel+1)); - } else { - p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); - p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,100,resistlevel)); - } + GenericFunctions.addStackingPotionEffect(p, PotionEffectType.DAMAGE_RESISTANCE, 20*5, 4); if (p.isBlocking() && ItemSet.hasFullSet(p, ItemSet.SONGSTEEL)) { PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); pd.vendetta_amt+=((1-CalculateDamageReduction(1,target,damager))*pd.lastrawdamage)*0.3; @@ -430,6 +423,7 @@ public class CustomDamage { } performMegaKnockback(damager,target); removePermEnchantments(p,weapon); + GenericFunctions.knockOffGreed(p); castEruption(p,target,weapon); addHealthFromLifesteal(p,damage,weapon); triggerEliteHitEvent(p,target,damage); @@ -1807,10 +1801,7 @@ public class CustomDamage { } private static void increaseStrikerSpeed(Player p) { - int speedlv = 0; - if (p.hasPotionEffect(PotionEffectType.SPEED)) { - speedlv = GenericFunctions.getPotionEffectLevel(PotionEffectType.SPEED, p)+1; - } + GenericFunctions.addStackingPotionEffect(p, PotionEffectType.SPEED, 20*5, 4); } /*0.0-1.0*/ diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 345da11..ab0c906 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -3731,4 +3731,39 @@ public class GenericFunctions { aPlugin.API.sendActionBarMessage(p, ChatColor.GRAY+"Resistance "+WorldShop.toRomanNumeral(GenericFunctions.getPotionEffectLevel(PotionEffectType.DAMAGE_RESISTANCE, p)+1)); } } + + /** + * Behavior is as follows: + * -> Sees if the potion effect exists on the player. + * -> If current potion effect duration <= tick_duration + * -> Overwrite with higher level buff. + * + * -> If potion effect does not exist on the player + * -> Add it. + * + * -> If current potion effect == maxlv + * -> If current potion effect duration <= tick_duration. + * -> Overwrite / Renew with maxlv buff. + * @param p + * @param type + * @param maxlv The maximum level (Represented as a POTION level, not in-game displayed level. + */ + public static void addStackingPotionEffect(Player p, PotionEffectType type, int tick_duration, int maxlv) { + addStackingPotionEffect(p,type,tick_duration,maxlv,1); + } + + public static void addStackingPotionEffect(Player p, PotionEffectType type, int tick_duration, int maxlv, int incr_amt) { + final int BUFFER = 20*20; //20 extra seconds difference required to prevent buffs from being overwritten by this method. + if (p.hasPotionEffect(type)) { + int duration = getPotionEffectDuration(type,p); + int currentlv = getPotionEffectLevel(type,p); + PotionEffect neweffect = new PotionEffect(type,tick_duration,(currentlv+incr_amt= duration) { + p.addPotionEffect(neweffect, true); + } + } else { + PotionEffect neweffect = new PotionEffect(type,tick_duration,0); + p.addPotionEffect(neweffect, true); + } + } } diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index d632897..5c3025f 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -2311,7 +2311,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { for (int i=0;i