Validate plugin dependency IDs in accordance to plugin ID requirements (#1231)

This commit is contained in:
itsTyrion
2024-02-08 03:30:55 +01:00
committed by GitHub
parent 5956751284
commit 10430a2115
2 changed files with 19 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ package com.velocitypowered.api.plugin.ap;
import com.google.auto.service.AutoService;
import com.google.gson.Gson;
import com.velocitypowered.api.plugin.Dependency;
import com.velocitypowered.api.plugin.Plugin;
import java.io.BufferedWriter;
import java.io.IOException;
@@ -87,6 +88,16 @@ public class PluginAnnotationProcessor extends AbstractProcessor {
return false;
}
for (Dependency dependency : plugin.dependencies()) {
if (!SerializedPluginDescription.ID_PATTERN.matcher(dependency.id()).matches()) {
environment.getMessager().printMessage(Diagnostic.Kind.ERROR,
"Invalid dependency ID '" + dependency.id() + "' for plugin " + qualifiedName
+ ". IDs must start alphabetically, have lowercase alphanumeric characters, and "
+ "can contain dashes or underscores.");
return false;
}
}
// All good, generate the velocity-plugin.json.
SerializedPluginDescription description = SerializedPluginDescription
.from(plugin, qualifiedName.toString());