Alpha version release commit

This commit is contained in:
Fangoboyo 2022-06-07 14:17:07 -07:00
parent 9175d6e824
commit 521cabe04f
11 changed files with 101 additions and 19 deletions

View File

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="PluginInstaller:jar">
<output-path>$PROJECT_DIR$/out/artifacts/PluginInstaller_jar</output-path>
<root id="archive" name="PluginInstaller.jar">
<element id="module-output" name="PluginInstaller" />
</root>
</artifact>
</component>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

Binary file not shown.

View File

@ -1,31 +1,43 @@
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.craftbukkit.libs.org.ibex.nestedvm.util.Seekable;
import org.bukkit.command.ConsoleCommandSender;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
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("installpl")) {
Installer ins = new Installer();
String Install_Jar = cmd.getName();
if (ins.JARURLs.containsKey(Install_Jar)) {
try (InputStream in = URI.create(ins.JARURLs.get(Install_Jar)).toURL().openStream()) {
ins.InstallPlugin(in);
} catch (IOException e) {
snder.sendMessage("Check 1 passed");
if (snder.isOp() || snder instanceof ConsoleCommandSender) {
snder.sendMessage("Check 2 passed");
Installer ins = new Installer();
if (args.length != 1) return false;
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 (Main.getJavaURLs().containsKey(Install_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) {
}
}
}
}
return false;

View File

@ -1,5 +1,9 @@
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.nio.file.Files;
@ -7,14 +11,24 @@ import java.nio.file.StandardCopyOption;
import java.util.HashMap;
public class Installer {
public HashMap<String, String> JARURLs = new HashMap<>();
private HashMap<String, String> JARURLs = new HashMap<>();
public static void SetupInstaller() {
public static HashMap<String, String> SetupInstaller() {
Installer ins = new Installer();
ins.JARURLs.put("dynmap", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/dynmap-1.9.1.jar");
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) throws IOException {
Files.copy(in, Main.getInstance().getDataFolder().toPath(), StandardCopyOption.REPLACE_EXISTING);
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");
}
}

View File

@ -1,20 +1,40 @@
package tech.nully.PluginInstaller;
import org.bukkit.ChatColor;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
public class Main extends JavaPlugin {
private static Plugin instance = null;
public static Plugin getInstance() {
return instance;
}
private static HashMap<String, String> javaURLs = null;
public static HashMap<String, String> getJavaURLs() {
return javaURLs;
}
@Override
public void onEnable() {
instance = this;
getCommand("installpl").setExecutor(new InstallCommand());
javaURLs = Installer.SetupInstaller();
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("--------------------------------------------");
getServer().getConsoleSender().sendMessage("--------------------------------------------");
}
@Override
public void onDisable() {
getLogger().info("Plugin has been disabled!");
getServer().getConsoleSender().sendMessage("--------------------------------------------");
getServer().getConsoleSender().sendMessage("--------------------------------------------");
getServer().getConsoleSender().sendMessage(
ChatColor.GREEN + "[PluginInstaller]" + ChatColor.AQUA + " PluginInstaller V1.0.0 is now Disabled! D:");
getServer().getConsoleSender().sendMessage("--------------------------------------------");
getServer().getConsoleSender().sendMessage("--------------------------------------------");
}
}

View File

@ -0,0 +1,11 @@
name: PluginInstaller
version: 1.0.0
main: tech.nully.PluginInstaller.Main
prefix: [PluginInstaller]
authors: [BongoCat]
description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft
website: nully.tech
commands:
installpl:
usage: /<command> <plugin>
description: Installs the latest compatible version of the requested plugin

11
target/classes/plugin.yml Normal file
View File

@ -0,0 +1,11 @@
name: PluginInstaller
version: 1.0.0
main: tech.nully.PluginInstaller.Main
prefix: [PluginInstaller]
authors: [BongoCat]
description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft
website: nully.tech
commands:
installpl:
usage: /<command> <plugin>
description: Installs the latest compatible version of the requested plugin

Binary file not shown.