mirror of
https://github.com/darverdevs/PluginInstaller.git
synced 2024-11-22 09:16:06 -08:00
Alpha version release commit
This commit is contained in:
parent
9175d6e824
commit
521cabe04f
8
.idea/artifacts/PluginInstaller_jar.xml
Normal file
8
.idea/artifacts/PluginInstaller_jar.xml
Normal 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
6
.idea/vcs.xml
Normal 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>
|
BIN
out/artifacts/PluginInstaller_jar/PluginInstaller.jar
Normal file
BIN
out/artifacts/PluginInstaller_jar/PluginInstaller.jar
Normal file
Binary file not shown.
|
@ -1,31 +1,43 @@
|
||||||
package tech.nully.PluginInstaller;
|
package tech.nully.PluginInstaller;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
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.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.util.Locale;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
public class InstallCommand implements CommandExecutor {
|
public class InstallCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender snder, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender snder, Command cmd, String label, String[] args) {
|
||||||
|
// Name checker
|
||||||
if (cmd.getName().equalsIgnoreCase("installpl")) {
|
if (cmd.getName().equalsIgnoreCase("installpl")) {
|
||||||
|
snder.sendMessage("Check 1 passed");
|
||||||
|
if (snder.isOp() || snder instanceof ConsoleCommandSender) {
|
||||||
|
snder.sendMessage("Check 2 passed");
|
||||||
Installer ins = new Installer();
|
Installer ins = new Installer();
|
||||||
String Install_Jar = cmd.getName();
|
if (args.length != 1) return false;
|
||||||
if (ins.JARURLs.containsKey(Install_Jar)) {
|
snder.sendMessage("Check 3 passed");
|
||||||
try (InputStream in = URI.create(ins.JARURLs.get(Install_Jar)).toURL().openStream()) {
|
String Install_Jar = args[0].toLowerCase();
|
||||||
ins.InstallPlugin(in);
|
|
||||||
|
// 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) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package tech.nully.PluginInstaller;
|
package tech.nully.PluginInstaller;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
@ -7,14 +11,24 @@ import java.nio.file.StandardCopyOption;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Installer {
|
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();
|
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 {
|
public void InstallPlugin(InputStream in, String pluginName, CommandSender s) throws IOException {
|
||||||
Files.copy(in, Main.getInstance().getDataFolder().toPath(), StandardCopyOption.REPLACE_EXISTING);
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,40 @@
|
||||||
package tech.nully.PluginInstaller;
|
package tech.nully.PluginInstaller;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Main extends JavaPlugin {
|
public class Main extends JavaPlugin {
|
||||||
private static Plugin instance = null;
|
private static Plugin instance = null;
|
||||||
public static Plugin getInstance() {
|
public static Plugin getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
private static HashMap<String, String> javaURLs = null;
|
||||||
|
public static HashMap<String, String> getJavaURLs() {
|
||||||
|
return javaURLs;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
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
|
@Override
|
||||||
public void onDisable() {
|
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("--------------------------------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
11
src/main/resources/plugin.yml
Normal file
11
src/main/resources/plugin.yml
Normal 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
11
target/classes/plugin.yml
Normal 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
|
BIN
target/classes/tech/nully/PluginInstaller/InstallCommand.class
Normal file
BIN
target/classes/tech/nully/PluginInstaller/InstallCommand.class
Normal file
Binary file not shown.
BIN
target/classes/tech/nully/PluginInstaller/Installer.class
Normal file
BIN
target/classes/tech/nully/PluginInstaller/Installer.class
Normal file
Binary file not shown.
BIN
target/classes/tech/nully/PluginInstaller/Main.class
Normal file
BIN
target/classes/tech/nully/PluginInstaller/Main.class
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user