Updated Plugin-API version as it has recived updates since 0.1.0, but yet dine to be in 1.0 release
build / build (push) Has been cancelled
build / build (push) Has been cancelled
Updeaded the RPCP loader to use JarFile instead of a virtual FS Signed-off-by: zacharias <alienfromdia@proton.me>
This commit is contained in:
@@ -849,7 +849,7 @@ public class Core {
|
||||
pluginJsonData.append(tmp);
|
||||
}
|
||||
JSONObject pluginJson = new JSONObject(pluginJsonData.toString());
|
||||
LoadedPlugin plugin = loader.loadPlugin(pluginJson, file.toPath(), data);
|
||||
LoadedPlugin plugin = loader.loadPlugin(pluginJson, jar, file.toPath(), data);
|
||||
|
||||
data.addPlugin(plugin);
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import static me.neurodock.plugin.Plugin.UNKNOWN_PLUGIN;
|
||||
|
||||
@@ -79,7 +81,9 @@ public class Loader {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// Replaces the toString which is used thru out the Core and OllamaObject to get the JSON representation of a Function Tool
|
||||
// Replaces the toString which is used throughout the Core and OllamaObject to get the JSON representation of a Function Tool
|
||||
// Ideally the toString method SHULD NOT be used like this, while yes a JSON representation is better than a Java Hash representation
|
||||
// the toString should not be utilized or overwritten in this manner
|
||||
return tool.getToolJSON();
|
||||
}
|
||||
});
|
||||
@@ -89,13 +93,13 @@ public class Loader {
|
||||
|
||||
}
|
||||
|
||||
public LoadedPlugin loadPlugin(JSONObject pluginJson, Path pluginJar, Data data) {
|
||||
public LoadedPlugin loadPlugin(JSONObject pluginJson, JarFile jar, Path pluginJar, Data data) {
|
||||
if(!pluginJson.has("name") || !(pluginJson.get("name") instanceof String pluginName))
|
||||
throw new PluginLoadingException("Malformed plugin json", UNKNOWN_PLUGIN);
|
||||
if(!pluginJson.has("entryPoint") || !(pluginJson.get("entryPoint") instanceof String pluginEntryPoint))
|
||||
throw new PluginLoadingException("Malformed plugin json", pluginName);
|
||||
Path pluginEntryPointFile = fs.getPath("/"+pluginEntryPoint.replaceAll("\\.", "/")+".class");
|
||||
if(!Files.exists(pluginEntryPointFile)) throw new PluginLoadingException("Missing plugin entrypoint", pluginName);
|
||||
JarEntry entry = jar.getJarEntry(pluginEntryPoint.replaceAll("\\.", "/"));
|
||||
if(entry == null) throw new PluginLoadingException("Missing plugin entrypoint", pluginName);
|
||||
|
||||
Plugin plugin = null;
|
||||
URLClassLoader classLoader;
|
||||
|
||||
Reference in New Issue
Block a user