diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index ac1cb8b..8134864 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 4349150..e41b904 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -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. diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 4acf679..194c624 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -2658,16 +2658,14 @@ 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 { - /*List drops = new ArrayList(); - EntityDeathEvent ev = new EntityDeathEvent(entity,drops); - Bukkit.getPluginManager().callEvent(ev); - entity.setHealth(0);*/ - entity.damage(Integer.MAX_VALUE); - } + if (entity.getHealth()>dmg) { + entity.setHealth(entity.getHealth()-dmg); + } else { + /*List drops = new ArrayList(); + EntityDeathEvent ev = new EntityDeathEvent(entity,drops); + Bukkit.getPluginManager().callEvent(ev); + entity.setHealth(0);*/ + entity.damage(Integer.MAX_VALUE); } } @@ -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(); } } diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 0b673c0..e51e08b 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -3823,27 +3823,66 @@ 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 LivingEntity) { - dmg = NewCombat.applyDamage((LivingEntity)ev.getEntity(), ev.getDamager()); - log(GenericFunctions.GetEntityDisplayName(ev.getDamager())+ChatColor.GRAY+"->"+ - GenericFunctions.GetEntityDisplayName(ev.getEntity())+ChatColor.GRAY+": Damage dealt was "+dmg,2); + 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"+ + GenericFunctions.GetEntityDisplayName(ev.getEntity())+ChatColor.GRAY+": Damage dealt was "+dmg,2); + } + if (ev.getCause()==DamageCause.THORNS) { + if (ev.getEntity() instanceof LivingEntity) { + ((LivingEntity)ev.getEntity()).setNoDamageTicks(10); + ((LivingEntity)ev.getEntity()).damage(Math.min(GenericFunctions.getMaxThornsLevel((LivingEntity)ev.getDamager()),((LivingEntity)ev.getEntity()).getHealth()/0.05)); + } + } else + if (dmg>=0) { + NewCombat.setupTrueDamage(ev); //Apply this as true damage. + ev.setDamage(0); + if (ev.getEntity() instanceof LivingEntity) { + ((LivingEntity)ev.getEntity()).setNoDamageTicks(10); + double oldhp=((LivingEntity)ev.getEntity()).getHealth(); + GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(),dmg); + log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)ev.getEntity()).getHealth()+" HP",3); + } + } //Negative damage doesn't make sense. We'd apply it normally. } - if (ev.getCause()==DamageCause.THORNS) { - if (ev.getEntity() instanceof LivingEntity) { - ((LivingEntity)ev.getEntity()).setNoDamageTicks(10); - ((LivingEntity)ev.getEntity()).damage(Math.min(GenericFunctions.getMaxThornsLevel((LivingEntity)ev.getDamager()),((LivingEntity)ev.getEntity()).getHealth()/0.05)); - } - } else - if (dmg>=0) { - NewCombat.setupTrueDamage(ev); //Apply this as true damage. - ev.setDamage(0); - if (ev.getEntity() instanceof LivingEntity) { - ((LivingEntity)ev.getEntity()).setNoDamageTicks(10); - double oldhp=((LivingEntity)ev.getEntity()).getHealth(); - GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(),dmg); - log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)ev.getEntity()).getHealth()+" HP",3); - } - } //Negative damage doesn't make sense. We'd apply it normally. } @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)