If player dies in region

Discussion in 'Plugin Development' started by RainoBoy97, Jan 16, 2013.

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

    RainoBoy97

    hay!

    i got this code to save and restore inventory..
    what i want to do:
    - If player dies in a region, teleport to specified location then restore inventory

    how do i check if a player dies in a world guard region? and how do i reset inventory on respawn? (got inventory saved)
     
  2. RainoBoy97
    World Guard has an API for checking that. Visit their page on bukkit dev and look at the documentation.

    For resetting the inventory you can just iterate over every inventory slot and set it to null. And then add your custom inventory.
     
  3. Offline

    RainoBoy97

    The API documentation doesnt explain very well, thats why i asked here..

    Ive tried to add the cusrom inventory on respawn but it doesnt work..
     
  4. Offline

    Frazz86

    or clean the players inventory with
    event.getPlayer().getInventory().clear();
     
  5. Offline

    RainoBoy97

    Frazz86
    I did that, thats not the hard part :p
     
  6. RainoBoy97
    While the documentation is not great you should be able to figure it out for youself.
    As far as i remember you have to hook into world guard in on enable, this gives you an api object which you can use to get a region and then check if a player is inside.
     
  7. Offline

    RainoBoy97

  8. Offline

    Miner_Fil

    i can help you with the teleportation part, So if you want to teleport to the given location use this
    Code:
    Location loc = p.getLocation();
    loc.setX(0);
    loc.setY(0);
    loc.setZ(0);
    p.teleport(loc);
    Replace the Zeros with the co-ords in minecraft x, y and z
     
  9. Offline

    fireblast709

    p.teleport(new Location(p.getWorld(), x, y, z));
     
  10. Offline

    Miner_Fil

    Or you could do it like fireblast explained
     
  11. Offline

    RainoBoy97

    Miner_Fil
    I know how to teleport :p Thats not the part i need help with ;) Thanks anyways.
     
Thread Status:
Not open for further replies.

Share This Page