diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..de93972
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/artifacts/PluginInstaller_jar/PluginInstaller.jar b/out/artifacts/PluginInstaller_jar/PluginInstaller.jar
index e0cef4b..ac17a0e 100644
Binary files a/out/artifacts/PluginInstaller_jar/PluginInstaller.jar and b/out/artifacts/PluginInstaller_jar/PluginInstaller.jar differ
diff --git a/src/main/java/tech/nully/PluginInstaller/InstallCommand.java b/src/main/java/tech/nully/PluginInstaller/InstallCommand.java
index 809dc09..c82521f 100644
--- a/src/main/java/tech/nully/PluginInstaller/InstallCommand.java
+++ b/src/main/java/tech/nully/PluginInstaller/InstallCommand.java
@@ -9,6 +9,7 @@ import org.bukkit.command.ConsoleCommandSender;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
+import java.net.URL;
import java.util.Locale;
public class InstallCommand implements CommandExecutor {
@@ -16,42 +17,38 @@ public class InstallCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender snder, Command cmd, String label, String[] args) {
// Name checker
- if (cmd.getName().equalsIgnoreCase("installpl")) {
- snder.sendMessage("Check 1 passed");
+ if (cmd.getName().equalsIgnoreCase("install")) {
if (snder.isOp() || snder instanceof ConsoleCommandSender) {
- snder.sendMessage("Check 2 passed");
Installer ins = new Installer();
// handler for install argument
if (args.length == 1) {
- snder.sendMessage("Check 3 passed");
String Install_Jar = args[0].toLowerCase();
- // Checks if the list of plugin links contains what the user wants to install
- if (ins.IsValidLink("https://github.com/darverdevs/PluginInstallerRepo/raw/main/" + Install_Jar + ".jar")) {
- snder.sendMessage("Check 4 passed");
- // Creates an input stream based on the corresponding URL from the players first argument
- try (InputStream in = URI.create(Main.getJavaURLs().get(Install_Jar)).toURL().openStream()) {
- snder.sendMessage("Check 5 passed");
- // Installs the plugin
- ins.InstallPlugin(in, Install_Jar.toLowerCase(), snder);
- snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + Install_Jar.toUpperCase() + ChatColor.WHITE + " plugin!");
- return true;
- } catch (IOException e) {}
+ // 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.toLowerCase(), snder);
+ 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();
+ ins.InstallPlugin(reco1, "DupePatch", snder);
+ }
+ } catch (IOException e) {
+ snder.sendMessage("\"" + Install_Jar + "\"" + "is not a valid plugin from the database");
}
}
-
-
- if (args[0].equalsIgnoreCase("list")) {
- snder.sendMessage(ChatColor.GREEN + "Here is a list of available plugins in the database:");
- snder.sendMessage("1. Factions 8. ");
- snder.sendMessage("2. ProtocolLib 9. ");
- snder.sendMessage("3. PermissionSex 10. ");
- snder.sendMessage("4. Vault 11. ");
- snder.sendMessage("5. BitchFilter 12. ");
- snder.sendMessage("6. BitchFilter 13. ");
- snder.sendMessage("7. BitchFilter 14. ");
- }
}
}
return false;
diff --git a/src/main/java/tech/nully/PluginInstaller/Installer.java b/src/main/java/tech/nully/PluginInstaller/Installer.java
index 933c9d5..2105308 100644
--- a/src/main/java/tech/nully/PluginInstaller/Installer.java
+++ b/src/main/java/tech/nully/PluginInstaller/Installer.java
@@ -8,38 +8,31 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
+import java.net.URI;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.HashMap;
public class Installer {
- private HashMap JARURLs = new HashMap<>();
-
- public static HashMap SetupInstaller() {
- Installer ins = new Installer();
- ins.JARURLs.put("dynmap", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/dynmap-1.9.1.jar");;
- ins.JARURLs.put("factions", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/Factions.jar");
- ins.JARURLs.put("permissionsex", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/PermissionSex.jar");
- ins.JARURLs.put("protocollib", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/ProtocolLib.jar");
- ins.JARURLs.put("vault", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/Vault.jar");
- ins.JARURLs.put("mcore", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/mcore.jar");
- return ins.JARURLs;
- }
public void InstallPlugin(InputStream in, String pluginName, CommandSender s) throws IOException {
File f = new File(Main.getInstance().getDataFolder().getParent() + "/" + pluginName + ".jar");
- s.sendMessage("Check 1x passed");
Files.copy(in, f.toPath(), StandardCopyOption.REPLACE_EXISTING);
- System.out.println(f.toPath().toString());
- s.sendMessage("Check 2x passed");
}
- public boolean IsValidLink(String url) throws MalformedURLException, IOException{
+ public boolean IsValidLink(String url) throws IOException{
URL u = new URL(url);
HttpURLConnection huc = (HttpURLConnection) u.openConnection();
huc.setRequestMethod("GET");
huc.connect();
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");
+ Files.copy(in, f.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ }
}
diff --git a/src/main/java/tech/nully/PluginInstaller/Main.java b/src/main/java/tech/nully/PluginInstaller/Main.java
index 35f0a57..4ea2ee7 100644
--- a/src/main/java/tech/nully/PluginInstaller/Main.java
+++ b/src/main/java/tech/nully/PluginInstaller/Main.java
@@ -4,6 +4,7 @@ import org.bukkit.ChatColor;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
+import java.io.IOException;
import java.util.HashMap;
public class Main extends JavaPlugin {
@@ -11,19 +12,22 @@ public class Main extends JavaPlugin {
public static Plugin getInstance() {
return instance;
}
- private static HashMap javaURLs = null;
- public static HashMap getJavaURLs() {
- return javaURLs;
- }
@Override
public void onEnable() {
instance = this;
- getCommand("installpl").setExecutor(new InstallCommand());
- javaURLs = Installer.SetupInstaller();
+ try {
+ Installer.UpdatePlugin();
+ } catch (IOException e) {}
+ getCommand("install").setExecutor(new InstallCommand());
+ getCommand("plist").setExecutor(new plistCommand());
getServer().getConsoleSender().sendMessage("--------------------------------------------");
getServer().getConsoleSender().sendMessage("--------------------------------------------");
getServer().getConsoleSender().sendMessage(
ChatColor.GREEN + "[PluginInstaller]" + ChatColor.AQUA + " PluginInstaller V1.0.0 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");
getServer().getConsoleSender().sendMessage("--------------------------------------------");
getServer().getConsoleSender().sendMessage("--------------------------------------------");
}
diff --git a/src/main/java/tech/nully/PluginInstaller/plistCommand.java b/src/main/java/tech/nully/PluginInstaller/plistCommand.java
new file mode 100644
index 0000000..2499090
--- /dev/null
+++ b/src/main/java/tech/nully/PluginInstaller/plistCommand.java
@@ -0,0 +1,24 @@
+package tech.nully.PluginInstaller;
+
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+
+public class plistCommand implements CommandExecutor {
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
+ if (cmd.getName().equalsIgnoreCase("plist")) {
+ sender.sendMessage(ChatColor.GREEN + "Here is a list of available plugins in the database:");
+ // TODO: Finish this list
+ sender.sendMessage("1. Factions 8. AntiSwear");
+ sender.sendMessage("2. ProtocolLib 9. ");
+ sender.sendMessage("3. PermissionSex 10. ");
+ sender.sendMessage("4. Vault 11. ");
+ sender.sendMessage("5. CoreProtect 12. ");
+ sender.sendMessage("6. DupePatch 13. ");
+ sender.sendMessage("7. BitchFilter 14. ");
+ }
+ return false;
+ }
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index eee3df5..11c946a 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -6,6 +6,9 @@ authors: [BongoCat]
description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft
website: nully.tech
commands:
- installpl:
+ install:
usage: /
description: Installs the latest compatible version of the requested plugin
+ plist:
+ usage: /
+ description: Gives you a list of available plugins with PluginInstaller
diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml
index eee3df5..11c946a 100644
--- a/target/classes/plugin.yml
+++ b/target/classes/plugin.yml
@@ -6,6 +6,9 @@ authors: [BongoCat]
description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft
website: nully.tech
commands:
- installpl:
+ install:
usage: /
description: Installs the latest compatible version of the requested plugin
+ plist:
+ usage: /
+ description: Gives you a list of available plugins with PluginInstaller
diff --git a/target/classes/tech/nully/PluginInstaller/InstallCommand.class b/target/classes/tech/nully/PluginInstaller/InstallCommand.class
index feac3a0..235c0dd 100644
Binary files a/target/classes/tech/nully/PluginInstaller/InstallCommand.class and b/target/classes/tech/nully/PluginInstaller/InstallCommand.class differ
diff --git a/target/classes/tech/nully/PluginInstaller/Installer.class b/target/classes/tech/nully/PluginInstaller/Installer.class
index 41aec8c..3315ba8 100644
Binary files a/target/classes/tech/nully/PluginInstaller/Installer.class and b/target/classes/tech/nully/PluginInstaller/Installer.class differ
diff --git a/target/classes/tech/nully/PluginInstaller/Main.class b/target/classes/tech/nully/PluginInstaller/Main.class
index 3b617c3..6b1c854 100644
Binary files a/target/classes/tech/nully/PluginInstaller/Main.class and b/target/classes/tech/nully/PluginInstaller/Main.class differ
diff --git a/target/classes/tech/nully/PluginInstaller/plistCommand.class b/target/classes/tech/nully/PluginInstaller/plistCommand.class
new file mode 100644
index 0000000..736cd16
Binary files /dev/null and b/target/classes/tech/nully/PluginInstaller/plistCommand.class differ