Prioritize new Rule annotation when parsing if both are present
This commit is contained in:
1 file changed
+4
-4
@@ -149,12 +149,12 @@ public final class ParsedRule<T> implements CarpetRule<T>, Comparable<ParsedRule
|
||||
@Deprecated(forRemoval = true)
|
||||
public static <T> ParsedRule<T> of(Field field, SettingsManager settingsManager) {
|
||||
RuleAnnotation rule;
|
||||
if (settingsManager instanceof carpet.settings.SettingsManager && field.isAnnotationPresent(Rule.class)) { // Legacy path
|
||||
Rule a = field.getAnnotation(Rule.class);
|
||||
rule = new RuleAnnotation(true, a.name(), a.desc(), a.extra(), a.category(), a.options(), a.strict(), a.appSource(), a.validate());
|
||||
} else if (field.isAnnotationPresent(carpet.api.settings.Rule.class)) {
|
||||
if (field.isAnnotationPresent(carpet.api.settings.Rule.class)) {
|
||||
carpet.api.settings.Rule a = field.getAnnotation(carpet.api.settings.Rule.class);
|
||||
rule = new RuleAnnotation(false, null, null, null, a.categories(), a.options(), a.strict(), a.appSource(), a.validators());
|
||||
} else if (settingsManager instanceof carpet.settings.SettingsManager && field.isAnnotationPresent(Rule.class)) { // Legacy path
|
||||
Rule a = field.getAnnotation(Rule.class);
|
||||
rule = new RuleAnnotation(true, a.name(), a.desc(), a.extra(), a.category(), a.options(), a.strict(), a.appSource(), a.validate());
|
||||
} else {
|
||||
// Don't allow to use old rule types in custom AND migrated settings manager
|
||||
throw new IllegalArgumentException("Old rule annotation is only supported in legacy SettngsManager!");
|
||||
|
||||
Reference in new issue
Block a user