Fix Dodging and Iframing and damage dealing.
This commit is contained in:
parent
3e623852b7
commit
0e6d99f8ed
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
name: TwosideKeeper
|
||||
main: sig.plugin.TwosideKeeper.TwosideKeeper
|
||||
version: 3.7.0r1
|
||||
version: 3.7.0r2
|
||||
commands:
|
||||
money:
|
||||
description: Tells the player the amount of money they are holding.
|
||||
|
@ -2658,7 +2658,6 @@ public class GenericFunctions {
|
||||
}
|
||||
|
||||
public static void subtractHealth(final LivingEntity entity, double dmg) {
|
||||
if (!entity.hasPotionEffect(PotionEffectType.GLOWING) && entity instanceof Player) {
|
||||
if (entity.getHealth()>dmg) {
|
||||
entity.setHealth(entity.getHealth()-dmg);
|
||||
} else {
|
||||
@ -2669,7 +2668,6 @@ public class GenericFunctions {
|
||||
entity.damage(Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isViewingInventory(Player p) {
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||
@ -2690,6 +2688,8 @@ public class GenericFunctions {
|
||||
player.removePotionEffect(PotionEffectType.REGENERATION);
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,200,9));
|
||||
aPlugin.API.damageItem(player, player.getEquipment().getItemInMainHand(), 20);
|
||||
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), TwosideKeeper.REJUVENATE_COOLDOWN);
|
||||
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), TwosideKeeper.REJUVENATE_COOLDOWN);
|
||||
pd.last_rejuvenate = TwosideKeeper.getServerTickTime();
|
||||
}
|
||||
}
|
||||
|
@ -3823,6 +3823,44 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||
public void entityHitEvent(EntityDamageByEntityEvent ev) {
|
||||
double dmg = 0.0;
|
||||
if (ev.getEntity() instanceof Player) {
|
||||
Player p = (Player)ev.getEntity();
|
||||
if (p.hasPotionEffect(PotionEffectType.GLOWING)) {
|
||||
ev.setCancelled(true);
|
||||
}
|
||||
double dodgechance = GenericFunctions.CalculateDodgeChance(p);
|
||||
if (ev.getCause()==DamageCause.THORNS &&
|
||||
GenericFunctions.isRanger(p)) {
|
||||
dodgechance=1;
|
||||
p.setHealth(p.getHealth()-0.25);
|
||||
p.playSound(p.getLocation(), Sound.ENCHANT_THORNS_HIT, 0.8f, 3.0f);
|
||||
}
|
||||
|
||||
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
|
||||
|
||||
if (pd.fulldodge) {
|
||||
pd.fulldodge=false;
|
||||
}
|
||||
|
||||
if (Math.random()<=dodgechance) {
|
||||
//Cancel this event, we dodged the attack.
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f);
|
||||
log("Triggered Dodge.",3);
|
||||
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
|
||||
ItemStack equip = p.getEquipment().getArmorContents()[i];
|
||||
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GRACEFULDODGE, equip)) {
|
||||
p.addPotionEffect(
|
||||
new PotionEffect(PotionEffectType.GLOWING,
|
||||
(int)(GenericFunctions.getAbilityValue(ArtifactAbility.GRACEFULDODGE, equip)*20),
|
||||
0)
|
||||
);
|
||||
}
|
||||
}
|
||||
p.setNoDamageTicks(10);
|
||||
ev.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if (!ev.isCancelled()) {
|
||||
if (ev.getEntity() instanceof LivingEntity) {
|
||||
dmg = NewCombat.applyDamage((LivingEntity)ev.getEntity(), ev.getDamager());
|
||||
log(GenericFunctions.GetEntityDisplayName(ev.getDamager())+ChatColor.GRAY+"->"+
|
||||
@ -3845,6 +3883,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
}
|
||||
} //Negative damage doesn't make sense. We'd apply it normally.
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||
public void onLightningStrike(LightningStrikeEvent ev) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user