diff --git a/.idea/compiler.xml b/.idea/compiler.xml index efeb2a2..a3ba1dc 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -8,12 +8,12 @@ + - diff --git a/out/artifacts/EaglerPluginInstaller_jar/EaglerPluginInstaller.jar b/out/artifacts/EaglerPluginInstaller_jar/EaglerPluginInstaller.jar index 1bb3447..f6e4db9 100644 Binary files a/out/artifacts/EaglerPluginInstaller_jar/EaglerPluginInstaller.jar and b/out/artifacts/EaglerPluginInstaller_jar/EaglerPluginInstaller.jar differ diff --git a/src/main/java/tech/nully/PluginInstaller/Commands/InstallCommand.java b/src/main/java/tech/nully/PluginInstaller/Commands/InstallCommand.java index c85395b..d04b83d 100644 --- a/src/main/java/tech/nully/PluginInstaller/Commands/InstallCommand.java +++ b/src/main/java/tech/nully/PluginInstaller/Commands/InstallCommand.java @@ -18,60 +18,61 @@ public class InstallCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender snder, Command cmd, String label, String[] args) { // Name checker - if (cmd.getName().equalsIgnoreCase("install")) { - if (snder.isOp() || snder instanceof ConsoleCommandSender) { - Installer ins = new Installer(); - // handler for install argument - if (args.length == 1) { - String Install_Jar = args[0].toLowerCase(); - - // Checks if the created URL is a valid one - try { - if (ins.IsValidLink("https://github.com/darverdevs/PluginInstallerRepo/raw/main/" + Install_Jar + ".jar")) { - //plugin URL - URL plugin = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/" + Install_Jar + ".jar") - .toURL(); - - // Creates the InputStream - try (InputStream in = plugin.openStream()) { - - // Installs the plugin - ins.InstallPlugin(in, Install_Jar.substring(0, 1).toUpperCase() + Install_Jar.substring(1)); - snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + Install_Jar.toUpperCase() + ChatColor.WHITE + " plugin!"); - return true; - } catch (IOException e) {} - } else if (Install_Jar.equalsIgnoreCase("recommended")) { - InputStream reco1 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/dupepatch.jar") - .toURL().openStream(); - InputStream reco2 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/essentials.jar") - .toURL().openStream(); - InputStream reco3 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/essentialsspawn.jar") - .toURL().openStream(); - InputStream reco4 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/authme.jar") - .toURL().openStream(); - InputStream reco5 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/worldedit.jar") - .toURL().openStream(); - InputStream reco6 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/bitchfilter.jar") - .toURL().openStream(); - ins.InstallPlugin(reco1, "DupePatch"); - snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "DupePatch" + ChatColor.WHITE + " plugin!"); - ins.InstallPlugin(reco2, "Essentials"); - snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "Essentials" + ChatColor.WHITE + " plugin!"); - ins.InstallPlugin(reco3, "EssentialsSpawn"); - snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "EssentialsSpawn" + ChatColor.WHITE + " plugin!"); - ins.InstallPlugin(reco4, "AuthMe"); - snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "AuthMe" + ChatColor.WHITE + " plugin!"); - ins.InstallPlugin(reco5, "Worldedit"); - snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "Worldedit" + ChatColor.WHITE + " plugin!"); - ins.InstallPlugin(reco6, "BitchFilter"); - snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "BitchFilter" + ChatColor.WHITE + " plugin!"); + if (snder.isOp() || snder instanceof ConsoleCommandSender) { + Installer ins = new Installer(); + // handler for install argument + if (args.length == 1) { + String Install_Jar = args[0].toLowerCase(); + // Checks if the created URL is a valid one + try { + if (ins.IsValidLink("https://github.com/darverdevs/PluginInstallerRepo/raw/main/" + Install_Jar + ".jar")) { + //plugin URL + URL plugin = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/" + Install_Jar + ".jar") + .toURL(); + // Creates the InputStream + try (InputStream in = plugin.openStream()) { + // Installs the plugin + ins.InstallPlugin(in, Install_Jar.substring(0, 1).toUpperCase() + Install_Jar.substring(1)); + snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + Install_Jar.toUpperCase() + ChatColor.WHITE + " plugin!"); + return true; + } catch (IOException e) { + snder.sendMessage("\"" + Install_Jar + "\"" + "is not a valid plugin from the database"); return true; } - } catch (IOException e) { - snder.sendMessage("\"" + Install_Jar + "\"" + "is not a valid plugin from the database"); + } else if (Install_Jar.equalsIgnoreCase("recommended")) { + InputStream reco1 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/dupepatch.jar") + .toURL().openStream(); + InputStream reco2 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/essentials.jar") + .toURL().openStream(); + InputStream reco3 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/essentialsspawn.jar") + .toURL().openStream(); + InputStream reco4 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/authme.jar") + .toURL().openStream(); + InputStream reco5 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/worldedit.jar") + .toURL().openStream(); + InputStream reco6 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/bitchfilter.jar") + .toURL().openStream(); + ins.InstallPlugin(reco1, "DupePatch"); + snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "DupePatch" + ChatColor.WHITE + " plugin!"); + ins.InstallPlugin(reco2, "Essentials"); + snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "Essentials" + ChatColor.WHITE + " plugin!"); + ins.InstallPlugin(reco3, "EssentialsSpawn"); + snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "EssentialsSpawn" + ChatColor.WHITE + " plugin!"); + ins.InstallPlugin(reco4, "AuthMe"); + snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "AuthMe" + ChatColor.WHITE + " plugin!"); + ins.InstallPlugin(reco5, "Worldedit"); + snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "Worldedit" + ChatColor.WHITE + " plugin!"); + ins.InstallPlugin(reco6, "BitchFilter"); + snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "BitchFilter" + ChatColor.WHITE + " plugin!"); return true; } + } catch (IOException e) { + snder.sendMessage("\"" + Install_Jar + "\"" + "is not a valid plugin from the database"); + return true; } + } else { + snder.sendMessage("You have provided too many arguments!"); + snder.sendMessage("The correct usage of this command is: /install "); } } return false; diff --git a/target/EaglerPluginInstaller-1.0.0.jar b/target/EaglerPluginInstaller-1.0.0.jar deleted file mode 100644 index ba5e3f4..0000000 Binary files a/target/EaglerPluginInstaller-1.0.0.jar and /dev/null differ