use of com.herocraftonline.heroes.characters.skill.Skill in project MagicPlugin by elBukkit.
the class HeroesManager method getSkillList.
public List<String> getSkillList(Player player, boolean showUnuseable, boolean showPassive) {
if (skills == null)
return emptySkillList;
Hero hero = getHero(player);
if (hero == null)
return emptySkillList;
HeroClass heroClass = hero.getHeroClass();
HeroClass secondClass = hero.getSecondClass();
Set<String> primarySkills = new HashSet<>();
Set<String> secondarySkills = new HashSet<>();
addSkills(hero, heroClass, primarySkills, showUnuseable, showPassive);
addSkills(hero, secondClass, secondarySkills, showUnuseable, showPassive);
secondarySkills.removeAll(primarySkills);
Multimap<Integer, Skill> primaryMap = mapSkillsByLevel(hero, primarySkills);
Multimap<Integer, Skill> secondaryMap = mapSkillsByLevel(hero, secondarySkills);
List<String> skillNames = new ArrayList<>();
for (Skill skill : primaryMap.values()) {
skillNames.add(skill.getName());
}
for (Skill skill : secondaryMap.values()) {
skillNames.add(skill.getName());
}
return skillNames;
}
use of com.herocraftonline.heroes.characters.skill.Skill in project MagicPlugin by elBukkit.
the class HeroesManager method getSkillLevel.
public int getSkillLevel(Player player, String skillName) {
Skill skill = skills.getSkill(skillName);
if (skill == null)
return 0;
Hero hero = getHero(player);
if (hero == null)
return 0;
return SkillConfigManager.getUseSetting(hero, skill, SkillSetting.LEVEL, 1, true);
}
use of com.herocraftonline.heroes.characters.skill.Skill in project MagicPlugin by elBukkit.
the class HeroesManager method createSkillSpell.
@Nullable
public SpellTemplate createSkillSpell(MagicController controller, String skillName) {
if (skills == null)
return null;
Skill skill = skills.getSkill(skillName);
if (skill == null)
return null;
MageSpell newSpell = new HeroesSkillSpell();
newSpell.initialize(controller);
ConfigurationSection config = new MemoryConfiguration();
String iconURL = SkillConfigManager.getRaw(skill, "icon-url", SkillConfigManager.getRaw(skill, "icon_url", null));
if (iconURL == null || iconURL.isEmpty()) {
String icon = SkillConfigManager.getRaw(skill, "icon", null);
if (icon == null || icon.isEmpty()) {
config.set("icon", controller.getDefaultSkillIcon());
} else if (icon.startsWith("http://")) {
config.set("icon_url", icon);
} else {
config.set("icon", icon);
}
} else {
config.set("icon_url", iconURL);
}
String iconDisabledURL = SkillConfigManager.getRaw(skill, "icon-disabled-url", SkillConfigManager.getRaw(skill, "icon_disabled_url", null));
if (iconDisabledURL == null || iconDisabledURL.isEmpty()) {
String icon = SkillConfigManager.getRaw(skill, "icon-disabled", SkillConfigManager.getRaw(skill, "icon_disabled", null));
if (icon != null && !icon.isEmpty()) {
if (icon.startsWith("http://")) {
config.set("icon_disabled_url", icon);
} else {
config.set("icon_disabled", icon);
}
}
} else {
config.set("icon_disabled_url", iconDisabledURL);
}
String nameTemplate = controller.getMessages().get("skills.item_name", "$skill");
String skillDisplayName = SkillConfigManager.getRaw(skill, "name", skill.getName());
config.set("name", nameTemplate.replace("$skill", skillDisplayName));
config.set("category", "skills");
String descriptionTemplate = controller.getMessages().get("skills.item_description", "$description");
descriptionTemplate = descriptionTemplate.replace("$description", SkillConfigManager.getRaw(skill, "description", ""));
config.set("description", descriptionTemplate);
newSpell.loadTemplate("heroes*" + skillName, config);
return newSpell;
}
use of com.herocraftonline.heroes.characters.skill.Skill in project MagicPlugin by elBukkit.
the class HeroesManager method mapSkillsByLevel.
private Multimap<Integer, Skill> mapSkillsByLevel(Hero hero, Collection<String> skillNames) {
Multimap<Integer, Skill> skillMap = TreeMultimap.create(Ordering.natural(), new Comparator<Skill>() {
@Override
public int compare(Skill skill1, Skill skill2) {
return skill1.getName().compareTo(skill2.getName());
}
});
for (String skillName : skillNames) {
Skill skill = skills.getSkill(skillName);
if (skill == null)
continue;
int level = SkillConfigManager.getUseSetting(hero, skill, SkillSetting.LEVEL, 1, true);
skillMap.put(level, skill);
}
return skillMap;
}
Aggregations