diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/artifacts/EaglerPluginInstaller_jar.xml b/.idea/artifacts/EaglerPluginInstaller_jar.xml new file mode 100644 index 0000000..70e0900 --- /dev/null +++ b/.idea/artifacts/EaglerPluginInstaller_jar.xml @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/out/artifacts/EaglerPluginInstaller_jar + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b91288e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..30bab2a --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..b2320b5 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file 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/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..fe537f9 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..c2024ad --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/EaglerPluginInstaller.iml b/EaglerPluginInstaller.iml new file mode 100644 index 0000000..4ec1b0e --- /dev/null +++ b/EaglerPluginInstaller.iml @@ -0,0 +1,12 @@ + + + + + + + BUKKIT + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ba06aa2 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# PluginInstaller +PluginInstaller is a plugin designed for eaglercraft that can install plugins from an [online repository](https://github.com/darverdevs/PluginInstallerRepo) to your server just with a /install command. +This plugin also has an autoupdater so theres no need to constantly redownload the plugin. +#### **The download link is [here](https://github.com/darverdevs/PluginInstaller/raw/main/out/artifacts/PluginInstaller_jar/PluginInstaller.jar)** +## How to contribute: +Since PluginInstaller runs on an autoupdater, all contributions must be made from pull requests either by forks or branches approved by someone in the darverdevs group and tested before a pull request is made diff --git a/out/artifacts/EaglerPluginInstaller_jar/EaglerPluginInstaller.jar b/out/artifacts/EaglerPluginInstaller_jar/EaglerPluginInstaller.jar new file mode 100644 index 0000000..4c8e92e Binary files /dev/null and b/out/artifacts/EaglerPluginInstaller_jar/EaglerPluginInstaller.jar differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..ef33914 --- /dev/null +++ b/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + + tech.nully + EaglerPluginInstaller + 1.0.0 + jar + + EaglerPluginInstaller + + A plugin made to install other plugins from an online repository to eaglercraft servers with a single command + nully.tech + + 1.8 + UTF-8 + 1.8 + 1.8 + + + + + PrimCoreRepos-repos + https://github.com/darverdevs/EaglerMavenRepo/raw/main + + + + + + com.github.EaglerMaven + craftbukkit + 1.5.2-R1.0 + + + + + \ No newline at end of file diff --git a/src/main/java/tech/nully/PluginInstaller/InstallCommand.java b/src/main/java/tech/nully/PluginInstaller/InstallCommand.java new file mode 100644 index 0000000..1ecdc61 --- /dev/null +++ b/src/main/java/tech/nully/PluginInstaller/InstallCommand.java @@ -0,0 +1,55 @@ +package tech.nully.PluginInstaller; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +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 { + + @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.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"); + } + } + } + } + return false; + } +} diff --git a/src/main/java/tech/nully/PluginInstaller/Installer.java b/src/main/java/tech/nully/PluginInstaller/Installer.java new file mode 100644 index 0000000..a5a64d7 --- /dev/null +++ b/src/main/java/tech/nully/PluginInstaller/Installer.java @@ -0,0 +1,41 @@ +package tech.nully.PluginInstaller; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; + +import java.io.File; +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 { + + public void InstallPlugin(InputStream in, String pluginName, CommandSender s) throws IOException { + File f = new File(Main.getInstance().getDataFolder().getParent() + "/" + pluginName + ".jar"); + Files.copy(in, f.toPath(), StandardCopyOption.REPLACE_EXISTING); + } + + 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 InstallUpdater() throws IOException { + File file = new File(Main.getInstance().getDataFolder().getParent() + "/EaglerPluginUpdater.jar"); + if (!(file.exists())) { + URL plugin = URI.create("https://github.com/darverdevs/PluginInstaller/raw/Updater/out/artifacts/EaglerPluginUpdater_jar/EaglerPluginUpdater.jar") + .toURL(); + InputStream in = plugin.openStream(); + Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING); + } + } +} diff --git a/src/main/java/tech/nully/PluginInstaller/Main.java b/src/main/java/tech/nully/PluginInstaller/Main.java new file mode 100644 index 0000000..da84fc7 --- /dev/null +++ b/src/main/java/tech/nully/PluginInstaller/Main.java @@ -0,0 +1,44 @@ +package tech.nully.PluginInstaller; + +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 { + private static Plugin instance = null; + public static Plugin getInstance() { + return instance; + } + @Override + public void onEnable() { + instance = this; + try { + Installer.InstallUpdater(); + } catch (IOException e) {} + getCommand("install").setExecutor(new InstallCommand()); + getCommand("plist").setExecutor(new plistCommand()); + getServer().getConsoleSender().sendMessage("--------------------------------------------"); + getServer().getConsoleSender().sendMessage("--------------------------------------------"); + getServer().getConsoleSender().sendMessage( + ChatColor.GREEN + "[EaglerPluginInstaller]" + ChatColor.AQUA + " EaglerPluginInstaller V1.0.9 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("--------------------------------------------"); + } + + @Override + public void onDisable() { + getServer().getConsoleSender().sendMessage("--------------------------------------------"); + getServer().getConsoleSender().sendMessage("--------------------------------------------"); + getServer().getConsoleSender().sendMessage( + ChatColor.GREEN + "[EaglerPluginInstaller]" + ChatColor.AQUA + " PluginInstaller V1.0.9 is now Disabled! D:"); + 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..c9a893f --- /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. ProtocolLib"); + sender.sendMessage("3. PermissionSex 10. MCore"); + 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 new file mode 100644 index 0000000..34b3e58 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,15 @@ +name: EaglerPluginInstaller +version: 1.0.9 +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 from an online repository +website: nully.tech +commands: + 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 new file mode 100644 index 0000000..34b3e58 --- /dev/null +++ b/target/classes/plugin.yml @@ -0,0 +1,15 @@ +name: EaglerPluginInstaller +version: 1.0.9 +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 from an online repository +website: nully.tech +commands: + 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 new file mode 100644 index 0000000..666f54c Binary files /dev/null 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 new file mode 100644 index 0000000..4b1d57b Binary files /dev/null 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 new file mode 100644 index 0000000..13959ec Binary files /dev/null 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..9d15c34 Binary files /dev/null and b/target/classes/tech/nully/PluginInstaller/plistCommand.class differ