Plugin forever loops an error instead of a task

Discussion in 'Plugin Development' started by NugNugz, Aug 1, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    NugNugz

    So the server works and I can play. but the plugin does not do what it's supposed to. I get the error:
    Here is my code:
    Code:
    package destroyBlock;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitRunnable;
    
    public class DestroyBlock extends JavaPlugin{
    
        Player p;
    
       
        @Override
        public void onEnable() {
    
    
                new BukkitRunnable() {
               
                    @Override
                    public void run() {
                        int x = p.getLocation().getBlockX();
                        int y = p.getLocation().getBlockY() - 1;
                        int z = p.getLocation().getBlockZ();
                        Location loc = new Location(p.getWorld(), x, y, z);
    
                        loc.getBlock().setType(Material.AIR);
                    }
                }.runTaskTimerAsynchronously(this, 0, 20);
           
            }
        }
       
    
    
    
    
    I know the code works, I tested it to destroy a block every time I moved and it worked. I'm trying to just have it run every second without an event but it won't work. Any suggestions?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @NugNugz runTaskTimerAsynchronously should not be async
    And p is null
     
Thread Status:
Not open for further replies.

Share This Page