package com.projectkorra.ProjectKorra.Ability; import java.io.File; import java.util.HashMap; import java.util.HashSet; import java.util.List; import com.projectkorra.ProjectKorra.Element; import com.projectkorra.ProjectKorra.ProjectKorra; import com.projectkorra.ProjectKorra.Utilities.AbilityLoader; public class AbilityModuleManager { static ProjectKorra plugin; public static List ability; private final AbilityLoader loader; public static HashSet abilities; public static HashSet waterbendingabilities; public static HashSet airbendingabilities; public static HashSet earthbendingabilities; public static HashSet firebendingabilities; public static HashSet chiabilities; public static HashSet shiftabilities; public static HashMap authors; public static HashMap descriptions; public AbilityModuleManager(final ProjectKorra plugin) { AbilityModuleManager.plugin = plugin; final File path = new File(plugin.getDataFolder().toString() + "/Abilities/"); if (!path.exists()) { path.mkdir(); } loader = new AbilityLoader(plugin, path, new Object[] {}); abilities = new HashSet(); waterbendingabilities = new HashSet(); airbendingabilities = new HashSet(); earthbendingabilities = new HashSet(); firebendingabilities = new HashSet(); chiabilities = new HashSet(); shiftabilities = new HashSet(); descriptions = new HashMap(); authors = new HashMap(); ability = loader.load(AbilityModule.class); fill(); } private void fill() { for (AbilityModule ab: ability) { ab.onThisLoad(); abilities.add(ab.getName()); if (ab.getElement() == Element.Air.toString()) airbendingabilities.add(ab.getName()); if (ab.getElement() == Element.Water.toString()) waterbendingabilities.add(ab.getName()); if (ab.getElement() == Element.Earth.toString()) earthbendingabilities.add(ab.getName()); if (ab.getElement() == Element.Fire.toString()) firebendingabilities.add(ab.getName()); if (ab.getElement() == Element.Chi.toString()) chiabilities.add(ab.getName()); if (ab.isShiftAbility()) shiftabilities.add(ab.getName()); descriptions.put(ab.getName(), ab.getDescription()); authors.put(ab.getName(), ab.getAuthor()); } } }