Added AddonDescription#getRepository()

This commit is contained in:
Florian CUNY 2019-02-12 16:11:11 +01:00
parent 68b7702b1c
commit 3fb60480ff
2 changed files with 32 additions and 1 deletions

View File

@ -87,7 +87,8 @@ public class AddonClassLoader extends URLClassLoader {
private AddonDescription asDescription(YamlConfiguration data) {
AddonDescription.Builder builder = new AddonDescription.Builder(data.getString("main"), data.getString("name"), data.getString("version"))
.authors(data.getString("authors"))
.metrics(data.getBoolean("metrics", false));
.metrics(data.getBoolean("metrics", false))
.repository(data.getString("repository", ""));
if (data.getString("depend") != null) {
builder.dependencies(Arrays.asList(data.getString("depend").split("\\s*,\\s*")));

View File

@ -1,6 +1,7 @@
package world.bentobox.bentobox.api.addons;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
@ -23,6 +24,12 @@ public final class AddonDescription {
* @since 1.1
*/
private final boolean metrics;
/**
* Name of the GitHub repository of the addon or an empty String.
* It follows an {@code Owner/Name} format.
* @since 1.3.0
*/
private final @NonNull String repository;
private AddonDescription(@NonNull Builder builder) {
this.main = builder.main;
@ -33,6 +40,7 @@ public final class AddonDescription {
this.dependencies = builder.dependencies;
this.softDependencies = builder.softDependencies;
this.metrics = builder.metrics;
this.repository = builder.repository;
}
@NonNull
@ -85,6 +93,17 @@ public final class AddonDescription {
return metrics;
}
/**
* Returns the name of the GitHub repository of the addon.
* It follows a {@code Owner/Name} format.
* @return the name of the GitHub repository of the addon or an empty String.
* @since 1.3.0
*/
@NonNull
public String getRepository() {
return repository;
}
public static class Builder {
private @NonNull String main;
private @NonNull String name;
@ -94,6 +113,7 @@ public final class AddonDescription {
private @NonNull List<String> dependencies = new ArrayList<>();
private @NonNull List<String> softDependencies = new ArrayList<>();
private boolean metrics = false;
private @NonNull String repository = "";
/**
* @since 1.1
*/
@ -136,6 +156,16 @@ public final class AddonDescription {
return this;
}
/**
* Sets the name of the GitHub repository.
* Must follow the {@code Owner/Name} format.
* @since 1.3.0
*/
public Builder repository(@NonNull String repository) {
this.repository = repository;
return this;
}
@NonNull
public AddonDescription build() {
return new AddonDescription(this);