3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-09-29 06:30:16 +02:00

allow more than one author

Dieser Commit ist enthalten in:
kashike 2018-08-21 09:09:48 -07:00
Ursprung a028467e66
Commit c4fdac9591
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 com.velocitypowered.api.plugin.Plugin;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
public class SerializedPluginDescription { public class SerializedPluginDescription {
private final String id; private final String id;
private final String author; private final List<String> authors;
private final String main; private final String main;
private final String version; private final String version;
private final List<Dependency> dependencies; 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()); 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.id = Preconditions.checkNotNull(id, "id");
this.author = Preconditions.checkNotNull(author, "author"); this.authors = Preconditions.checkNotNull(authors, "authors");
this.main = Preconditions.checkNotNull(main, "main"); this.main = Preconditions.checkNotNull(main, "main");
this.version = Preconditions.checkNotNull(version, "version"); this.version = Preconditions.checkNotNull(version, "version");
this.dependencies = ImmutableList.copyOf(dependencies); this.dependencies = ImmutableList.copyOf(dependencies);
@ -32,15 +34,15 @@ 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.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() { public String getId() {
return id; return id;
} }
public String getAuthor() { public List<String> getAuthors() {
return author; return authors;
} }
public String getMain() { public String getMain() {
@ -61,7 +63,7 @@ public class SerializedPluginDescription {
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
SerializedPluginDescription that = (SerializedPluginDescription) o; SerializedPluginDescription that = (SerializedPluginDescription) o;
return Objects.equals(id, that.id) && return Objects.equals(id, that.id) &&
Objects.equals(author, that.author) && Objects.equals(authors, that.authors) &&
Objects.equals(main, that.main) && Objects.equals(main, that.main) &&
Objects.equals(version, that.version) && Objects.equals(version, that.version) &&
Objects.equals(dependencies, that.dependencies); Objects.equals(dependencies, that.dependencies);
@ -69,14 +71,14 @@ public class SerializedPluginDescription {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, author, main, version, dependencies); return Objects.hash(id, authors, main, version, dependencies);
} }
@Override @Override
public String toString() { public String toString() {
return "SerializedPluginDescription{" + return "SerializedPluginDescription{" +
"id='" + id + '\'' + "id='" + id + '\'' +
", author='" + author + '\'' + ", authors='" + authors + '\'' +
", main='" + main + '\'' + ", main='" + main + '\'' +
", version='" + version + '\'' + ", version='" + version + '\'' +
", dependencies=" + dependencies + ", dependencies=" + dependencies +

Datei anzeigen

@ -33,7 +33,7 @@ public @interface Plugin {
* *
* @return the plugin's author, or empty if unknown * @return the plugin's author, or empty if unknown
*/ */
String author() default ""; String[] authors() default "";
/** /**
* The dependencies required to load before this plugin. * 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.nio.file.Path;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -37,12 +38,12 @@ public interface PluginDescription {
String getVersion(); 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 * @return the plugin authors
* @see Plugin#author() * @see Plugin#authors()
*/ */
String getAuthor(); List<String> getAuthors();
/** /**
* Gets a {@link Collection} of all dependencies of the {@link Plugin} within * 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( return new VelocityPluginContainer(
description.getId(), description.getId(),
description.getVersion(), description.getVersion(),
description.getAuthor(), description.getAuthors(),
description.getDependencies(), description.getDependencies(),
source.get(), source.get(),
instance instance
@ -112,7 +112,7 @@ public class JavaPluginLoader implements PluginLoader {
return new JavaVelocityPluginDescription( return new JavaVelocityPluginDescription(
description.getId(), description.getId(),
description.getVersion(), description.getVersion(),
description.getAuthor(), description.getAuthors(),
dependencies, dependencies,
source, source,
mainClass mainClass

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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