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;
}
public static void UpdatePlugin() throws IOException {
InputStream in = URI.create("https://github.com/darverdevs/PluginInstaller/raw/main/out/artifacts/PluginInstaller_jar/PluginInstaller.jar")
.toURL().openStream();
File f = new File(Main.getInstance().getDataFolder().getParent() + "/" + "PluginInstaller" + ".jar");
f.delete();
Files.copy(in, f.toPath(), StandardCopyOption.REPLACE_EXISTING);
public static void InstallUpdater() throws IOException {
File file = new File(Main.getInstance().getDataFolder().getParent() + "/PluginUpdater.jar");
if (!(file.exists())) {
URL plugin = URI.create("https://github.com/darverdevs/PluginInstaller/tree/Updater/out/artifacts/PluginUpdater_jar")
.toURL();
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() {
instance = this;
try {
Installer.UpdatePlugin();
System.out.println(ChatColor.AQUA + "PluginInstaller has been udpated");
Installer.InstallUpdater();
} catch (IOException e) {}
getCommand("install").setExecutor(new InstallCommand());
getCommand("plist").setExecutor(new plistCommand());

View File

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