Skip to content

Commit

Permalink
Fixes unwanted parsing when warping to an island (#86)
Browse files Browse the repository at this point in the history
* Fixes incorrect parsing when warping to similiar players

* Removes debug lines
  • Loading branch information
wellnesscookie committed Aug 6, 2020
1 parent 27afafa commit fd06c0c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/main/java/world/bentobox/warps/commands/WarpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* The /is warp <name> command
*
* @author tastybento
*
*/
public class WarpCommand extends DelayedTeleportCommand {

Expand Down Expand Up @@ -52,12 +51,22 @@ public boolean execute(User user, String label, List<String> args) {
user.sendMessage("warps.warpTip", "[text]", addon.getSettings().getWelcomeLine());
return false;
} else {
// Check if this is part of a name
UUID foundWarp = warpList.stream().filter(u -> getPlayers().getName(u).equalsIgnoreCase(args.get(0))
|| getPlayers().getName(u).toLowerCase().startsWith(args.get(0).toLowerCase())).findFirst().orElse(null);
// Attemp to find warp with exact player's name
UUID foundWarp = warpList.stream().filter(u -> getPlayers().getName(u).equalsIgnoreCase(args.get(0))).findFirst().orElse(null);

if (foundWarp == null) {
user.sendMessage("warps.error.does-not-exist");
return false;

// Atempt to find warp which starts with the given name
UUID foundAlernativeWarp = warpList.stream().filter(u -> getPlayers().getName(u).toLowerCase().startsWith(args.get(0).toLowerCase())).findFirst().orElse(null);

if (foundAlernativeWarp == null) {
user.sendMessage("warps.error.does-not-exist");
return false;
} else {
// Alternative warp found!
this.delayCommand(user, () -> addon.getWarpSignsManager().warpPlayer(world, user, foundAlernativeWarp));
return true;
}
} else {
// Warp exists!
this.delayCommand(user, () -> addon.getWarpSignsManager().warpPlayer(world, user, foundWarp));
Expand Down

0 comments on commit fd06c0c

Please sign in to comment.