Skip to content

Commit 8772367

Browse files
committed
changed the list text spaces
1 parent 0fafd12 commit 8772367

6 files changed

Lines changed: 60 additions & 17 deletions

File tree

241 Bytes
Binary file not shown.

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

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,24 @@
33
import org.bukkit.ChatColor;
44
import org.bukkit.command.CommandSender;
55

6+
import java.util.ArrayList;
7+
import java.util.List;
8+
69
public class PluginList {
710
private static String[] AlphaPluginList = new String[]{"AntiSwear", "AyunCord", "BitchFilter", "CoreProtect", "CrackShot", "CraftBook", "DupePatch", "DynMap", "Essentials",
811
"EssenttialsAntiBuild", "EssentialsChat", "EssentialsProtect", "EssentialsSpawn", "Factions", "MCore", "Multiverse", "MyWarp", "PermissionSex", "ProtocolLib",
912
"Vault", "WorldEdit", "WorldGuard"};
1013
public static void SendPG1ToSender(CommandSender sender) {
1114
sender.sendMessage(ChatColor.GREEN + "Here is a list of available plugins in the database:");
1215
int SecondCollumn = 8;
16+
1317
for (int i = 1; i < 8; i++) {
14-
sender.sendMessage(i+". "+ AlphaPluginList[i-1] + "" +SecondCollumn + ". " + AlphaPluginList[SecondCollumn-1]);
18+
int Spaces = 21-AlphaPluginList[i-1].length();
19+
List<String> spaces = new ArrayList<>();
20+
for (int forInt = 0; i < Spaces; i++) {
21+
spaces.add(" ");
22+
}
23+
sender.sendMessage(i+". "+ AlphaPluginList[i-1] + "" + Utils.ListToString(spaces) + "" +SecondCollumn + ". " + AlphaPluginList[SecondCollumn-1]);
1524
SecondCollumn++;
1625
}
1726
sender.sendMessage(" Page 1 of 12");
@@ -29,19 +38,25 @@ public static void SendPG2ToSender(CommandSender sender) {
2938
String Col2 = "";
3039

3140
// Null checkers for elements in the Array
32-
if (AlphaPluginList[i-1] != null) {
41+
try {
3342
Col1 = AlphaPluginList[i-1];
34-
} else {
43+
} catch (ArrayIndexOutOfBoundsException y) {
3544
Col1 = "N/A";
3645
}
37-
if (AlphaPluginList[SecondCollumn-1] != null) {
46+
try {
3847
Col2 = AlphaPluginList[SecondCollumn-1];
39-
} else {
48+
} catch (ArrayIndexOutOfBoundsException a) {
4049
Col2 = "N/A";
4150
}
4251
// _________________________________________
4352

44-
sender.sendMessage(i+". "+ Col1 + "" + SecondCollumn + ". " + Col2);
53+
int Spaces = 21-AlphaPluginList[i-1].length();
54+
List<String> spaces = new ArrayList<>();
55+
for (int forInt = 0; i < Spaces; i++) {
56+
spaces.add(" ");
57+
}
58+
59+
sender.sendMessage(i+". "+ Col1 + "" + Utils.ListToString(spaces) + "" + SecondCollumn + ". " + Col2);
4560
SecondCollumn++;
4661
}
4762

@@ -60,19 +75,25 @@ public static void SendPG3ToSender(CommandSender sender) {
6075
String Col32;
6176

6277
// Null checkers for elements in the Array
63-
if (AlphaPluginList[i-1] != null) {
78+
try {
6479
Col31 = AlphaPluginList[i-1];
65-
} else {
80+
} catch (ArrayIndexOutOfBoundsException e) {
6681
Col31 = "N/A";
6782
}
68-
if (AlphaPluginList[SecondCollumn-1] != null) {
83+
try {
6984
Col32 = AlphaPluginList[SecondCollumn-1];
70-
} else {
85+
} catch (ArrayIndexOutOfBoundsException e) {
7186
Col32 = "N/A";
7287
}
7388
// _________________________________________
7489

75-
sender.sendMessage(i+". "+ Col31 + "" + SecondCollumn + ". " + Col32);
90+
int Spaces = 21-AlphaPluginList[i-1].length();
91+
List<String> spaces = new ArrayList<>();
92+
for (int forInt = 0; i < Spaces; i++) {
93+
spaces.add(" ");
94+
}
95+
96+
sender.sendMessage(i+". "+ Col31 + "" + Utils.ListToString(spaces) + "" + SecondCollumn + ". " + Col32);
7697
SecondCollumn++;
7798
}
7899

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package tech.nully.PluginInstaller;
2+
3+
import java.util.List;
4+
5+
public class Utils {
6+
public static String ArrayToString(String[] str) {
7+
StringBuilder sb = new StringBuilder();
8+
for (String s : str) {
9+
sb.append(s);
10+
}
11+
return sb.toString();
12+
}
13+
14+
public static String ListToString(List<String> list) {
15+
StringBuilder sb = new StringBuilder();
16+
for (String s : list) {
17+
sb.append(s);
18+
}
19+
return sb.toString();
20+
}
21+
}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ public class plistCommand implements CommandExecutor {
1111
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
1212
if (cmd.getName().equalsIgnoreCase("plist") && sender.isOp() || sender instanceof ConsoleCommandSender) {
1313
if (args.length >= 1) {
14-
if (args[0] == null) {
15-
PluginList.SendPG1ToSender(sender);
16-
return true;
14+
try {
15+
System.out.println(args[0]);
16+
} catch (ArrayIndexOutOfBoundsException e) {
17+
System.out.println("error");
1718
}
1819
int listPage = 0;
1920
boolean PageArgIsInt = false;
@@ -30,13 +31,13 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
3031
switch (PageArg) {
3132
case 1:
3233
PluginList.SendPG1ToSender(sender);
33-
break;
34+
return true;
3435
case 2:
3536
PluginList.SendPG2ToSender(sender);
36-
break;
37+
return true;
3738
case 3:
3839
PluginList.SendPG3ToSender(sender);
39-
break;
40+
return true;
4041
}
4142
}
4243
}
195 Bytes
Binary file not shown.
258 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)