Skip to content

Commit

Permalink
minor string parsing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
insanj committed Feb 18, 2019
1 parent abd3103 commit bc7e502
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
27 changes: 11 additions & 16 deletions plugin/me/insanj/pride/Pride.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,19 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return false;
}

Boolean foundComma = false;
String firstAreaName = "";
String secondAreaName = "";
String argString = "";
for (String arg : args) {
if (arg.contains(",") == true) {
String[] splitStrings = arg.split(",");
firstAreaName += splitStrings[0];
secondAreaName += splitStrings[splitStrings.length-1].trim();
foundComma = true;
} else if (foundComma == true) {
secondAreaName += arg + " ";
} else {
firstAreaName += arg + " ";
}
argString += arg + " ";
}

String[] argSplit = argString.split(",");
if (argSplit.length != 2) {
sender.sendMessage(ChatColor.RED + "Use a comma to separate the two Pride areas");
return false;
}

firstAreaName = firstAreaName.trim();
secondAreaName = secondAreaName.trim();
String firstAreaName = argSplit[0].trim();
String secondAreaName = argSplit[1].trim();

Location firstAreaLocation = (Location)saved.get(firstAreaName);
if (firstAreaLocation == null) {
Expand All @@ -206,7 +201,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

Location secondAreaLocation = (Location)saved.get(secondAreaName);
if (secondAreaLocation == null) {
sender.sendMessage("Could not find both area: " + ChatColor.RED + secondAreaName);
sender.sendMessage("Could not find area: " + ChatColor.RED + secondAreaName);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pride
main: me.insanj.pride.Pride
version: 0.3.7
version: 0.3.8
description: keep track of your playmates in minecraft
commands:
settle:
Expand Down

0 comments on commit bc7e502

Please sign in to comment.