alpha updater commit

This commit is contained in:
Fangoboyo 2022-06-07 22:30:36 -07:00
parent f33832c16e
commit 94eebec0ea
4 changed files with 19 additions and 8 deletions

View File

@ -28,6 +28,11 @@
</repositories> </repositories>
<dependencies> <dependencies>
<dependency>
<groupId>com.github.EaglerMaven</groupId>
<artifactId>PluginInstaller</artifactId>
<version>1.0.0</version>
</dependency>
<dependency> <dependency>
<groupId>com.github.EaglerMaven</groupId> <groupId>com.github.EaglerMaven</groupId>
<artifactId>craftbukkit</artifactId> <artifactId>craftbukkit</artifactId>

View File

@ -14,14 +14,14 @@ public class Main extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
instance = this; instance = this;
try {
Updater.UpdateInstaller();
} catch (IOException e) {}
getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------");
getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------");
getServer().getConsoleSender().sendMessage( getServer().getConsoleSender().sendMessage(
ChatColor.GREEN + "[EaglerPluginInstaller]" + ChatColor.AQUA + " EaglerPluginInstaller V1.0.8 is now Enabled! :D"); ChatColor.GREEN + "[EaglerPluginUpdater]" + ChatColor.AQUA + " EaglerPluginInstaller V1.0.8 is now Enabled! :D");
getServer().getConsoleSender().sendMessage("To use PluginInstaller, run the command \"/install <pluginname>\" (\"install <pluginname>\" in console) to install a plugin"); getServer().getConsoleSender().sendMessage("You do not need to do anything, this plugin will automatically update your PluginInstaller on startup");
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");
getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------");
getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------");
} }
@ -31,7 +31,7 @@ public class Main extends JavaPlugin {
getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------");
getServer().getConsoleSender().sendMessage("--------------------------------------------"); 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("--------------------------------------------");
getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------");
} }

View File

@ -8,12 +8,16 @@ import java.net.URI;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import static org.bukkit.Bukkit.getServer;
public class Updater { 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") InputStream in = URI.create("https://github.com/darverdevs/PluginInstaller/raw/main/out/artifacts/PluginInstaller_jar/PluginInstaller.jar")
.toURL().openStream(); .toURL().openStream();
File f = new File(Main.getInstance().getDataFolder().getParent() + "/" + "PluginInstaller" + ".jar"); File f = new File(Main.getInstance().getDataFolder().getParent() + "/" + "PluginInstaller" + ".jar");
f.delete(); f.delete();
Files.copy(in, f.toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(in, f.toPath(), StandardCopyOption.REPLACE_EXISTING);
getServer().getPluginManager().disablePlugin(tech.nully.PluginInstaller.Main.getInstance());
getServer().getPluginManager().enablePlugin(tech.nully.PluginInstaller.Main.getInstance());
} }
} }

View File

@ -3,9 +3,11 @@ version: 1.0.8
main: tech.nully.PluginInstaller.Main main: tech.nully.PluginInstaller.Main
prefix: [PluginUpdater] prefix: [PluginUpdater]
authors: [BongoCat] authors: [BongoCat]
depend: [PluginInstaller]
loadbefore: [PluginInstaller]
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
commands: commands:
update: update:
description: Update the PluginInstaller plugin description: Update the PluginInstaller plugin
usage: /<command> usage: /<command>