Add initiator to targets if it's an entity and no target was found

This happens when the player runs the command without a target argument or when using the API methods
This commit is contained in:
Phoenix616 2019-04-27 01:14:10 +01:00
parent 24e92041c1
commit 6b98efb1e4

View File

@ -259,6 +259,9 @@ public class RandomSearcher {
*/
public CompletableFuture<Location> search() {
plugin.getRunningSearchers().put(uniqueId, this);
if (targets.isEmpty() && initiator instanceof Entity) {
targets.add((Entity) initiator);
}
future = new CompletableFuture<>();
plugin.getServer().getScheduler().runTask(plugin, () -> checkRandom(future));
future.whenComplete((l, e) -> plugin.getRunningSearchers().remove(uniqueId));