Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Validate plugin dependency IDs in accordance to plugin ID requirements (#1231)
Dieser Commit ist enthalten in:
Ursprung
5956751284
Commit
10430a2115
@ -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());
|
||||
|
@ -72,6 +72,14 @@ public class JavaPluginLoader implements PluginLoader {
|
||||
throw new InvalidPluginException("Plugin ID '" + pd.getId() + "' is invalid.");
|
||||
}
|
||||
|
||||
for (SerializedPluginDescription.Dependency dependency : pd.getDependencies()) {
|
||||
if (!SerializedPluginDescription.ID_PATTERN.matcher(dependency.getId()).matches()) {
|
||||
throw new InvalidPluginException(
|
||||
"Dependency ID '" + dependency.getId() + "' for plugin '" + pd.getId() + "' is invalid."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return createCandidateDescription(pd, source);
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren