Add ability to set custom structures as locatable by Ender Eyes

This commit is contained in:
dfsek
2020-10-21 00:37:10 -07:00
parent 1ccd14a973
commit 862e9e82a2
10 changed files with 138 additions and 24 deletions

View File

@@ -7,6 +7,7 @@ import com.dfsek.terra.config.genconfig.StructureConfig;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.generation.TerraChunkGenerator;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -42,7 +43,19 @@ public class LocateCommand extends WorldCommand {
LangUtil.send("command.structure.invalid", sender, id);
return true;
}
Bukkit.getScheduler().runTaskAsynchronously(Terra.getInstance(), new AsyncStructureFinder(TerraWorld.getWorld(world).getGrid(), s, sender, 0, maxRadius, tp));
Bukkit.getScheduler().runTaskAsynchronously(Terra.getInstance(), new AsyncStructureFinder(TerraWorld.getWorld(world).getGrid(), s, sender.getLocation(), 0, maxRadius, (location) -> {
if(sender.isOnline()) {
if(location != null) {
sender.sendMessage("Located structure at (" + location.getBlockX() + ", " + location.getBlockZ() + ").");
if(tp) {
int finalX = location.getBlockX();
int finalZ = location.getBlockZ();
Bukkit.getScheduler().runTask(Terra.getInstance(), () -> sender.teleport(new Location(sender.getWorld(), finalX, sender.getLocation().getY(), finalZ)));
}
}
else sender.sendMessage("Unable to locate structure. ");
}
}));
return true;
}