mirror of
https://github.com/darverdevs/PluginInstaller.git
synced 2024-11-22 01:06:06 -08:00
Updated installers
This commit is contained in:
parent
521cabe04f
commit
c586620883
|
@ -21,12 +21,14 @@ public class InstallCommand implements CommandExecutor {
|
|||
if (snder.isOp() || snder instanceof ConsoleCommandSender) {
|
||||
snder.sendMessage("Check 2 passed");
|
||||
Installer ins = new Installer();
|
||||
if (args.length != 1) return false;
|
||||
|
||||
// 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 (Main.getJavaURLs().containsKey(Install_Jar)) {
|
||||
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()) {
|
||||
|
@ -35,9 +37,21 @@ public class InstallCommand implements CommandExecutor {
|
|||
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) {
|
||||
} catch (IOException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
|
|
@ -6,6 +6,9 @@ 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.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.HashMap;
|
||||
|
@ -31,4 +34,12 @@ public class Installer {
|
|||
System.out.println(f.toPath().toString());
|
||||
s.sendMessage("Check 2x passed");
|
||||
}
|
||||
|
||||
public boolean IsValidLink(String url) throws MalformedURLException, IOException{
|
||||
URL u = new URL(url);
|
||||
HttpURLConnection huc = (HttpURLConnection) u.openConnection();
|
||||
huc.setRequestMethod("GET");
|
||||
huc.connect();
|
||||
return huc.getResponseCode() == 200;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user