Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-06 00:00:47 +01:00
Add plugin description
Dieser Commit ist enthalten in:
Ursprung
830b1d4798
Commit
c43c6cbea2
@ -16,15 +16,18 @@ public class SerializedPluginDescription {
|
|||||||
private final String id;
|
private final String id;
|
||||||
private final @Nullable String name;
|
private final @Nullable String name;
|
||||||
private final @Nullable String version;
|
private final @Nullable String version;
|
||||||
|
private final @Nullable String description;
|
||||||
private final @Nullable String url;
|
private final @Nullable String url;
|
||||||
private final @Nullable List<String> authors;
|
private final @Nullable List<String> authors;
|
||||||
private final @Nullable List<Dependency> dependencies;
|
private final @Nullable List<Dependency> dependencies;
|
||||||
private final String main;
|
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.id = Preconditions.checkNotNull(id, "id");
|
||||||
this.name = Strings.emptyToNull(name);
|
this.name = Strings.emptyToNull(name);
|
||||||
this.version = Strings.emptyToNull(version);
|
this.version = Strings.emptyToNull(version);
|
||||||
|
this.description = Strings.emptyToNull(description);
|
||||||
this.url = Strings.emptyToNull(url);
|
this.url = Strings.emptyToNull(url);
|
||||||
this.authors = authors == null || authors.isEmpty() ? null : authors;
|
this.authors = authors == null || authors.isEmpty() ? null : authors;
|
||||||
this.dependencies = dependencies == null || dependencies.isEmpty() ? null : dependencies;
|
this.dependencies = dependencies == null || dependencies.isEmpty() ? null : dependencies;
|
||||||
@ -36,7 +39,7 @@ public class SerializedPluginDescription {
|
|||||||
for (com.velocitypowered.api.plugin.Dependency dependency : plugin.dependencies()) {
|
for (com.velocitypowered.api.plugin.Dependency dependency : plugin.dependencies()) {
|
||||||
dependencies.add(new Dependency(dependency.id(), dependency.optional()));
|
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);
|
Arrays.stream(plugin.authors()).filter(author -> !author.isEmpty()).collect(Collectors.toList()), dependencies, qualifiedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +55,10 @@ public class SerializedPluginDescription {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable String getUrl() {
|
public @Nullable String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@ -76,6 +83,7 @@ public class SerializedPluginDescription {
|
|||||||
return Objects.equals(id, that.id) &&
|
return Objects.equals(id, that.id) &&
|
||||||
Objects.equals(name, that.name) &&
|
Objects.equals(name, that.name) &&
|
||||||
Objects.equals(version, that.version) &&
|
Objects.equals(version, that.version) &&
|
||||||
|
Objects.equals(description, that.description) &&
|
||||||
Objects.equals(url, that.url) &&
|
Objects.equals(url, that.url) &&
|
||||||
Objects.equals(authors, that.authors) &&
|
Objects.equals(authors, that.authors) &&
|
||||||
Objects.equals(dependencies, that.dependencies) &&
|
Objects.equals(dependencies, that.dependencies) &&
|
||||||
@ -84,14 +92,16 @@ public class SerializedPluginDescription {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
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{" +
|
return "SerializedPluginDescription{" +
|
||||||
"id='" + id + '\'' +
|
"id='" + id + '\'' +
|
||||||
", name='" + name + '\'' +
|
", name='" + name + '\'' +
|
||||||
", version='" + version + '\'' +
|
", version='" + version + '\'' +
|
||||||
|
", description='" + description + '\'' +
|
||||||
", url='" + url + '\'' +
|
", url='" + url + '\'' +
|
||||||
", authors=" + authors +
|
", authors=" + authors +
|
||||||
", dependencies=" + dependencies +
|
", dependencies=" + dependencies +
|
||||||
|
@ -36,6 +36,13 @@ public @interface Plugin {
|
|||||||
*/
|
*/
|
||||||
String version() default "";
|
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.
|
* The URL or website of the plugin.
|
||||||
*
|
*
|
||||||
|
@ -49,6 +49,16 @@ public interface PluginDescription {
|
|||||||
return Optional.empty();
|
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.
|
* Gets the url or website of the {@link Plugin} within this container.
|
||||||
*
|
*
|
||||||
|
@ -108,6 +108,7 @@ public class JavaPluginLoader implements PluginLoader {
|
|||||||
description.getId(),
|
description.getId(),
|
||||||
description.getName(),
|
description.getName(),
|
||||||
description.getVersion(),
|
description.getVersion(),
|
||||||
|
description.getDescription(),
|
||||||
description.getUrl(),
|
description.getUrl(),
|
||||||
description.getAuthors(),
|
description.getAuthors(),
|
||||||
dependencies,
|
dependencies,
|
||||||
|
@ -19,16 +19,18 @@ public class VelocityPluginDescription implements PluginDescription {
|
|||||||
private final String id;
|
private final String id;
|
||||||
private final @Nullable String name;
|
private final @Nullable String name;
|
||||||
private final @Nullable String version;
|
private final @Nullable String version;
|
||||||
|
private final @Nullable String description;
|
||||||
private final @Nullable String url;
|
private final @Nullable String url;
|
||||||
private final List<String> authors;
|
private final List<String> authors;
|
||||||
private final Map<String, PluginDependency> dependencies;
|
private final Map<String, PluginDependency> dependencies;
|
||||||
private final Path source;
|
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) {
|
@Nullable List<String> authors, Collection<PluginDependency> dependencies, Path source) {
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = checkNotNull(id, "id");
|
||||||
this.name = Strings.emptyToNull(name);
|
this.name = Strings.emptyToNull(name);
|
||||||
this.version = Strings.emptyToNull(version);
|
this.version = Strings.emptyToNull(version);
|
||||||
|
this.description = Strings.emptyToNull(description);
|
||||||
this.url = Strings.emptyToNull(url);
|
this.url = Strings.emptyToNull(url);
|
||||||
this.authors = authors == null ? ImmutableList.of() : ImmutableList.copyOf(authors);
|
this.authors = authors == null ? ImmutableList.of() : ImmutableList.copyOf(authors);
|
||||||
this.dependencies = Maps.uniqueIndex(dependencies, PluginDependency::getId);
|
this.dependencies = Maps.uniqueIndex(dependencies, PluginDependency::getId);
|
||||||
@ -50,6 +52,11 @@ public class VelocityPluginDescription implements PluginDescription {
|
|||||||
return Optional.ofNullable(version);
|
return Optional.ofNullable(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<String> getDescription() {
|
||||||
|
return Optional.ofNullable(description);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> getUrl() {
|
public Optional<String> getUrl() {
|
||||||
return Optional.ofNullable(url);
|
return Optional.ofNullable(url);
|
||||||
@ -79,8 +86,11 @@ public class VelocityPluginDescription implements PluginDescription {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "VelocityPluginDescription{" +
|
return "VelocityPluginDescription{" +
|
||||||
"id='" + id + '\'' +
|
"id='" + id + '\'' +
|
||||||
|
", name='" + name + '\'' +
|
||||||
", version='" + version + '\'' +
|
", version='" + version + '\'' +
|
||||||
", authors='" + authors + '\'' +
|
", description='" + description + '\'' +
|
||||||
|
", url='" + url + '\'' +
|
||||||
|
", authors=" + authors +
|
||||||
", dependencies=" + dependencies +
|
", dependencies=" + dependencies +
|
||||||
", source=" + source +
|
", source=" + source +
|
||||||
'}';
|
'}';
|
||||||
|
@ -2,6 +2,7 @@ package com.velocitypowered.proxy.plugin.loader.java;
|
|||||||
|
|
||||||
import com.velocitypowered.api.plugin.meta.PluginDependency;
|
import com.velocitypowered.api.plugin.meta.PluginDependency;
|
||||||
import com.velocitypowered.proxy.plugin.loader.VelocityPluginDescription;
|
import com.velocitypowered.proxy.plugin.loader.VelocityPluginDescription;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -12,9 +13,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
public class JavaVelocityPluginDescription extends VelocityPluginDescription {
|
public class JavaVelocityPluginDescription extends VelocityPluginDescription {
|
||||||
private final Class<?> mainClass;
|
private final Class<?> mainClass;
|
||||||
|
|
||||||
public JavaVelocityPluginDescription(String id, String name, String version, String url, List<String> authors,
|
public JavaVelocityPluginDescription(String id, @Nullable String name, @Nullable String version, @Nullable String description, @Nullable String url,
|
||||||
Collection<PluginDependency> dependencies, Path source, Class<?> mainClass) {
|
@Nullable List<String> authors, Collection<PluginDependency> dependencies, Path source, Class<?> mainClass) {
|
||||||
super(id, name, version, url, authors, dependencies, source);
|
super(id, name, version, description, url, authors, dependencies, source);
|
||||||
this.mainClass = checkNotNull(mainClass);
|
this.mainClass = checkNotNull(mainClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,15 +16,18 @@ public class SerializedPluginDescription {
|
|||||||
private final String id;
|
private final String id;
|
||||||
private final @Nullable String name;
|
private final @Nullable String name;
|
||||||
private final @Nullable String version;
|
private final @Nullable String version;
|
||||||
|
private final @Nullable String description;
|
||||||
private final @Nullable String url;
|
private final @Nullable String url;
|
||||||
private final @Nullable List<String> authors;
|
private final @Nullable List<String> authors;
|
||||||
private final @Nullable List<Dependency> dependencies;
|
private final @Nullable List<Dependency> dependencies;
|
||||||
private final String main;
|
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.id = Preconditions.checkNotNull(id, "id");
|
||||||
this.name = Strings.emptyToNull(name);
|
this.name = Strings.emptyToNull(name);
|
||||||
this.version = Strings.emptyToNull(version);
|
this.version = Strings.emptyToNull(version);
|
||||||
|
this.description = Strings.emptyToNull(description);
|
||||||
this.url = Strings.emptyToNull(url);
|
this.url = Strings.emptyToNull(url);
|
||||||
this.authors = authors == null || authors.isEmpty() ? null : authors;
|
this.authors = authors == null || authors.isEmpty() ? null : authors;
|
||||||
this.dependencies = dependencies == null || dependencies.isEmpty() ? null : dependencies;
|
this.dependencies = dependencies == null || dependencies.isEmpty() ? null : dependencies;
|
||||||
@ -36,7 +39,7 @@ public class SerializedPluginDescription {
|
|||||||
for (com.velocitypowered.api.plugin.Dependency dependency : plugin.dependencies()) {
|
for (com.velocitypowered.api.plugin.Dependency dependency : plugin.dependencies()) {
|
||||||
dependencies.add(new Dependency(dependency.id(), dependency.optional()));
|
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);
|
Arrays.stream(plugin.authors()).filter(author -> !author.isEmpty()).collect(Collectors.toList()), dependencies, qualifiedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +55,10 @@ public class SerializedPluginDescription {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable String getUrl() {
|
public @Nullable String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@ -76,6 +83,7 @@ public class SerializedPluginDescription {
|
|||||||
return Objects.equals(id, that.id) &&
|
return Objects.equals(id, that.id) &&
|
||||||
Objects.equals(name, that.name) &&
|
Objects.equals(name, that.name) &&
|
||||||
Objects.equals(version, that.version) &&
|
Objects.equals(version, that.version) &&
|
||||||
|
Objects.equals(description, that.description) &&
|
||||||
Objects.equals(url, that.url) &&
|
Objects.equals(url, that.url) &&
|
||||||
Objects.equals(authors, that.authors) &&
|
Objects.equals(authors, that.authors) &&
|
||||||
Objects.equals(dependencies, that.dependencies) &&
|
Objects.equals(dependencies, that.dependencies) &&
|
||||||
@ -84,14 +92,16 @@ public class SerializedPluginDescription {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
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{" +
|
return "SerializedPluginDescription{" +
|
||||||
"id='" + id + '\'' +
|
"id='" + id + '\'' +
|
||||||
", name='" + name + '\'' +
|
", name='" + name + '\'' +
|
||||||
", version='" + version + '\'' +
|
", version='" + version + '\'' +
|
||||||
|
", description='" + description + '\'' +
|
||||||
", url='" + url + '\'' +
|
", url='" + url + '\'' +
|
||||||
", authors=" + authors +
|
", authors=" + authors +
|
||||||
", dependencies=" + dependencies +
|
", dependencies=" + dependencies +
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren