mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-18 18:05:05 +01:00
Basic plugin manager
This commit is contained in:
29
src/main/java/emu/grasscutter/plugin/PluginIdentifier.java
Normal file
29
src/main/java/emu/grasscutter/plugin/PluginIdentifier.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package emu.grasscutter.plugin;
|
||||
|
||||
// TODO: Potentially replace with Lombok?
|
||||
public final class PluginIdentifier {
|
||||
public final String name, description, version;
|
||||
public final String[] authors;
|
||||
|
||||
public PluginIdentifier(
|
||||
String name, String description, String version,
|
||||
String[] authors
|
||||
) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.version = version;
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a {@link PluginConfig} into a {@link PluginIdentifier}.
|
||||
*/
|
||||
public static PluginIdentifier fromPluginConfig(PluginConfig config) {
|
||||
if(!config.validate())
|
||||
throw new IllegalArgumentException("A valid plugin config is required to convert into a plugin identifier.");
|
||||
return new PluginIdentifier(
|
||||
config.name, config.description, config.version,
|
||||
config.authors
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user