Skip to content

Commit

Permalink
match_player tags: match startsWith stronger than contains
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 4, 2021
1 parent cf5074c commit 7095b61
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
Expand Up @@ -126,6 +126,10 @@ public InventoryCommand() {
// - inventory exclude origin:stick|stone
//
// @Usage
// Use to clear the player's inventory entirely.
// - inventory clear
//
// @Usage
// Use to swap two players' inventories.
// - inventory swap d:<[playerOne].inventory> o:<[playerTwo].inventory>
//
Expand Down
Expand Up @@ -94,15 +94,15 @@ public ModifyBlockCommand() {
//
// @Usage
// Use to modify an entire cuboid to half stone, half dirt.
// - modifyblock <cuboid[<player.location>|<player.cursor_on>]> stone|dirt
// - modifyblock <player.location.to_cuboid[<player.cursor_on>]> stone|dirt
//
// @Usage
// Use to modify an entire cuboid to some stone, some dirt, and some left as it is.
// - modifyblock <cuboid[<player.location>|<player.cursor_on>]> stone|dirt 25|25
// - modifyblock <player.location.to_cuboid[<player.cursor_on>]> stone|dirt 25|25
//
// @Usage
// Use to modify the ground beneath the player's feet.
// - modifyblock <cuboid[<player.location.add[2,-1,2]>|<player.location.add[-2,-1,-2]>]> RED_WOOL
// - modifyblock <player.location.add[2,-1,2].to_cuboid[<player.location.add[-2,-1,-2]>]> RED_WOOL
// -->

@Override
Expand Down
Expand Up @@ -1530,12 +1530,15 @@ else if (recipe instanceof CookingRecipe<?>) {
return;
}
for (Player player : Bukkit.getOnlinePlayers()) {
if (CoreUtilities.equalsIgnoreCase(player.getName(), matchInput)) {
String nameLow = CoreUtilities.toLowerCase(player.getName());
if (nameLow.equals(matchInput)) {
matchPlayer = player;
break;
}
else if (CoreUtilities.toLowerCase(player.getName()).contains(matchInput) && matchPlayer == null) {
matchPlayer = player;
else if (nameLow.contains(matchInput)) {
if (matchPlayer == null || nameLow.startsWith(matchInput)) {
matchPlayer = player;
}
}
}

Expand All @@ -1561,12 +1564,15 @@ else if (CoreUtilities.toLowerCase(player.getName()).contains(matchInput) && mat
return;
}
for (Map.Entry<String, UUID> entry : PlayerTag.getAllPlayers().entrySet()) {
if (CoreUtilities.equalsIgnoreCase(entry.getKey(), matchInput)) {
String nameLow = CoreUtilities.toLowerCase(entry.getKey());
if (nameLow.equals(matchInput)) {
matchPlayer = entry.getValue();
break;
}
else if (CoreUtilities.toLowerCase(entry.getKey()).contains(matchInput) && matchPlayer == null) {
matchPlayer = entry.getValue();
else if (nameLow.contains(matchInput)) {
if (matchPlayer == null || nameLow.startsWith(matchInput)) {
matchPlayer = entry.getValue();
}
}
}
if (matchPlayer != null) {
Expand Down

0 comments on commit 7095b61

Please sign in to comment.