@@ -121,24 +121,27 @@ private static void checkThenWarnIfDeprecatedEvent(Plugin plugin, Class<? extend
121121 Warning .WarningState warningState = plugin .getServer ().getWarningState ();
122122 Optional <Warning > warning = annotation (clazz , Warning .class );
123123
124- // Differs from bukkit: always print warnings unless explicitly turned off.
125- if ( warningState == Warning .WarningState .OFF ) { break ; }
124+ boolean shouldBeWarned = warning . filter ( Warning :: value ). isPresent ();
125+ boolean canBeWarned = warningState != Warning .WarningState .OFF ;
126126
127- plugin .getLogger ().log (
128- Level .WARNING ,
129- String .format (
130- "%s has registered a listener for %s, but the event is deprecated (%s). %s." ,
131- plugin .getDescription ().getFullName (),
132- eventType .getSimpleName (),
133- clazz .getName (),
134- warning .map (Warning ::reason )
135- .filter (Predicate .not (String ::isBlank ))
136- .orElse ("Server performance will be affected" )
137- ),
138- (warningState == Warning .WarningState .ON ) ? new AuthorNagException (null ) : null
139- );
140-
141- return ;
127+ if (shouldBeWarned && canBeWarned )
128+ {
129+ plugin .getLogger ().log (
130+ Level .WARNING ,
131+ String .format (
132+ "%s has registered a listener for %s, but the event is deprecated (%s). %s." ,
133+ plugin .getDescription ().getFullName (),
134+ eventType .getSimpleName (),
135+ clazz .getName (),
136+ warning .map (Warning ::reason )
137+ .filter (Predicate .not (String ::isBlank ))
138+ .orElse ("Server performance will be affected" )
139+ ),
140+ (warningState == Warning .WarningState .ON ) ? new AuthorNagException (null ) : null
141+ );
142+
143+ return ; // already warned, don't spam
144+ }
142145 }
143146 }
144147
0 commit comments