/**
   * Register an event. python-facing. this version converts from string info.
   *
   * @param handler function handler
   * @param type Event type string
   * @param priority Event priority string
   */
  public void registerEvent(PyObject handler, PyString type, PyString priority) {
    try {
      String clazz = type.asString();
      Class<?> event = null;

      if (clazz.contains(".")) {
        try {
          // try if we can find the class
          event = Class.forName(clazz);
        } catch (ClassNotFoundException e) {
          // assume the subpackage and class name was given and append org.bukkit.event
          event = Class.forName("org.bukkit.event." + clazz);
        }
      } else if (customEvents.containsKey(clazz)) {
        // check if the name of a custom event was given
        event = customEvents.get(clazz);
      } else {
        throw new IllegalArgumentException("Could not find Event " + clazz);
      }

      if (!event.getClass().isInstance(event)) {
        throw new IllegalArgumentException(type.asString().toUpperCase() + " is not of type Event");
      }
      Class<? extends Event> realtype = (Class<? extends Event>) event;
      EventPriority realpriority = EventPriority.valueOf(priority.upper());
      registerEvent(handler, realtype, realpriority);

    } catch (ClassNotFoundException e) {
      Bukkit.getLogger()
          .log(
              Level.SEVERE,
              "Could not register event " + type + " because the event could not be found",
              e);
    }
  }