mirror of
https://github.com/BentoBoxWorld/Warps.git
synced 2024-11-14 14:45:48 +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:
parent
27afafadce
commit
fd06c0cdd7
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user