Added plugin-version and plugin to extension.yml

This commit is contained in:
Auxilor
2023-05-02 14:26:53 +01:00
parent cc6dc1e67c
commit 60a1f2429c
5 changed files with 40 additions and 13 deletions

View File

@@ -152,11 +152,7 @@ public abstract class Extension implements PluginLike {
@Override
public @NotNull File getFile() {
Validate.notNull(metadata, "Metadata cannot be null!");
if (this.metadata.file() != null) {
return this.metadata.file();
} else {
throw new MalformedExtensionException("Metadata does not have file!");
}
return this.metadata.file();
}
/**

View File

@@ -0,0 +1,17 @@
package com.willfp.eco.core.extensions;
import org.jetbrains.annotations.NotNull;
/**
* Generic exception in extension loading.
*/
public class ExtensionLoadException extends RuntimeException {
/**
* Create a new ExtensionLoadException.
*
* @param errorMessage The error message to show.
*/
public ExtensionLoadException(@NotNull final String errorMessage) {
super(errorMessage);
}
}

View File

@@ -1,7 +1,7 @@
package com.willfp.eco.core.extensions;
import com.willfp.eco.core.version.Version;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
@@ -17,19 +17,22 @@ import java.io.File;
public record ExtensionMetadata(@NotNull String version,
@NotNull String name,
@NotNull String author,
@Nullable File file) {
@NotNull File file,
@NotNull Version minimumPluginVersion) {
/**
* Legacy constructor.
*
* @param version The extension version.
* @param name The extension name.
* @param author The extension's author.
* @deprecated Use {@link ExtensionMetadata#ExtensionMetadata(String, String, String, File)} instead.
* @deprecated Use {@link ExtensionMetadata#ExtensionMetadata(String, String, String, File, Version)} instead.
*/
@SuppressWarnings("ConstantConditions")
@Deprecated(since = "6.57.0", forRemoval = true)
public ExtensionMetadata(@NotNull String version,
@NotNull String name,
@NotNull String author) {
this(version, name, author, null);
this(version, name, author, null, null);
throw new UnsupportedOperationException("Legacy constructor is not supported.");
}
}

View File

@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
* Missing or invalid extension.yml.
* Invalid filetype.
*/
public class MalformedExtensionException extends RuntimeException {
public class MalformedExtensionException extends ExtensionLoadException {
/**
* Create a new MalformedExtensionException.
*