From 12958737fab6a9b931e6f477380267930c51f121 Mon Sep 17 00:00:00 2001 From: Jack Lin Date: Tue, 4 Aug 2015 13:10:43 +1200 Subject: [PATCH] Add getAbility() to CoreAbility to prevent overlooping --- .../projectkorra/ability/api/CoreAbility.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/com/projectkorra/projectkorra/ability/api/CoreAbility.java b/src/com/projectkorra/projectkorra/ability/api/CoreAbility.java index e8020e21..aeba9bad 100644 --- a/src/com/projectkorra/projectkorra/ability/api/CoreAbility.java +++ b/src/com/projectkorra/projectkorra/ability/api/CoreAbility.java @@ -94,9 +94,22 @@ public abstract class CoreAbility implements Ability { } return null; } + + /** + * Gets the ability instance by its id. + * + * @param id The ability id to get + * @return the ability instance or null + */ + public static final CoreAbility getAbility(int id) { + return instances.get(id); + } /** * An access method to get an the instances of a {@link StockAbility}. + * IMPORTANT: If this is used in a for each loop use + * {@link #getAbility(int)} to get the ability. Incorrect usage may + * cause over looping and is capable of hanging the thead. * * @param ability The instances map to get * @return a map of instances from the specified {@link StockAbility} @@ -114,7 +127,9 @@ public abstract class CoreAbility implements Ability { /** * An access method to get an the instances of a {@link CoreAbility} by its - * class. + * class. IMPORTANT: If this is used in a for each loop use + * {@link #getAbility(int)} to get the ability. Incorrect usage may + * cause over looping and is capable of hanging the thead. * * @param ability The instances map to get * @return a map of instances from the specified class