3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-16 21:10:30 +01:00

Merge pull request #43 from kashike/authors

allow more than one author
Dieser Commit ist enthalten in:
Andrew Steinborn 2018-08-21 13:41:09 -04:00 committet von GitHub
Commit fcf5ad157f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
9 geänderte Dateien mit 50 neuen und 40 gelöschten Zeilen

Datei anzeigen

@ -5,23 +5,25 @@ import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.plugin.Plugin;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
public class SerializedPluginDescription {
private final String id;
private final String author;
private final List<String> authors;
private final String main;
private final String version;
private final List<Dependency> dependencies;
public SerializedPluginDescription(String id, String author, String main, String version) {
public SerializedPluginDescription(String id, List<String> author, String main, String version) {
this(id, author, main, version, ImmutableList.of());
}
public SerializedPluginDescription(String id, String author, String main, String version, List<Dependency> dependencies) {
public SerializedPluginDescription(String id, List<String> authors, String main, String version, List<Dependency> dependencies) {
this.id = Preconditions.checkNotNull(id, "id");
this.author = Preconditions.checkNotNull(author, "author");
this.authors = Preconditions.checkNotNull(authors, "authors");
this.main = Preconditions.checkNotNull(main, "main");
this.version = Preconditions.checkNotNull(version, "version");
this.dependencies = ImmutableList.copyOf(dependencies);
@ -32,15 +34,15 @@ 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.author(), qualifiedName, plugin.version(), dependencies);
return new SerializedPluginDescription(plugin.id(), Arrays.stream(plugin.authors()).filter(author -> !author.isEmpty()).collect(Collectors.toList()), qualifiedName, plugin.version(), dependencies);
}
public String getId() {
return id;
}
public String getAuthor() {
return author;
public List<String> getAuthors() {
return authors;
}
public String getMain() {
@ -61,7 +63,7 @@ public class SerializedPluginDescription {
if (o == null || getClass() != o.getClass()) return false;
SerializedPluginDescription that = (SerializedPluginDescription) o;
return Objects.equals(id, that.id) &&
Objects.equals(author, that.author) &&
Objects.equals(authors, that.authors) &&
Objects.equals(main, that.main) &&
Objects.equals(version, that.version) &&
Objects.equals(dependencies, that.dependencies);
@ -69,14 +71,14 @@ public class SerializedPluginDescription {
@Override
public int hashCode() {
return Objects.hash(id, author, main, version, dependencies);
return Objects.hash(id, authors, main, version, dependencies);
}
@Override
public String toString() {
return "SerializedPluginDescription{" +
"id='" + id + '\'' +
", author='" + author + '\'' +
", authors='" + authors + '\'' +
", main='" + main + '\'' +
", version='" + version + '\'' +
", dependencies=" + dependencies +

Datei anzeigen

@ -33,7 +33,7 @@ public @interface Plugin {
*
* @return the plugin's author, or empty if unknown
*/
String author() default "";
String[] authors() default "";
/**
* The dependencies required to load before this plugin.

Datei anzeigen

@ -5,6 +5,7 @@ import com.velocitypowered.api.plugin.meta.PluginDependency;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Pattern;
@ -37,12 +38,12 @@ public interface PluginDescription {
String getVersion();
/**
* Gets the author of the {@link Plugin} within this container.
* Gets the authors of the {@link Plugin} within this container.
*
* @return the plugin author
* @see Plugin#author()
* @return the plugin authors
* @see Plugin#authors()
*/
String getAuthor();
List<String> getAuthors();
/**
* Gets a {@link Collection} of all dependencies of the {@link Plugin} within

Datei anzeigen

@ -80,7 +80,7 @@ public class JavaPluginLoader implements PluginLoader {
return new VelocityPluginContainer(
description.getId(),
description.getVersion(),
description.getAuthor(),
description.getAuthors(),
description.getDependencies(),
source.get(),
instance
@ -112,7 +112,7 @@ public class JavaPluginLoader implements PluginLoader {
return new JavaVelocityPluginDescription(
description.getId(),
description.getVersion(),
description.getAuthor(),
description.getAuthors(),
dependencies,
source,
mainClass

Datei anzeigen

@ -6,13 +6,14 @@ import com.velocitypowered.api.plugin.meta.PluginDependency;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
public class VelocityPluginContainer extends VelocityPluginDescription implements PluginContainer {
private final Object instance;
public VelocityPluginContainer(String id, String version, String author, Collection<PluginDependency> dependencies, Path source, Object instance) {
super(id, version, author, dependencies, source);
public VelocityPluginContainer(String id, String version, List<String> authors, Collection<PluginDependency> dependencies, Path source, Object instance) {
super(id, version, authors, dependencies, source);
this.instance = instance;
}

Datei anzeigen

@ -6,6 +6,7 @@ import com.velocitypowered.api.plugin.meta.PluginDependency;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@ -14,14 +15,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
public class VelocityPluginDescription implements PluginDescription {
private final String id;
private final String version;
private final String author;
private final List<String> authors;
private final Map<String, PluginDependency> dependencies;
private final Path source;
public VelocityPluginDescription(String id, String version, String author, Collection<PluginDependency> dependencies, Path source) {
public VelocityPluginDescription(String id, String version, List<String> authors, Collection<PluginDependency> dependencies, Path source) {
this.id = checkNotNull(id, "id");
this.version = checkNotNull(version, "version");
this.author = checkNotNull(author, "author");
this.authors = checkNotNull(authors, "authors");
this.dependencies = Maps.uniqueIndex(dependencies, PluginDependency::getId);
this.source = source;
}
@ -37,8 +38,8 @@ public class VelocityPluginDescription implements PluginDescription {
}
@Override
public String getAuthor() {
return author;
public List<String> getAuthors() {
return authors;
}
@Override
@ -61,7 +62,7 @@ public class VelocityPluginDescription implements PluginDescription {
return "VelocityPluginDescription{" +
"id='" + id + '\'' +
", version='" + version + '\'' +
", author='" + author + '\'' +
", authors='" + authors + '\'' +
", dependencies=" + dependencies +
", source=" + source +
'}';

Datei anzeigen

@ -5,14 +5,15 @@ import com.velocitypowered.proxy.plugin.loader.VelocityPluginDescription;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
public class JavaVelocityPluginDescription extends VelocityPluginDescription {
private final Class mainClass;
public JavaVelocityPluginDescription(String id, String version, String author, Collection<PluginDependency> dependencies, Path source, Class mainClass) {
super(id, version, author, dependencies, source);
public JavaVelocityPluginDescription(String id, String version, List<String> authors, Collection<PluginDependency> dependencies, Path source, Class mainClass) {
super(id, version, authors, dependencies, source);
this.mainClass = checkNotNull(mainClass);
}

Datei anzeigen

@ -5,23 +5,25 @@ import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.plugin.Plugin;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
public class SerializedPluginDescription {
private final String id;
private final String author;
private final List<String> authors;
private final String main;
private final String version;
private final List<Dependency> dependencies;
public SerializedPluginDescription(String id, String author, String main, String version) {
this(id, author, main, version, ImmutableList.of());
public SerializedPluginDescription(String id, List<String> authors, String main, String version) {
this(id, authors, main, version, ImmutableList.of());
}
public SerializedPluginDescription(String id, String author, String main, String version, List<Dependency> dependencies) {
public SerializedPluginDescription(String id, List<String> authors, String main, String version, List<Dependency> dependencies) {
this.id = Preconditions.checkNotNull(id, "id");
this.author = Preconditions.checkNotNull(author, "author");
this.authors = Preconditions.checkNotNull(authors, "author");
this.main = Preconditions.checkNotNull(main, "main");
this.version = Preconditions.checkNotNull(version, "version");
this.dependencies = ImmutableList.copyOf(dependencies);
@ -32,15 +34,15 @@ 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.author(), qualifiedName, plugin.version(), dependencies);
return new SerializedPluginDescription(plugin.id(), Arrays.stream(plugin.authors()).filter(author -> !author.isEmpty()).collect(Collectors.toList()), qualifiedName, plugin.version(), dependencies);
}
public String getId() {
return id;
}
public String getAuthor() {
return author;
public List<String> getAuthors() {
return authors;
}
public String getMain() {
@ -61,7 +63,7 @@ public class SerializedPluginDescription {
if (o == null || getClass() != o.getClass()) return false;
SerializedPluginDescription that = (SerializedPluginDescription) o;
return Objects.equals(id, that.id) &&
Objects.equals(author, that.author) &&
Objects.equals(authors, that.authors) &&
Objects.equals(main, that.main) &&
Objects.equals(version, that.version) &&
Objects.equals(dependencies, that.dependencies);
@ -69,14 +71,14 @@ public class SerializedPluginDescription {
@Override
public int hashCode() {
return Objects.hash(id, author, main, version, dependencies);
return Objects.hash(id, authors, main, version, dependencies);
}
@Override
public String toString() {
return "SerializedPluginDescription{" +
"id='" + id + '\'' +
", author='" + author + '\'' +
", authors='" + authors + '\'' +
", main='" + main + '\'' +
", version='" + version + '\'' +
", dependencies=" + dependencies +

Datei anzeigen

@ -8,6 +8,8 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
public class FakePluginManager implements PluginManager {
@ -78,8 +80,8 @@ public class FakePluginManager implements PluginManager {
}
@Override
public String getAuthor() {
return "";
public List<String> getAuthors() {
return Collections.emptyList();
}
};
}