1.16.5 How to make armor stand follow you

Discussion in 'Spigot Plugin Development' started by AlexNomad, Jun 9, 2021.

  1. I have this code and I want armor stand to follow player for 2 seconds

    Code (Java):
    package dev.alexnomad.cringe.bubles;

    import dev.alexnomad.cringe.Cringe;
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.entity.ArmorStand;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;

    public class Buble {

        public Buble(Location location, String message, Player player){

                    () -> {
                        ArmorStand armor = (ArmorStand) location.getWorld().spawn(location, EntityType.ARMOR_STAND.getEntityClass());

                        Bukkit.getScheduler().runTaskLater(Cringe.getPlugin(Cringe.class), armor::remove, 40L);


        private void movement(ArmorStand armorStand, Location location){
  2. spawn an armor stand to the player location and do all the settings outside the runnable, then use a run task timer that will run every half second or something, then inside the runnable, update the players location, then teleport your ArmorStand to that location. Don't forget to add a counter or something so you can stop the task after 2 seconds and remove the armorstand,
  3. how stop runTaskTimer?
  4. You can get the task id and call
    Code (Java):
  5. How to get it?
  6. You can get it from your BukkitTask.
    Code (Java):
    int taskid = Bukkit.getScheduler().runTask(plugin, () -> System.out.println("Useless task")).getTaskId();