Supporting Pull Request Deletion without breaking 5.0.X functionality

I’m working on a plugin that uses the atlassian event listener to trigger actions on the various com.atlassian.bitbucket.event.pull.* events (such as PullRequestOpenedEvent or PullRequestDeclinedEvent). I want to include the PullRequestDeletedEvent introduced in Bitbucket Server 5.1.0 but setting up an eventlistener causes java.lang.ClassNotFoundException: com.atlassian.bitbucket.event.pull.PullRequestDeletedEvent for earlier versions of Bitbucket Server 5. Is there a way to service PR Deletion events without breaking backwards compatibility, at least for Bitbucket 5.0.X?

My code is located at https://github.com/KyleLNicholls/parameterized-builds and the class that handles PR events is com.kylenicholls.stash.parameterizedbuilds.PullRequestHook if that helps get a sense of what I’m trying to accomplish.

Sometimes I use reflection to maintain reverse-compatibility.

Sometimes I query the running Bitbucket version and maintain two code paths. Example:

import com.atlassian.bitbucket.util.Version;

private static final Version BITBUCKET_4_4_0 = new Version(4, 4, 0);

Version runningVersion = new Version(propertiesService.getBuildVersion());
boolean atLeast440 = runningVersion.compareTo(BITBUCKET_4_4_0) >= 0;