@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("BaseTickDamage", 0); node.set("LevelMultiplier", 0.5); node.set(Setting.DURATION.node(), 12000); 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() 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; } } } } } }