Updated error text

This commit is contained in:
BongoCat 2022-08-06 13:28:06 -07:00
parent 0c4d2e665e
commit 0233ad79c1
4 changed files with 51 additions and 50 deletions

View File

@ -8,12 +8,12 @@
<outputRelativeToContentRoot value="true" /> <outputRelativeToContentRoot value="true" />
<module name="Installer" /> <module name="Installer" />
<module name="EaglerPluginInstaller" /> <module name="EaglerPluginInstaller" />
<module name="PluginInstaller" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel> <bytecodeTargetLevel>
<module name="EaglerPluginUpdater" target="1.8" /> <module name="EaglerPluginUpdater" target="1.8" />
<module name="Installer" target="1.8" /> <module name="Installer" target="1.8" />
<module name="PluginInstaller" target="1.8" />
<module name="PrimCore" target="1.8" /> <module name="PrimCore" target="1.8" />
<module name="untitled" target="1.8" /> <module name="untitled" target="1.8" />
</bytecodeTargetLevel> </bytecodeTargetLevel>

View File

@ -18,28 +18,27 @@ 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 // Name checker
if (cmd.getName().equalsIgnoreCase("install")) {
if (snder.isOp() || snder instanceof ConsoleCommandSender) { if (snder.isOp() || snder instanceof ConsoleCommandSender) {
Installer ins = new Installer(); Installer ins = new Installer();
// handler for install argument // handler for install argument
if (args.length == 1) { if (args.length == 1) {
String Install_Jar = args[0].toLowerCase(); String Install_Jar = args[0].toLowerCase();
// Checks if the created URL is a valid one // Checks if the created URL is a valid one
try { try {
if (ins.IsValidLink("https://github.com/darverdevs/PluginInstallerRepo/raw/main/" + Install_Jar + ".jar")) { if (ins.IsValidLink("https://github.com/darverdevs/PluginInstallerRepo/raw/main/" + Install_Jar + ".jar")) {
//plugin URL //plugin URL
URL plugin = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/" + Install_Jar + ".jar") URL plugin = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/" + Install_Jar + ".jar")
.toURL(); .toURL();
// Creates the InputStream // Creates the InputStream
try (InputStream in = plugin.openStream()) { try (InputStream in = plugin.openStream()) {
// Installs the plugin // Installs the plugin
ins.InstallPlugin(in, Install_Jar.substring(0, 1).toUpperCase() + Install_Jar.substring(1)); 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!"); snder.sendMessage("You have successfully installed the " + ChatColor.GREEN + Install_Jar.toUpperCase() + ChatColor.WHITE + " plugin!");
return true; return true;
} catch (IOException e) {} } catch (IOException e) {
snder.sendMessage("\"" + Install_Jar + "\"" + "is not a valid plugin from the database");
return true;
}
} else if (Install_Jar.equalsIgnoreCase("recommended")) { } else if (Install_Jar.equalsIgnoreCase("recommended")) {
InputStream reco1 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/dupepatch.jar") InputStream reco1 = URI.create("https://github.com/darverdevs/PluginInstallerRepo/raw/main/dupepatch.jar")
.toURL().openStream(); .toURL().openStream();
@ -71,7 +70,9 @@ public class InstallCommand implements CommandExecutor {
snder.sendMessage("\"" + Install_Jar + "\"" + "is not a valid plugin from the database"); snder.sendMessage("\"" + Install_Jar + "\"" + "is not a valid plugin from the database");
return true; return true;
} }
} } else {
snder.sendMessage("You have provided too many arguments!");
snder.sendMessage("The correct usage of this command is: /install <plugin>");
} }
} }
return false; return false;