13
0
geforkt von Mirrors/Velocity

Add plugin description

Dieser Commit ist enthalten in:
Minecrell 2018-08-21 21:18:10 +02:00
Ursprung 830b1d4798
Commit c43c6cbea2
7 geänderte Dateien mit 62 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -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<String> authors;
private final @Nullable List<Dependency> dependencies;
private final String main;
public SerializedPluginDescription(String id, String name, String version, String url, List<String> authors, List<Dependency> dependencies, String main) {
public SerializedPluginDescription(String id, String name, String version, String description, String url,
List<String> authors, List<Dependency> 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 +

Datei anzeigen

@ -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.
*

Datei anzeigen

@ -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<String> getDescription() {
return Optional.empty();
}
/**
* Gets the url or website of the {@link Plugin} within this container.
*

Datei anzeigen

@ -108,6 +108,7 @@ public class JavaPluginLoader implements PluginLoader {
description.getId(),
description.getName(),
description.getVersion(),
description.getDescription(),
description.getUrl(),
description.getAuthors(),
dependencies,

Datei anzeigen

@ -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<String> authors;
private final Map<String, PluginDependency> 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<String> authors, Collection<PluginDependency> 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<String> getDescription() {
return Optional.ofNullable(description);
}
@Override
public Optional<String> 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 +
'}';

Datei anzeigen

@ -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<String> authors,
Collection<PluginDependency> 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<String> authors, Collection<PluginDependency> dependencies, Path source, Class<?> mainClass) {
super(id, name, version, description, url, authors, dependencies, source);
this.mainClass = checkNotNull(mainClass);
}

Datei anzeigen

@ -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<String> authors;
private final @Nullable List<Dependency> dependencies;
private final String main;
public SerializedPluginDescription(String id, String name, String version, String url, List<String> authors, List<Dependency> dependencies, String main) {
public SerializedPluginDescription(String id, String name, String version, String description, String url,
List<String> authors, List<Dependency> 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 +