command code cleanup

This commit is contained in:
Oth3r 2024-08-06 11:09:15 -05:00
commit 6da81cb4af

View file

@ -37,13 +37,13 @@ public class SitCommand {
private static int command(ServerCommandSource source, String arg) { private static int command(ServerCommandSource source, String arg) {
ServerPlayerEntity player = source.getPlayer(); ServerPlayerEntity player = source.getPlayer();
//trim all the arguments before the command // trim all the arguments before the command (for commands like /execute)
String keyword = "sit"; int index = arg.indexOf("sit");
int index = Integer.MAX_VALUE; // trims the words before the text
if (arg.contains(keyword)) index = arg.indexOf(keyword); if (index != -1) arg = arg.substring(index).trim();
//trims the words before the text
if (index != Integer.MAX_VALUE) arg = arg.substring(index).trim();
String[] args = arg.split(" "); String[] args = arg.split(" ");
// if command string starts with sit, remove it
if (args[0].equalsIgnoreCase("sit")) if (args[0].equalsIgnoreCase("sit"))
args = arg.replaceFirst("sit ", "").split(" "); args = arg.replaceFirst("sit ", "").split(" ");