1
0
mirror of https://github.com/BentoBoxWorld/Warps.git synced 2024-11-14 06:36:47 +01:00

Fixes unwanted parsing when warping to an island (#86)

* Fixes incorrect parsing when warping to similiar players

* Removes debug lines
This commit is contained in:
wellnesscookie 2020-08-06 21:14:50 +02:00 committed by GitHub
parent 27afafadce
commit fd06c0cdd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,6 @@ import world.bentobox.warps.Warp;
* The /is warp <name> command
*
* @author tastybento
*
*/
public class WarpCommand extends DelayedTeleportCommand {
@ -52,12 +51,22 @@ public class WarpCommand extends DelayedTeleportCommand {
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));