private void gatherAnnotations(Class<?> clazz) {

        try {

            // Loops through all methods
            for (Method method : clazz.newInstance().getClass().getDeclaredMethods()) {

                // checks for methods using the @EventHandler interface
                if (method.isAnnotationPresent(Module.EventHandler.class)) {

                    // Creates an array of classes used for parameter types.
                    Class<?>[] parameterTypes = method.getParameterTypes();
                    // Makes sure that there is only one parameter in the
                    // method.
                    if (parameterTypes.length != 1)
                        throw new IllegalArgumentException("Method " + method + " has @EventHandler annotation, but contains " + parameterTypes.length + " arguments. Methods using the @EventHandler annotation can only use a single argument.");

                    // Creates an Event class to use as a key in the map.
                    Class eventType = parameterTypes[0];
                    // Checks if the event parameter is appropriate.
                    if (!Event.class.isAssignableFrom(eventType))
                        throw new IllegalArgumentException("Method " + method + " has @EventHandler annotation, but takes an argument that is not an Event " + eventType);

                    // Retrieves a list of existing events under this key.
                    ArrayList<Method> others = eventMethods.get(eventType);

                    // Creates the entry if it does not exist.
                    if (others == null) {

                        others = new ArrayList<Method>();
                        eventMethods.put(eventType, others);
                    }
                    // Adds the method to the array of methods for this type.
                    others.add(method);
                }
            }
        }

        catch (InstantiationException e) {

            e.printStackTrace();
        }

        catch (IllegalAccessException e) {

            e.printStackTrace();
        }
    }