use of me.xjcyan1de.cyanbot.utils.schedule.TimerCount in project CyanBot by XjCyan1de.
the class CommandWhere method execute.
@Override
public void execute(CommandEvent event) {
final Bot bot = event.getBot();
final Entity entity = event.has(0, "я") ? bot.getWorld().getPlayer(event.getSender()) : bot.getWorld().getPlayer(event.arg(0));
if (entity != null) {
Schedule.cancel(timerTask);
final Location loc = bot.getLoc();
timerTask = Schedule.timer(new TimerCount(() -> {
final float pitch = loc.getPitch();
final float yaw = loc.getYaw();
loc.setDir(entity.getX() - loc.getX(), entity.getY() - loc.getY(), entity.getZ() - loc.getZ());
loc.setYaw(smoothly(loc.getYaw(), yaw));
loc.setPitch(smoothly(loc.getPitch(), pitch));
System.out.println(loc.getYaw() + " " + loc.getPitch());
}, 100) {
@Override
public boolean cancel() {
timerTask = null;
bot.sendMessage("Та вижу я!");
return super.cancel();
}
}, 50, 50);
}
}
Aggregations