Problem setting fire to air after a specific amount of time

Discussion in 'Plugin Development' started by Trytan, Aug 5, 2015.

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

    Trytan

    I need help setting fire to air after 5 seconds. Could someone correct me.

    Code:
    package me.trytan.iffa.Events;
    
    import me.trytan.iffa.Main;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockPlaceEvent;
    
    public class Fire_Event implements Listener{
       
        Main pl;
       
        @EventHandler
        public void onPlace(final BlockPlaceEvent e){
            if(e.getBlock().getType() == Material.FIRE){
                Bukkit.getServer().getScheduler().scheduleAsyncDelayedTask(pl, new Runnable(){
                    public void run() {
                        e.getBlock().setType(Material.AIR);
                    }
                   
                }, 50L);
            }
        }
    
    }
    
     
  2. Offline

    Gater12

    @Trytan
    Do NOT use an Async task for that.

    Use sync task.
     
    Shortninja66 and mine-care like this.
  3. Also Main pl; is null so your scheduler will not work
    And 50L is 2.5 seconds. It is in ticks (20 ticks = 1 second) so you need 100L or 5L * 20L
     
    Last edited: Aug 5, 2015
    Shortninja66 likes this.
Thread Status:
Not open for further replies.

Share This Page