Skip to content

Commit 521cabe

Browse files
committed
Alpha version release commit
1 parent 9175d6e commit 521cabe

11 files changed

Lines changed: 101 additions & 19 deletions

File tree

.idea/artifacts/PluginInstaller_jar.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
4.83 KB
Binary file not shown.

src/main/java/tech/nully/PluginInstaller/InstallCommand.java

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,43 @@
11
package tech.nully.PluginInstaller;
22

3+
import org.bukkit.ChatColor;
34
import org.bukkit.command.Command;
45
import org.bukkit.command.CommandExecutor;
56
import org.bukkit.command.CommandSender;
6-
import org.bukkit.craftbukkit.libs.org.ibex.nestedvm.util.Seekable;
7+
import org.bukkit.command.ConsoleCommandSender;
78

89
import java.io.IOException;
910
import java.io.InputStream;
10-
import java.net.MalformedURLException;
1111
import java.net.URI;
12-
import java.net.URL;
13-
import java.nio.file.Files;
14-
import java.nio.file.Paths;
12+
import java.util.Locale;
1513

1614
public class InstallCommand implements CommandExecutor {
15+
1716
@Override
1817
public boolean onCommand(CommandSender snder, Command cmd, String label, String[] args) {
18+
// Name checker
1919
if (cmd.getName().equalsIgnoreCase("installpl")) {
20-
Installer ins = new Installer();
21-
String Install_Jar = cmd.getName();
22-
if (ins.JARURLs.containsKey(Install_Jar)) {
23-
try (InputStream in = URI.create(ins.JARURLs.get(Install_Jar)).toURL().openStream()) {
24-
ins.InstallPlugin(in);
25-
} catch (IOException e) {
26-
}
27-
20+
snder.sendMessage("Check 1 passed");
21+
if (snder.isOp() || snder instanceof ConsoleCommandSender) {
22+
snder.sendMessage("Check 2 passed");
23+
Installer ins = new Installer();
24+
if (args.length != 1) return false;
25+
snder.sendMessage("Check 3 passed");
26+
String Install_Jar = args[0].toLowerCase();
2827

28+
// Checks if the list of plugin links contains what the user wants to install
29+
if (Main.getJavaURLs().containsKey(Install_Jar)) {
30+
snder.sendMessage("Check 4 passed");
31+
// Creates an input stream based on the corresponding URL from the players first argument
32+
try (InputStream in = URI.create(Main.getJavaURLs().get(Install_Jar)).toURL().openStream()) {
33+
snder.sendMessage("Check 5 passed");
34+
// Installs the plugin
35+
ins.InstallPlugin(in, Install_Jar.toLowerCase(), snder);
36+
snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + Install_Jar.toUpperCase() + ChatColor.WHITE + " plugin!");
37+
return true;
38+
} catch (IOException e) {
39+
}
40+
}
2941
}
3042
}
3143
return false;
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
package tech.nully.PluginInstaller;
22

3+
import org.bukkit.Bukkit;
4+
import org.bukkit.command.CommandSender;
5+
6+
import java.io.File;
37
import java.io.IOException;
48
import java.io.InputStream;
59
import java.nio.file.Files;
610
import java.nio.file.StandardCopyOption;
711
import java.util.HashMap;
812

913
public class Installer {
10-
public HashMap<String, String> JARURLs = new HashMap<>();
14+
private HashMap<String, String> JARURLs = new HashMap<>();
1115

12-
public static void SetupInstaller() {
16+
public static HashMap<String, String> SetupInstaller() {
1317
Installer ins = new Installer();
14-
ins.JARURLs.put("dynmap", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/dynmap-1.9.1.jar");
18+
ins.JARURLs.put("dynmap", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/dynmap-1.9.1.jar");;
19+
ins.JARURLs.put("factions", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/Factions.jar");
20+
ins.JARURLs.put("permissionsex", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/PermissionSex.jar");
21+
ins.JARURLs.put("protocollib", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/ProtocolLib.jar");
22+
ins.JARURLs.put("vault", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/Vault.jar");
23+
ins.JARURLs.put("mcore", "https://github.com/darverdevs/PluginInstallerRepo/raw/main/mcore.jar");
24+
return ins.JARURLs;
1525
}
1626

17-
public void InstallPlugin(InputStream in) throws IOException {
18-
Files.copy(in, Main.getInstance().getDataFolder().toPath(), StandardCopyOption.REPLACE_EXISTING);
27+
public void InstallPlugin(InputStream in, String pluginName, CommandSender s) throws IOException {
28+
File f = new File(Main.getInstance().getDataFolder().getParent() + "/" + pluginName + ".jar");
29+
s.sendMessage("Check 1x passed");
30+
Files.copy(in, f.toPath(), StandardCopyOption.REPLACE_EXISTING);
31+
System.out.println(f.toPath().toString());
32+
s.sendMessage("Check 2x passed");
1933
}
2034
}
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
11
package tech.nully.PluginInstaller;
22

3+
import org.bukkit.ChatColor;
34
import org.bukkit.plugin.Plugin;
45
import org.bukkit.plugin.java.JavaPlugin;
56

7+
import java.util.HashMap;
8+
69
public class Main extends JavaPlugin {
710
private static Plugin instance = null;
811
public static Plugin getInstance() {
912
return instance;
1013
}
14+
private static HashMap<String, String> javaURLs = null;
15+
public static HashMap<String, String> getJavaURLs() {
16+
return javaURLs;
17+
}
1118
@Override
1219
public void onEnable() {
1320
instance = this;
21+
getCommand("installpl").setExecutor(new InstallCommand());
22+
javaURLs = Installer.SetupInstaller();
23+
getServer().getConsoleSender().sendMessage("--------------------------------------------");
24+
getServer().getConsoleSender().sendMessage("--------------------------------------------");
25+
getServer().getConsoleSender().sendMessage(
26+
ChatColor.GREEN + "[PluginInstaller]" + ChatColor.AQUA + " PluginInstaller V1.0.0 is now Enabled! :D");
27+
getServer().getConsoleSender().sendMessage("--------------------------------------------");
28+
getServer().getConsoleSender().sendMessage("--------------------------------------------");
1429
}
1530

1631
@Override
1732
public void onDisable() {
18-
getLogger().info("Plugin has been disabled!");
33+
getServer().getConsoleSender().sendMessage("--------------------------------------------");
34+
getServer().getConsoleSender().sendMessage("--------------------------------------------");
35+
getServer().getConsoleSender().sendMessage(
36+
ChatColor.GREEN + "[PluginInstaller]" + ChatColor.AQUA + " PluginInstaller V1.0.0 is now Disabled! D:");
37+
getServer().getConsoleSender().sendMessage("--------------------------------------------");
38+
getServer().getConsoleSender().sendMessage("--------------------------------------------");
1939
}
2040
}

src/main/resources/plugin.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: PluginInstaller
2+
version: 1.0.0
3+
main: tech.nully.PluginInstaller.Main
4+
prefix: [PluginInstaller]
5+
authors: [BongoCat]
6+
description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft
7+
website: nully.tech
8+
commands:
9+
installpl:
10+
usage: /<command> <plugin>
11+
description: Installs the latest compatible version of the requested plugin

target/classes/plugin.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: PluginInstaller
2+
version: 1.0.0
3+
main: tech.nully.PluginInstaller.Main
4+
prefix: [PluginInstaller]
5+
authors: [BongoCat]
6+
description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft
7+
website: nully.tech
8+
commands:
9+
installpl:
10+
usage: /<command> <plugin>
11+
description: Installs the latest compatible version of the requested plugin
2.88 KB
Binary file not shown.
2.75 KB
Binary file not shown.

0 commit comments

Comments
 (0)