diff --git a/api/src/ap/java/com/velocitypowered/api/plugin/ap/SerializedPluginDescription.java b/api/src/ap/java/com/velocitypowered/api/plugin/ap/SerializedPluginDescription.java index 12109985e..925074cc2 100644 --- a/api/src/ap/java/com/velocitypowered/api/plugin/ap/SerializedPluginDescription.java +++ b/api/src/ap/java/com/velocitypowered/api/plugin/ap/SerializedPluginDescription.java @@ -16,15 +16,18 @@ public class SerializedPluginDescription { private final String id; private final @Nullable String name; private final @Nullable String version; + private final @Nullable String description; private final @Nullable String url; private final @Nullable List authors; private final @Nullable List dependencies; private final String main; - public SerializedPluginDescription(String id, String name, String version, String url, List authors, List dependencies, String main) { + public SerializedPluginDescription(String id, String name, String version, String description, String url, + List authors, List dependencies, String main) { this.id = Preconditions.checkNotNull(id, "id"); this.name = Strings.emptyToNull(name); this.version = Strings.emptyToNull(version); + this.description = Strings.emptyToNull(description); this.url = Strings.emptyToNull(url); this.authors = authors == null || authors.isEmpty() ? null : authors; this.dependencies = dependencies == null || dependencies.isEmpty() ? null : dependencies; @@ -36,7 +39,7 @@ public class SerializedPluginDescription { for (com.velocitypowered.api.plugin.Dependency dependency : plugin.dependencies()) { dependencies.add(new Dependency(dependency.id(), dependency.optional())); } - return new SerializedPluginDescription(plugin.id(), plugin.name(), plugin.version(), plugin.url(), + return new SerializedPluginDescription(plugin.id(), plugin.name(), plugin.version(), plugin.description(), plugin.url(), Arrays.stream(plugin.authors()).filter(author -> !author.isEmpty()).collect(Collectors.toList()), dependencies, qualifiedName); } @@ -52,6 +55,10 @@ public class SerializedPluginDescription { return version; } + public @Nullable String getDescription() { + return description; + } + public @Nullable String getUrl() { return url; } @@ -76,6 +83,7 @@ public class SerializedPluginDescription { return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(version, that.version) && + Objects.equals(description, that.description) && Objects.equals(url, that.url) && Objects.equals(authors, that.authors) && Objects.equals(dependencies, that.dependencies) && @@ -84,14 +92,16 @@ public class SerializedPluginDescription { @Override public int hashCode() { - return Objects.hash(id, name, version, url, authors, dependencies); + return Objects.hash(id, name, version, description, url, authors, dependencies); } - @Override public String toString() { + @Override + public String toString() { return "SerializedPluginDescription{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", version='" + version + '\'' + + ", description='" + description + '\'' + ", url='" + url + '\'' + ", authors=" + authors + ", dependencies=" + dependencies + diff --git a/api/src/main/java/com/velocitypowered/api/plugin/Plugin.java b/api/src/main/java/com/velocitypowered/api/plugin/Plugin.java index 3b0ab9fe2..b3e603f13 100644 --- a/api/src/main/java/com/velocitypowered/api/plugin/Plugin.java +++ b/api/src/main/java/com/velocitypowered/api/plugin/Plugin.java @@ -36,6 +36,13 @@ public @interface Plugin { */ String version() default ""; + /** + * The description of the plugin, explaining what it can be used for. + * + * @return The plugin description, or an empty string if unknown + */ + String description() default ""; + /** * The URL or website of the plugin. * diff --git a/api/src/main/java/com/velocitypowered/api/plugin/PluginDescription.java b/api/src/main/java/com/velocitypowered/api/plugin/PluginDescription.java index 78a1b5399..d789f68c5 100644 --- a/api/src/main/java/com/velocitypowered/api/plugin/PluginDescription.java +++ b/api/src/main/java/com/velocitypowered/api/plugin/PluginDescription.java @@ -49,6 +49,16 @@ public interface PluginDescription { return Optional.empty(); } + /** + * Gets the description of the {@link Plugin} within this container. + * + * @return an {@link Optional} with the plugin description, may be empty + * @see Plugin#description() + */ + default Optional getDescription() { + return Optional.empty(); + } + /** * Gets the url or website of the {@link Plugin} within this container. * diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/JavaPluginLoader.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/JavaPluginLoader.java index 09ba72397..e1ed51ff8 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/JavaPluginLoader.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/JavaPluginLoader.java @@ -108,6 +108,7 @@ public class JavaPluginLoader implements PluginLoader { description.getId(), description.getName(), description.getVersion(), + description.getDescription(), description.getUrl(), description.getAuthors(), dependencies, diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginDescription.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginDescription.java index 769ed3c41..0ee55c112 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginDescription.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/VelocityPluginDescription.java @@ -19,16 +19,18 @@ public class VelocityPluginDescription implements PluginDescription { private final String id; private final @Nullable String name; private final @Nullable String version; + private final @Nullable String description; private final @Nullable String url; private final List authors; private final Map dependencies; private final Path source; - public VelocityPluginDescription(String id, @Nullable String name, @Nullable String version, @Nullable String url, + public VelocityPluginDescription(String id, @Nullable String name, @Nullable String version, @Nullable String description, @Nullable String url, @Nullable List authors, Collection dependencies, Path source) { this.id = checkNotNull(id, "id"); this.name = Strings.emptyToNull(name); this.version = Strings.emptyToNull(version); + this.description = Strings.emptyToNull(description); this.url = Strings.emptyToNull(url); this.authors = authors == null ? ImmutableList.of() : ImmutableList.copyOf(authors); this.dependencies = Maps.uniqueIndex(dependencies, PluginDependency::getId); @@ -50,6 +52,11 @@ public class VelocityPluginDescription implements PluginDescription { return Optional.ofNullable(version); } + @Override + public Optional getDescription() { + return Optional.ofNullable(description); + } + @Override public Optional getUrl() { return Optional.ofNullable(url); @@ -79,8 +86,11 @@ public class VelocityPluginDescription implements PluginDescription { public String toString() { return "VelocityPluginDescription{" + "id='" + id + '\'' + + ", name='" + name + '\'' + ", version='" + version + '\'' + - ", authors='" + authors + '\'' + + ", description='" + description + '\'' + + ", url='" + url + '\'' + + ", authors=" + authors + ", dependencies=" + dependencies + ", source=" + source + '}'; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaVelocityPluginDescription.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaVelocityPluginDescription.java index a827dc202..a73aaec78 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaVelocityPluginDescription.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/JavaVelocityPluginDescription.java @@ -2,6 +2,7 @@ package com.velocitypowered.proxy.plugin.loader.java; import com.velocitypowered.api.plugin.meta.PluginDependency; import com.velocitypowered.proxy.plugin.loader.VelocityPluginDescription; +import org.checkerframework.checker.nullness.qual.Nullable; import java.nio.file.Path; import java.util.Collection; @@ -12,9 +13,9 @@ import static com.google.common.base.Preconditions.checkNotNull; public class JavaVelocityPluginDescription extends VelocityPluginDescription { private final Class mainClass; - public JavaVelocityPluginDescription(String id, String name, String version, String url, List authors, - Collection dependencies, Path source, Class mainClass) { - super(id, name, version, url, authors, dependencies, source); + public JavaVelocityPluginDescription(String id, @Nullable String name, @Nullable String version, @Nullable String description, @Nullable String url, + @Nullable List authors, Collection dependencies, Path source, Class mainClass) { + super(id, name, version, description, url, authors, dependencies, source); this.mainClass = checkNotNull(mainClass); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/SerializedPluginDescription.java b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/SerializedPluginDescription.java index 9e60f40ef..b12b1694e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/SerializedPluginDescription.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/plugin/loader/java/SerializedPluginDescription.java @@ -16,15 +16,18 @@ public class SerializedPluginDescription { private final String id; private final @Nullable String name; private final @Nullable String version; + private final @Nullable String description; private final @Nullable String url; private final @Nullable List authors; private final @Nullable List dependencies; private final String main; - public SerializedPluginDescription(String id, String name, String version, String url, List authors, List dependencies, String main) { + public SerializedPluginDescription(String id, String name, String version, String description, String url, + List authors, List dependencies, String main) { this.id = Preconditions.checkNotNull(id, "id"); this.name = Strings.emptyToNull(name); this.version = Strings.emptyToNull(version); + this.description = Strings.emptyToNull(description); this.url = Strings.emptyToNull(url); this.authors = authors == null || authors.isEmpty() ? null : authors; this.dependencies = dependencies == null || dependencies.isEmpty() ? null : dependencies; @@ -36,7 +39,7 @@ public class SerializedPluginDescription { for (com.velocitypowered.api.plugin.Dependency dependency : plugin.dependencies()) { dependencies.add(new Dependency(dependency.id(), dependency.optional())); } - return new SerializedPluginDescription(plugin.id(), plugin.name(), plugin.version(), plugin.url(), + return new SerializedPluginDescription(plugin.id(), plugin.name(), plugin.version(), plugin.description(), plugin.url(), Arrays.stream(plugin.authors()).filter(author -> !author.isEmpty()).collect(Collectors.toList()), dependencies, qualifiedName); } @@ -52,6 +55,10 @@ public class SerializedPluginDescription { return version; } + public @Nullable String getDescription() { + return description; + } + public @Nullable String getUrl() { return url; } @@ -76,6 +83,7 @@ public class SerializedPluginDescription { return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(version, that.version) && + Objects.equals(description, that.description) && Objects.equals(url, that.url) && Objects.equals(authors, that.authors) && Objects.equals(dependencies, that.dependencies) && @@ -84,14 +92,16 @@ public class SerializedPluginDescription { @Override public int hashCode() { - return Objects.hash(id, name, version, url, authors, dependencies); + return Objects.hash(id, name, version, description, url, authors, dependencies); } - @Override public String toString() { + @Override + public String toString() { return "SerializedPluginDescription{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", version='" + version + '\'' + + ", description='" + description + '\'' + ", url='" + url + '\'' + ", authors=" + authors + ", dependencies=" + dependencies +