diff --git a/.idea/artifacts/EaglerPluginInstaller_jar.xml b/.idea/artifacts/EaglerPluginInstaller_jar.xml index 70e0900..e7e98be 100644 --- a/.idea/artifacts/EaglerPluginInstaller_jar.xml +++ b/.idea/artifacts/EaglerPluginInstaller_jar.xml @@ -3,6 +3,7 @@ $PROJECT_DIR$/out/artifacts/EaglerPluginInstaller_jar + \ No newline at end of file diff --git a/out/artifacts/EaglerPluginInstaller_jar/EaglerPluginInstaller.jar b/out/artifacts/EaglerPluginInstaller_jar/EaglerPluginInstaller.jar index ab7d17e..2e477b3 100644 Binary files a/out/artifacts/EaglerPluginInstaller_jar/EaglerPluginInstaller.jar and b/out/artifacts/EaglerPluginInstaller_jar/EaglerPluginInstaller.jar differ diff --git a/pom.xml b/pom.xml index ef33914..3b5f0a7 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,11 @@ craftbukkit 1.5.2-R1.0 + + com.googlecode.json-simple + json-simple + 1.1 + diff --git a/src/main/java/tech/nully/PluginInstaller/InstallCommand.java b/src/main/java/tech/nully/PluginInstaller/InstallCommand.java index 1f98adb..32f9088 100644 --- a/src/main/java/tech/nully/PluginInstaller/InstallCommand.java +++ b/src/main/java/tech/nully/PluginInstaller/InstallCommand.java @@ -35,15 +35,23 @@ public class InstallCommand implements CommandExecutor { try (InputStream in = plugin.openStream()) { // Installs the plugin - ins.InstallPlugin(in, Install_Jar.toLowerCase()); + ins.InstallPlugin(in, Install_Jar.substring(0, 1).toUpperCase() + Install_Jar.substring(1)); 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(); + InputStream reco2 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/essentials.jar") + .toURL().openStream(); + InputStream reco3 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/essentialsspawn.jar") + .toURL().openStream(); ins.InstallPlugin(reco1, "DupePatch"); snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "DupePatch" + ChatColor.WHITE + " plugin!"); + ins.InstallPlugin(reco1, "Essentials"); + snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "Essentials" + ChatColor.WHITE + " plugin!"); + ins.InstallPlugin(reco1, "EssentialsSpawn"); + snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + "EssentialsSpawn" + ChatColor.WHITE + " plugin!"); return true; } } catch (IOException e) { diff --git a/src/main/java/tech/nully/PluginInstaller/Main.java b/src/main/java/tech/nully/PluginInstaller/Main.java index 38f8360..5f11f44 100644 --- a/src/main/java/tech/nully/PluginInstaller/Main.java +++ b/src/main/java/tech/nully/PluginInstaller/Main.java @@ -25,7 +25,7 @@ public class Main extends JavaPlugin { getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage( - ChatColor.GREEN + "[EaglerPluginInstaller]" + ChatColor.AQUA + " EaglerPluginInstaller V1.1.0 is now Enabled! :D"); + ChatColor.GREEN + "[EaglerPluginInstaller]" + ChatColor.AQUA + " EaglerPluginInstaller V1.1.1 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"); @@ -39,7 +39,7 @@ public class Main extends JavaPlugin { getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage( - ChatColor.GREEN + "[EaglerPluginInstaller]" + ChatColor.AQUA + " PluginInstaller V1.1.0 is now Disabled! D:"); + ChatColor.GREEN + "[EaglerPluginInstaller]" + ChatColor.AQUA + " PluginInstaller V1.1.1 is now Disabled! D:"); getServer().getConsoleSender().sendMessage("--------------------------------------------"); getServer().getConsoleSender().sendMessage("--------------------------------------------"); } diff --git a/src/main/java/tech/nully/PluginInstaller/PluginList.java b/src/main/java/tech/nully/PluginInstaller/PluginList.java new file mode 100644 index 0000000..7acc999 --- /dev/null +++ b/src/main/java/tech/nully/PluginInstaller/PluginList.java @@ -0,0 +1,103 @@ +package tech.nully.PluginInstaller; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; + +import java.util.ArrayList; +import java.util.List; + +public class PluginList { + private static String[] AlphaPluginList = new String[]{"AntiSwear", "AyunCord", "BitchFilter", "CoreProtect", "CrackShot", "CraftBook", "DupePatch", "DynMap", "Essentials", + "EssenttialsAntiBuild", "EssentialsChat", "EssentialsProtect", "EssentialsSpawn", "Factions", "MCore", "Multiverse", "MyWarp", "PermissionSex", "ProtocolLib", + "Vault", "WorldEdit", "WorldGuard"}; + public static void SendPG1ToSender(CommandSender sender) { + sender.sendMessage(ChatColor.GREEN + "Here is a list of available plugins in the database:"); + int SecondCollumn = 8; + + for (int i = 1; i < 8; i++) { + int Spaces = 21-AlphaPluginList[i-1].length(); + List spaces = new ArrayList<>(); + for (int forInt = 0; forInt < Spaces; forInt++) { + spaces.add(" "); + } + sender.sendMessage(i+". "+ AlphaPluginList[i-1] + "" + Utils.ListToString(spaces) + "" +SecondCollumn + ". " + AlphaPluginList[SecondCollumn-1]); + SecondCollumn++; + } + sender.sendMessage(" Page 1 of 12"); + sender.sendMessage("Note: You do not need to have proper"); + sender.sendMessage("capitalization when using the install command"); + } + + public static void SendPG2ToSender(CommandSender sender) { + sender.sendMessage(ChatColor.GREEN + "Here is a list of available plugins in the database:"); + + // List ------------------------------------------------------------- + int SecondCollumn = 22; + for (int i = 15; i < 22; i++) { + String Col1; + String Col2; + + // Null checkers for elements in the Array + try { + Col1 = AlphaPluginList[i-1]; + } catch (ArrayIndexOutOfBoundsException y) { + Col1 = "N/A"; + } + try { + Col2 = AlphaPluginList[SecondCollumn-1]; + } catch (ArrayIndexOutOfBoundsException a) { + Col2 = "N/A"; + } + // _________________________________________ + + int Spaces = 21-AlphaPluginList[i-1].length(); + List spaces = new ArrayList<>(); + for (int forInt = 0; forInt < Spaces; forInt++) { + spaces.add(" "); + } + sender.sendMessage(i+". "+ Col1 + "" + Utils.ListToString(spaces) + "" + SecondCollumn + ". " + Col2); + SecondCollumn++; + } + + sender.sendMessage(" Page 2 of 12"); + sender.sendMessage("Note: You do not need to have proper"); + sender.sendMessage("capitalization when using the install command"); + } + + public static void SendPG3ToSender(CommandSender sender) { + sender.sendMessage(ChatColor.GREEN + "Here is a list of available plugins in the database:"); + + // List ------------------------------------------------------------- + int SecondCollumn = 36; + for (int i = 29; i < 36; i++) { + String Col31; + String Col32; + + // Null checkers for elements in the Array + try { + Col31 = AlphaPluginList[i-1]; + } catch (ArrayIndexOutOfBoundsException e) { + Col31 = "N/A"; + } + try { + Col32 = AlphaPluginList[SecondCollumn-1]; + } catch (ArrayIndexOutOfBoundsException e) { + Col32 = "N/A"; + } + // _________________________________________ + + int Spaces = 21-Col31.length(); + List spaces = new ArrayList<>(); + for (int forInt = 0; forInt < Spaces; forInt++) { + spaces.add(" "); + } + sender.sendMessage(i+". "+ Col31 + "" + Utils.ListToString(spaces) + "" + SecondCollumn + ". " + Col32); + SecondCollumn++; + } + + sender.sendMessage(" Page 3 of 12"); + sender.sendMessage("Note: You do not need to have proper"); + sender.sendMessage("capitalization when using the install command"); + } +} + diff --git a/src/main/java/tech/nully/PluginInstaller/Utils.java b/src/main/java/tech/nully/PluginInstaller/Utils.java new file mode 100644 index 0000000..16a932e --- /dev/null +++ b/src/main/java/tech/nully/PluginInstaller/Utils.java @@ -0,0 +1,21 @@ +package tech.nully.PluginInstaller; + +import java.util.List; + +public class Utils { + public static String ArrayToString(String[] str) { + StringBuilder sb = new StringBuilder(); + for (String s : str) { + sb.append(s); + } + return sb.toString(); + } + + public static String ListToString(List list) { + StringBuilder sb = new StringBuilder(); + for (String s : list) { + sb.append(s); + } + return sb.toString(); + } +} diff --git a/src/main/java/tech/nully/PluginInstaller/plistCommand.java b/src/main/java/tech/nully/PluginInstaller/plistCommand.java index c9a893f..855627f 100644 --- a/src/main/java/tech/nully/PluginInstaller/plistCommand.java +++ b/src/main/java/tech/nully/PluginInstaller/plistCommand.java @@ -4,21 +4,44 @@ import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; 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. "); - } + if (cmd.getName().equalsIgnoreCase("plist") && sender.isOp() || sender instanceof ConsoleCommandSender) { + if (args.length >= 1) { + try { + System.out.println(args[0]); + } catch (ArrayIndexOutOfBoundsException e) { + System.out.println("error"); + } + int listPage = 0; + boolean PageArgIsInt = false; + try { + listPage= Integer.parseInt(args[0]); + PageArgIsInt = true; + } catch (NumberFormatException n) { + sender.sendMessage(ChatColor.RED + "That is not a valid page number!"); + PageArgIsInt = false; + return true; + } + if (PageArgIsInt) { + int PageArg = Integer.parseInt(args[0]); + switch (PageArg) { + case 1: + PluginList.SendPG1ToSender(sender); + return true; + case 2: + PluginList.SendPG2ToSender(sender); + return true; + case 3: + PluginList.SendPG3ToSender(sender); + return true; + } + } + } + } return false; } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c2c34b0..562067e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,10 +1,10 @@ name: EaglerPluginInstaller -version: 1.1.0 +version: 1.1.1 main: tech.nully.PluginInstaller.Main prefix: [EaglerPluginInstaller] loadbefore: [EaglerPluginUpdater] authors: [BongoCat] -description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft from an online repository +description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft from an online repository weith the executing of a command. website: nully.tech commands: install: diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml index c2c34b0..562067e 100644 --- a/target/classes/plugin.yml +++ b/target/classes/plugin.yml @@ -1,10 +1,10 @@ name: EaglerPluginInstaller -version: 1.1.0 +version: 1.1.1 main: tech.nully.PluginInstaller.Main prefix: [EaglerPluginInstaller] loadbefore: [EaglerPluginUpdater] authors: [BongoCat] -description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft from an online repository +description: A plugin that is capable of installing the latest compatible version of plugins with eaglercraft from an online repository weith the executing of a command. website: nully.tech commands: install: diff --git a/target/classes/tech/nully/PluginInstaller/InstallCommand.class b/target/classes/tech/nully/PluginInstaller/InstallCommand.class index 2d82488..9b2eab3 100644 Binary files a/target/classes/tech/nully/PluginInstaller/InstallCommand.class and b/target/classes/tech/nully/PluginInstaller/InstallCommand.class differ diff --git a/target/classes/tech/nully/PluginInstaller/Main.class b/target/classes/tech/nully/PluginInstaller/Main.class index c977204..1c21f95 100644 Binary files a/target/classes/tech/nully/PluginInstaller/Main.class and b/target/classes/tech/nully/PluginInstaller/Main.class differ diff --git a/target/classes/tech/nully/PluginInstaller/PluginList.class b/target/classes/tech/nully/PluginInstaller/PluginList.class new file mode 100644 index 0000000..e042da0 Binary files /dev/null and b/target/classes/tech/nully/PluginInstaller/PluginList.class differ diff --git a/target/classes/tech/nully/PluginInstaller/Utils.class b/target/classes/tech/nully/PluginInstaller/Utils.class new file mode 100644 index 0000000..f2162a1 Binary files /dev/null and b/target/classes/tech/nully/PluginInstaller/Utils.class differ diff --git a/target/classes/tech/nully/PluginInstaller/plistCommand.class b/target/classes/tech/nully/PluginInstaller/plistCommand.class index 9d15c34..a7e1355 100644 Binary files a/target/classes/tech/nully/PluginInstaller/plistCommand.class and b/target/classes/tech/nully/PluginInstaller/plistCommand.class differ