@Override public String getDescription(Hero hero) { int level = hero.getSkillLevel(this); double chance = (SkillConfigManager.getUseSetting(hero, this, Setting.CHANCE.node(), 0.2, false) + (SkillConfigManager.getUseSetting( hero, this, Setting.CHANCE_LEVEL.node(), 0.2, false) * level)) * 100; chance = chance > 0 ? chance : 0; double duration = (SkillConfigManager.getUseSetting(hero, this, Setting.DURATION.node(), 2000, false) + (level * SkillConfigManager.getUseSetting(hero, this, "duration-increase", 0, false))) / 1000; duration = duration > 0 ? duration : 0; String description = getDescription().replace("$1", chance + "").replace("$2", duration + ""); // COOLDOWN int cooldown = (SkillConfigManager.getUseSetting(hero, this, Setting.COOLDOWN.node(), 0, false) - SkillConfigManager.getUseSetting( hero, this, Setting.COOLDOWN_REDUCE.node(), 0, false) * hero.getSkillLevel(this)) / 1000; if (cooldown > 0) { description += " CD:" + cooldown + "s"; } return description; }
@Override public ConfigurationSection getDefaultConfig() { ConfigurationSection node = super.getDefaultConfig(); node.set(Setting.CHANCE.node(), 0.2); node.set(Setting.CHANCE_LEVEL.node(), 0); node.set("hst-chance", 0); return node; }
@Override public ConfigurationSection getDefaultConfig() { ConfigurationSection node = super.getDefaultConfig(); node.set(Setting.CHANCE.node(), 0.2); node.set(Setting.CHANCE_LEVEL.node(), 0.0); node.set(Setting.COOLDOWN.node(), 500); node.set(Setting.DURATION.node(), 2000); node.set("duration-increase", 0); node.set("exp-per-stun", 0); return node; }
@EventHandler(priority = EventPriority.HIGH) public void onEntityDamage(WeaponDamageEvent event) { if (!(event.isCancelled()) && (event.getDamager() instanceof Hero) && (event.getCause().equals(DamageCause.PROJECTILE))) { Hero hero = (Hero) event.getDamager(); if (hero.hasEffect("RetrieveArrow")) { double chance = (SkillConfigManager.getUseSetting(hero, skill, Setting.CHANCE.node(), 0.2, false) + (SkillConfigManager.getUseSetting( hero, skill, Setting.CHANCE_LEVEL.node(), 0.0, false) * hero.getSkillLevel(skill))); if (hst != null) chance += (SkillConfigManager.getUseSetting(hero, skill, "hst-amount", 0.0, false) * (hst.getSkillLevel(hero, skill) - 1)); chance = chance > 0 ? chance : 0; if (Math.random() <= chance) { if (event.getEntity() instanceof Player) { if (SkillRetrieveArrow.this .plugin .getCharacterManager() .getHero((Player) event.getEntity()) .getHealth() < event.getDamage()) { event .getEntity() .getWorld() .dropItemNaturally(event.getEntity().getLocation(), new ItemStack(262, 1)); } } else if (event.getEntity() instanceof LivingEntity) { if (SkillRetrieveArrow.this .plugin .getCharacterManager() .getMonster((LivingEntity) event.getEntity()) .getHealth() < event.getDamage()) { event .getEntity() .getWorld() .dropItemNaturally(event.getEntity().getLocation(), new ItemStack(262, 1)); } } } } } }
@Override public String getDescription(Hero hero) { double chance = (SkillConfigManager.getUseSetting(hero, this, Setting.CHANCE.node(), 0.2, false) + (SkillConfigManager.getUseSetting( hero, this, Setting.CHANCE_LEVEL.node(), 0.0, false) * hero.getSkillLevel(this))) * 100; if (hst != null) chance += (SkillConfigManager.getUseSetting(hero, this, "hst-chance", 0.0, false) * (hst.getSkillLevel(hero, this) - 1) * 100); chance = chance > 0 ? chance : 0; String description = getDescription().replace("$1", chance + ""); return description; }
@EventHandler() public void onEntityDamage(EntityDamageEvent event) { if (event.isCancelled() || event.getDamage() == 0 || event.getCause() != DamageCause.ENTITY_ATTACK || !(event.getEntity() instanceof Player) || !(event instanceof EntityDamageByEntityEvent)) { return; } EntityDamageByEntityEvent edby = (EntityDamageByEntityEvent) event; Player tPlayer = (Player) event.getEntity(); if (edby.getDamager() instanceof Player) { Player player = (Player) edby.getDamager(); Hero hero = plugin.getCharacterManager().getHero(player); if (hero.hasEffect("Basher")) { if (hero.getCooldown("Basher") == null || hero.getCooldown("Basher") <= System.currentTimeMillis()) { double chance = (double) SkillConfigManager.getUseSetting( hero, skill, Setting.CHANCE.node(), 0.2, false) + (hero.getSkillLevel(skill) * SkillConfigManager.getUseSetting( hero, skill, Setting.CHANCE_LEVEL.node(), 0.0, false)); chance = chance > 0 ? chance : 0; long cooldown = (long) (SkillConfigManager.getUseSetting( hero, skill, Setting.COOLDOWN.node(), 0, false) - SkillConfigManager.getUseSetting( hero, skill, Setting.COOLDOWN_REDUCE.node(), 0, false) * hero.getSkillLevel(skill)); cooldown = cooldown > 0 ? cooldown : 0; hero.setCooldown("Basher", cooldown + System.currentTimeMillis()); if (Math.random() <= chance) { long duration = (long) (SkillConfigManager.getUseSetting( hero, skill, Setting.DURATION.node(), 2000, false) + (hero.getSkillLevel(skill) * SkillConfigManager.getUseSetting( hero, skill, "duration-increase", 0, false))); duration = duration > 0 ? duration : 0; plugin .getCharacterManager() .getHero(tPlayer) .addEffect(new StunEffect(basher, duration)); double exp = SkillConfigManager.getUseSetting(hero, skill, "exp-per-stun", 0, false); if (exp > 0) { if (hero.hasParty()) { hero.getParty().gainExp(exp, ExperienceType.SKILL, player.getLocation()); } else { hero.gainExp(exp, ExperienceType.SKILL); } } return; } } } } else if (edby.getDamager() instanceof Projectile) { if (((Projectile) edby.getDamager()).getShooter() instanceof Player) { Player player = (Player) ((Projectile) edby.getDamager()).getShooter(); Hero hero = plugin.getCharacterManager().getHero(player); if (hero.hasEffect("Basher")) { if (hero.getCooldown("Basher") == null || hero.getCooldown("Basher") <= System.currentTimeMillis()) { double chance = (double) SkillConfigManager.getUseSetting( hero, skill, Setting.CHANCE.node(), 0.2, false) + (hero.getSkillLevel(skill) * SkillConfigManager.getUseSetting( hero, skill, Setting.CHANCE_LEVEL.node(), 0.0, false)); chance = chance > 0 ? chance : 0; long cooldown = (long) (SkillConfigManager.getUseSetting( hero, skill, Setting.COOLDOWN.node(), 0, false) - SkillConfigManager.getUseSetting( hero, skill, Setting.COOLDOWN_REDUCE.node(), 0, false) * hero.getSkillLevel(skill)); cooldown = cooldown > 0 ? cooldown : 0; hero.setCooldown("Basher", cooldown + System.currentTimeMillis()); if (Math.random() <= chance) { long duration = (long) (SkillConfigManager.getUseSetting( hero, skill, Setting.DURATION.node(), 2000, false) + (hero.getSkillLevel(skill) * SkillConfigManager.getUseSetting( hero, skill, "duration-increase", 0, false))); duration = duration > 0 ? duration : 0; plugin .getCharacterManager() .getHero(tPlayer) .addEffect(new StunEffect(basher, duration)); double exp = SkillConfigManager.getUseSetting(hero, skill, "exp-per-stun", 0, false); if (exp > 0) { if (hero.hasParty()) { hero.getParty().gainExp(exp, ExperienceType.SKILL, player.getLocation()); } else { hero.gainExp(exp, ExperienceType.SKILL); } } return; } } } } } }