changed to adapt to PluginUpdater

This commit is contained in:
Fangoboyo 2022-06-07 22:45:27 -07:00
parent fbc88b0737
commit 7f17ebd863
3 changed files with 10 additions and 8 deletions

View File

@ -29,11 +29,13 @@ public class Installer {
return huc.getResponseCode() == 200; return huc.getResponseCode() == 200;
} }
public static void UpdatePlugin() throws IOException { public static void InstallUpdater() throws IOException {
InputStream in = URI.create("https://github.com/darverdevs/PluginInstaller/raw/main/out/artifacts/PluginInstaller_jar/PluginInstaller.jar") File file = new File(Main.getInstance().getDataFolder().getParent() + "/PluginUpdater.jar");
.toURL().openStream(); if (!(file.exists())) {
File f = new File(Main.getInstance().getDataFolder().getParent() + "/" + "PluginInstaller" + ".jar"); URL plugin = URI.create("https://github.com/darverdevs/PluginInstaller/tree/Updater/out/artifacts/PluginUpdater_jar")
f.delete(); .toURL();
Files.copy(in, f.toPath(), StandardCopyOption.REPLACE_EXISTING); InputStream in = plugin.openStream();
Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
} }
} }

View File

@ -16,8 +16,7 @@ public class Main extends JavaPlugin {
public void onEnable() { public void onEnable() {
instance = this; instance = this;
try { try {
Installer.UpdatePlugin(); Installer.InstallUpdater();
System.out.println(ChatColor.AQUA + "PluginInstaller has been udpated");
} catch (IOException e) {} } catch (IOException e) {}
getCommand("install").setExecutor(new InstallCommand()); getCommand("install").setExecutor(new InstallCommand());
getCommand("plist").setExecutor(new plistCommand()); getCommand("plist").setExecutor(new plistCommand());

View File

@ -2,6 +2,7 @@ name: EaglerPluginInstaller
version: 1.0.8 version: 1.0.8
main: tech.nully.PluginInstaller.Main main: tech.nully.PluginInstaller.Main
prefix: [PluginInstaller] prefix: [PluginInstaller]
loadbefore: [PluginUpdater]
authors: [BongoCat] authors: [BongoCat]
description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft
website: nully.tech website: nully.tech