Putting out the "Player is on fire" status

Discussion in 'Plugin Development' started by Xgkkp, Mar 24, 2011.

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

    Xgkkp

    I'm trying to write something that teleports players out of lava, but I can't seem to do it without the player still being on fire. Is there a good way to stop the player being on fire? I tried capturing ENTITY_DAMAGED and:

    Code:
    player.teleportTo(newlocation);
    player.setFireTicks(0);
    but it doesn't seem to work if the player is still standing in the lava when they are teleported - I assume that some other fire event has been queued up somewhere.
     
  2. Offline

    Edward Hand

    You may need to set their fire ticks to 0 on a delay using bukkit's scheduler.
     
  3. Offline

    Xgkkp

    Ah, thanks, I didn't know about the scheduler - this is what comes from looking at simple examples. I needed to pass the player through to the Runnable object, and it complained about embedding a non-final variable. Is this a good way to do it:
    Code:
    final Player schedPlayer = player;
    plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() {
      public void run() {
        schedPlayer.setFireTicks(0);
        System.out.println("Scheduler running to remove fire from" + schedPlayer.getName());
      }
    }, 1L);
     
  4. Offline

    Edward Hand

    The runnable wont be able to access the variable 'schedPlayer'. It has to be passed to the runnable somehow, with a constructor function or something.
     
  5. Offline

    Xgkkp

    That code works fine - and it can access the variable schedPlayer (It was the non-final player variable that it had trouble accessing) though a constructor sounds like a better way of doing it.
     
Thread Status:
Not open for further replies.

Share This Page