Skip to content

Commit 51f6e5f

Browse files
committed
Declare that event listeners do not have to be public
1 parent f9f2102 commit 51f6e5f

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

src/ap/java/org/spongepowered/plugin/processor/ListenerProcessor.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
import javax.lang.model.util.Types;
5858

5959
@SupportedAnnotationTypes(ListenerProcessor.LISTENER_ANNOTATION_CLASS)
60-
@SupportedSourceVersion(SourceVersion.RELEASE_8)
60+
@SupportedSourceVersion(SourceVersion.RELEASE_16)
6161
public class ListenerProcessor extends AbstractProcessor {
6262

6363
static final String LISTENER_ANNOTATION_CLASS = "org.spongepowered.api.event.Listener";
@@ -86,24 +86,21 @@ public boolean process(final Set<? extends TypeElement> annotations, final Round
8686
final ExecutableElement method = (ExecutableElement) e;
8787

8888
if (method.getModifiers().contains(Modifier.STATIC)) {
89-
this.error("method must not be static", method);
90-
}
91-
if (!method.getModifiers().contains(Modifier.PUBLIC)) {
92-
this.error("method must be public", method);
89+
this.error("Event listener method must not be static", method);
9390
}
9491
if (method.getModifiers().contains(Modifier.ABSTRACT)) {
95-
this.error("method must not be abstract", method);
92+
this.error("Event listener method must not be abstract", method);
9693
}
9794
if (method.getEnclosingElement().getKind().isInterface()) {
9895
this.error("interfaces cannot declare listeners", method);
9996
}
10097
if (method.getReturnType().getKind() != TypeKind.VOID) {
101-
this.error("method must return void", method);
98+
this.error("Event listener method must return void", method);
10299
}
103100
final List<? extends VariableElement> parameters = method.getParameters();
104101
final DeclaredType eventType;
105102
if (parameters.isEmpty() || !this.isTypeSubclass(parameters.get(0), ListenerProcessor.EVENT_CLASS)) {
106-
this.error("method must have an Event as its first parameter", method);
103+
this.error("Event listener method must have an Event as its first parameter", method);
107104
eventType = null;
108105
} else {
109106
eventType = (DeclaredType) parameters.get(0).asType();

src/main/java/org/spongepowered/api/event/EventManager.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ public interface EventManager {
3636
* Registers {@link Event} methods annotated with @{@link Listener} in the
3737
* specified object.
3838
*
39-
* <p>Only methods that are public will be registered and the class must be
40-
* public as well.</p>
39+
* <p>This will not include any methods declared in supertypes, but will
40+
* test for private and package-private listener methods.</p>
4141
*
42-
* @param plugin The plugin instance
42+
* @param plugin The plugin container
4343
* @param obj The object
44-
* @throws IllegalArgumentException Thrown if {@code plugin} is not a plugin
45-
* instance
4644
*/
4745
void registerListeners(PluginContainer plugin, Object obj);
4846

src/main/java/org/spongepowered/api/event/Listener.java

-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232

3333
/**
3434
* Used to annotate a method as an {@link EventListener}.
35-
*
36-
* <p>The method being targeted must be public and must be in a class that is
37-
* also public.</p>
3835
*/
3936
@Retention(RUNTIME)
4037
@Target(METHOD)

0 commit comments

Comments
 (0)