changed the list text spaces

This commit is contained in:
Fangoboyo 2022-06-16 16:15:14 -07:00
parent 0fafd12eb1
commit 87723670c0
6 changed files with 60 additions and 17 deletions

View File

@ -3,6 +3,9 @@ package tech.nully.PluginInstaller;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.List;
public class PluginList { public class PluginList {
private static String[] AlphaPluginList = new String[]{"AntiSwear", "AyunCord", "BitchFilter", "CoreProtect", "CrackShot", "CraftBook", "DupePatch", "DynMap", "Essentials", 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", "EssenttialsAntiBuild", "EssentialsChat", "EssentialsProtect", "EssentialsSpawn", "Factions", "MCore", "Multiverse", "MyWarp", "PermissionSex", "ProtocolLib",
@ -10,8 +13,14 @@ public class PluginList {
public static void SendPG1ToSender(CommandSender sender) { public static void SendPG1ToSender(CommandSender sender) {
sender.sendMessage(ChatColor.GREEN + "Here is a list of available plugins in the database:"); sender.sendMessage(ChatColor.GREEN + "Here is a list of available plugins in the database:");
int SecondCollumn = 8; int SecondCollumn = 8;
for (int i = 1; i < 8; i++) { for (int i = 1; i < 8; i++) {
sender.sendMessage(i+". "+ AlphaPluginList[i-1] + "" +SecondCollumn + ". " + AlphaPluginList[SecondCollumn-1]); int Spaces = 21-AlphaPluginList[i-1].length();
List<String> spaces = new ArrayList<>();
for (int forInt = 0; i < Spaces; i++) {
spaces.add(" ");
}
sender.sendMessage(i+". "+ AlphaPluginList[i-1] + "" + Utils.ListToString(spaces) + "" +SecondCollumn + ". " + AlphaPluginList[SecondCollumn-1]);
SecondCollumn++; SecondCollumn++;
} }
sender.sendMessage(" Page 1 of 12"); sender.sendMessage(" Page 1 of 12");
@ -29,19 +38,25 @@ public class PluginList {
String Col2 = ""; String Col2 = "";
// Null checkers for elements in the Array // Null checkers for elements in the Array
if (AlphaPluginList[i-1] != null) { try {
Col1 = AlphaPluginList[i-1]; Col1 = AlphaPluginList[i-1];
} else { } catch (ArrayIndexOutOfBoundsException y) {
Col1 = "N/A"; Col1 = "N/A";
} }
if (AlphaPluginList[SecondCollumn-1] != null) { try {
Col2 = AlphaPluginList[SecondCollumn-1]; Col2 = AlphaPluginList[SecondCollumn-1];
} else { } catch (ArrayIndexOutOfBoundsException a) {
Col2 = "N/A"; Col2 = "N/A";
} }
// _________________________________________ // _________________________________________
sender.sendMessage(i+". "+ Col1 + "" + SecondCollumn + ". " + Col2); int Spaces = 21-AlphaPluginList[i-1].length();
List<String> spaces = new ArrayList<>();
for (int forInt = 0; i < Spaces; i++) {
spaces.add(" ");
}
sender.sendMessage(i+". "+ Col1 + "" + Utils.ListToString(spaces) + "" + SecondCollumn + ". " + Col2);
SecondCollumn++; SecondCollumn++;
} }
@ -60,19 +75,25 @@ public class PluginList {
String Col32; String Col32;
// Null checkers for elements in the Array // Null checkers for elements in the Array
if (AlphaPluginList[i-1] != null) { try {
Col31 = AlphaPluginList[i-1]; Col31 = AlphaPluginList[i-1];
} else { } catch (ArrayIndexOutOfBoundsException e) {
Col31 = "N/A"; Col31 = "N/A";
} }
if (AlphaPluginList[SecondCollumn-1] != null) { try {
Col32 = AlphaPluginList[SecondCollumn-1]; Col32 = AlphaPluginList[SecondCollumn-1];
} else { } catch (ArrayIndexOutOfBoundsException e) {
Col32 = "N/A"; Col32 = "N/A";
} }
// _________________________________________ // _________________________________________
sender.sendMessage(i+". "+ Col31 + "" + SecondCollumn + ". " + Col32); int Spaces = 21-AlphaPluginList[i-1].length();
List<String> spaces = new ArrayList<>();
for (int forInt = 0; i < Spaces; i++) {
spaces.add(" ");
}
sender.sendMessage(i+". "+ Col31 + "" + Utils.ListToString(spaces) + "" + SecondCollumn + ". " + Col32);
SecondCollumn++; SecondCollumn++;
} }

View File

@ -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<String> list) {
StringBuilder sb = new StringBuilder();
for (String s : list) {
sb.append(s);
}
return sb.toString();
}
}

View File

@ -11,9 +11,10 @@ public class plistCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("plist") && sender.isOp() || sender instanceof ConsoleCommandSender) { if (cmd.getName().equalsIgnoreCase("plist") && sender.isOp() || sender instanceof ConsoleCommandSender) {
if (args.length >= 1) { if (args.length >= 1) {
if (args[0] == null) { try {
PluginList.SendPG1ToSender(sender); System.out.println(args[0]);
return true; } catch (ArrayIndexOutOfBoundsException e) {
System.out.println("error");
} }
int listPage = 0; int listPage = 0;
boolean PageArgIsInt = false; boolean PageArgIsInt = false;
@ -30,13 +31,13 @@ public class plistCommand implements CommandExecutor {
switch (PageArg) { switch (PageArg) {
case 1: case 1:
PluginList.SendPG1ToSender(sender); PluginList.SendPG1ToSender(sender);
break; return true;
case 2: case 2:
PluginList.SendPG2ToSender(sender); PluginList.SendPG2ToSender(sender);
break; return true;
case 3: case 3:
PluginList.SendPG3ToSender(sender); PluginList.SendPG3ToSender(sender);
break; return true;
} }
} }
} }