From 94eebec0ea33c42d4f24f85125343b32f7e0b8e7 Mon Sep 17 00:00:00 2001 From: Fangoboyo <77935781+Fangoboyo@users.noreply.github.com> Date: Tue, 7 Jun 2022 22:30:36 -0700 Subject: [PATCH] alpha updater commit --- pom.xml | 5 +++++ src/main/java/tech/nully/PluginUpdater/Main.java | 12 ++++++------ src/main/java/tech/nully/PluginUpdater/Updater.java | 6 +++++- src/main/resources/plugin.yml | 4 +++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index fab92a8..93ca0c9 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,11 @@ + + com.github.EaglerMaven + PluginInstaller + 1.0.0 + com.github.EaglerMaven craftbukkit diff --git a/src/main/java/tech/nully/PluginUpdater/Main.java b/src/main/java/tech/nully/PluginUpdater/Main.java index e355008..57d4745 100644 --- a/src/main/java/tech/nully/PluginUpdater/Main.java +++ b/src/main/java/tech/nully/PluginUpdater/Main.java @@ -14,14 +14,14 @@ public class Main extends JavaPlugin { @Override public void onEnable() { instance = this; + try { + Updater.UpdateInstaller(); + } catch (IOException e) {} getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage( - ChatColor.GREEN + "[EaglerPluginInstaller]" + ChatColor.AQUA + " EaglerPluginInstaller V1.0.8 is now Enabled! :D"); - getServer().getConsoleSender().sendMessage("To use PluginInstaller, run the command \"/install \" (\"install \" in console) to install a plugin"); - getServer().getConsoleSender().sendMessage("To get a list of installable plugins, use the command \"/plist\" or \"plist\" in console"); - getServer().getConsoleSender().sendMessage("You can request to add a new plugin to the database by going to https://github.com/darverdevs/PluginInstallerRepo/tree/main"); - getServer().getConsoleSender().sendMessage("and creating an issue or pull request of the plugin you want to add"); + ChatColor.GREEN + "[EaglerPluginUpdater]" + ChatColor.AQUA + " EaglerPluginInstaller V1.0.8 is now Enabled! :D"); + getServer().getConsoleSender().sendMessage("You do not need to do anything, this plugin will automatically update your PluginInstaller on startup"); getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------"); } @@ -31,7 +31,7 @@ public class Main extends JavaPlugin { getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage( - ChatColor.GREEN + "[EaglerPluginInstaller]" + ChatColor.AQUA + " PluginInstaller V1.0.8 is now Disabled! D:"); + ChatColor.GREEN + "[EaglerPluginUpdater]" + ChatColor.AQUA + " EaglerPluginUpdater V1.0.8 is now Disabled! D:"); getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------"); } diff --git a/src/main/java/tech/nully/PluginUpdater/Updater.java b/src/main/java/tech/nully/PluginUpdater/Updater.java index 0174bee..91ec4ba 100644 --- a/src/main/java/tech/nully/PluginUpdater/Updater.java +++ b/src/main/java/tech/nully/PluginUpdater/Updater.java @@ -8,12 +8,16 @@ import java.net.URI; import java.nio.file.Files; import java.nio.file.StandardCopyOption; +import static org.bukkit.Bukkit.getServer; + public class Updater { - public void UpdateInstaller() throws IOException { + public static void UpdateInstaller() 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); + getServer().getPluginManager().disablePlugin(tech.nully.PluginInstaller.Main.getInstance()); + getServer().getPluginManager().enablePlugin(tech.nully.PluginInstaller.Main.getInstance()); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 90bcc7d..158b2a9 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,9 +3,11 @@ version: 1.0.8 main: tech.nully.PluginInstaller.Main prefix: [PluginUpdater] authors: [BongoCat] +depend: [PluginInstaller] +loadbefore: [PluginInstaller] description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft website: nully.tech commands: update: description: Update the PluginInstaller plugin - usage: / + usage: / \ No newline at end of file