Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map.Entry;
- import net.minecraft.src.Item;
- import net.minecraft.src.ItemStack;
- /**
- *
- * @author Duke605
- *
- */
- public class InformationAPI{
- private static HashMap<String, IInformationAPI> modArray = new HashMap<String, IInformationAPI>();
- /**
- * Registers a class for information API method call
- *
- * @param modClass the class you wish to register
- */
- public static void register(IInformationAPI modClass){
- if (modClass != null && !modArray.containsKey(modClass.getClass().getSimpleName()))
- modArray.put(modClass.getClass().getSimpleName(), modClass);
- else if (modClass == null)
- System.out.println("You cannot register NULL.");
- else if (modArray.containsKey(modClass.getClass().getSimpleName()))
- System.err.println(modClass.getClass().getSimpleName() + " is already registered.");
- else
- System.err.println("An impossiable error occured!");
- }
- /**
- * Unregisters a class for information API method call
- *
- * @param modClass the class you wish to unregister
- */
- public static void unregister(IInformationAPI modClass){
- modArray.remove(modClass.getClass().getSimpleName());
- }
- /**
- * Called by GuiContainer, calls all addInformation method from all classes in modArray
- *
- * @param itemstack The item stack
- * @param item Done for convince. Equivalent of "itemstack.getItem()"
- * @param list The information list
- */
- public static void addInfo(ItemStack itemstack, Item item, List list){
- for (Entry<String, IInformationAPI> i: modArray.entrySet()){
- i.getValue().addInformation(itemstack, item, list);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment