[Solved]Teleporting a sleeping player.

Discussion in 'Plugin Development' started by Neodork, May 15, 2012.

  1. Offline

    Neodork

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hello there!

    I tried to teleport a sleeping player on several ways, he keeps teleporting next to the bed. I figured maybe some of you have already experienced this and care to share their knowledge with me... No errors are thrown, it just won't teleport to the right co-ordinates. Instead he teleports "sleeping" next to the bed while standing straight.

    Please feel free to share any information regarding this problem.

    Grtz Neodork.
  2. Online

    LucasEmanuel

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Would using ecject do anything when a player is in the bed?

    PHP:
    player.eject();

    This post has been edited 1 time. It was last edited by LucasEmanuel May 15, 2012.
  3. Offline

    Neodork

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Checking this out.

    Edit: nope.. That's passenger related..

    This post has been edited 1 time. It was last edited by Neodork May 15, 2012.
  4. Offline

    fromgate

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Did you creating bed-teleport plugin? Oh!!! I think it great idea, please don't forget to publish it at bukkit-dev, when it will done :)
  5. Offline

    dsmyth1915

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Cancel the sleeping event, then teleport. Also note if the player is a passenger of a vehicle you CAN NOT teleport or you'll be glitches into blackness. Came across that while trying to teleport to the nether inside a minecart... Did not go over well.
  6. Offline

    Neodork

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Looking for that, maybe you can give me a example how to cancel it ?
  7. Offline

    dsmyth1915

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Only thing I could find was the player enter bed event. Do you want them to teleport as soon as they enter the bed?

    Some psuedo

    playerEnterBedEvent{
    Player player = event.getPlayer()
    Event.setCanelled(true)
    Player.teleport(your location)
    }
  8. Offline

    Neodork

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Yes, I know the event and it's like you say, I want them to be sleeping first.. Not teleport right away..
  9. Offline

    Double0negative

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Teleport the vehicle and the player?
  10. Offline

    Sorroko

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Try this: ((CraftPlayer) player).getHandle().a(true, false, false); It should make the player leave the bed. I have tried this and I am guessing a bit. Tell me if it works. ;)
    Neodork likes this.
  11. Offline

    Father Of Time

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Just throwing random ideas out, but have you though of setting their sleep tick to zero right before the teleport?

    org.bukkit.entity.HumanEntity.getSleepTicks()

    Or if not, instead of using the enter bed event, why not use the leaving bed event? So the player gets in, they sleep for a bit, then when they naturally get out they will be teleported to their destination as appose to just simply stepping out to the side of the bed. Just make sure to put a scheduler delay for one game tick so that you do the teleport on the next game tick, not on the event itself; I say this because if you do it when the event occurs the player is still technically "sleeping" because the event occurs BEFORE he gets out of bed, not after. If you put the teleport on a 1 tick delay it will occur after the sleep wake event, meaning the player will be out of bed, standing and ready to teleport, but because it occurs 1 game tick later the timing is practically instant to the human eye.

    No idea if any of these suggestions will work, but figured I would provide you with a few alternative methods just in case. Good luck with your project!
    Neodork likes this.
  12. Offline

    Neodork

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I will try this. And check if I can get the player out of bed with it before I teleport them.

    And if it won't work I think this:


    is a quite nice idea. I can work something out with it.


    Edit: The first one work perfectly, thanks! And I can use the second one to make a new type of teleportation, a bedleave related one. +1 to both

    This post has been edited 2 times. It was last edited by Neodork May 15, 2012.
  13. Offline

    Father Of Time

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I am happy to hear you resolved your issue, good luck with the remainder of your project! :D

Share This Page