Return a CompletableFuture<Boolean> to allow verification of the success of the teleport

This commit is contained in:
Yannick Lamprecht 2019-04-27 00:31:38 +02:00
parent da66a75feb
commit 1d1894883b
2 changed files with 4 additions and 3 deletions

View File

@ -374,8 +374,8 @@ public class RandomTeleport extends JavaPlugin implements RandomTeleportAPI {
}
@Override
public void teleportToRandomLocation(Player player, Location origin, int minRange, int maxRange, LocationValidator... validators) {
getRandomLocation(player, origin, minRange, maxRange, validators).thenApply(player::teleport);
public CompletableFuture<Boolean> teleportToRandomLocation(Player player, Location origin, int minRange, int maxRange, LocationValidator... validators) {
return getRandomLocation(player, origin, minRange, maxRange, validators).thenApply(player::teleport);
}
@Override

View File

@ -47,8 +47,9 @@ public interface RandomTeleportAPI {
* @param minRange the minimum distance a found location has to the center location
* @param maxRange the maximum distance a found location has to the center location
* @param validators additional LocationValidators to customize validity check of a location
* @return a CompletableFuture<Boolean> true if teleport was successful else false
*/
void teleportToRandomLocation(Player player, Location center, int minRange, int maxRange, LocationValidator... validators) throws ExecutionException, InterruptedException;
CompletableFuture<Boolean> teleportToRandomLocation(Player player, Location center, int minRange, int maxRange, LocationValidator... validators) throws ExecutionException, InterruptedException;
/**
* Creates a RandomSearcher instance with the passed parameters