Which type of event to listen to.

Discussion in 'Plugin Development' started by Ytry, Jul 24, 2012.

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

    Ytry

    Recently I was making a plugin that disables players from spawning in their beds, while making this I ran into the problem of which event to listen for. I ran into this problem because if I listened to PlayerRespawnEvent that only updates after a player respawns. The way I did this was make it so if they were going to bed spawn set their bed spawn to spawn. Since PlayerRespawnEvent did not update often enough I was forced to use player move event which can get very taxing on a server if it is setting like 100 players spawn area every time they move. Anyone have any suggestions on how to better do this?
     
  2. Offline

    nisovin

    I'm not sure what you're saying is wrong with PlayerRespawnEvent, as it should work fine. What do you mean by it doesn't update often enough? It will fire every time the player respawns, which is exactly what you want.
     
  3. Offline

    lololmaker

    You could check if they respawn in beds and move them to location accordingly.

    Also about PlayerMoveEvent, every even is fired anyway. If you listen on it or not. If they move their mouse, the event fires.
     
  4. Offline

    Ytry

    That does not work for me because if I set their bed spawn location to the actual spawn every time they respawn, they will bed spawn once do to the fact that it did not get changed until after they spawned. So I needed an event that fires more often than that.
     
  5. Offline

    evilmidget38

    Change both their bedspawn location and the actual respawn location.
     
  6. Offline

    Ytry

    Even if I did that it would only change after they respawn, so again they would bedspawn once. Would they not?
     
  7. Offline

    nisovin

    The PlayerRespawnEvent has a setRespawnLocation() method, use that to set where they respawn. You don't have to set their bed spawn location at all if you don't want to.
     
  8. Offline

    pzxc

    Why not do it on the PlayerDeathEvent? Then it would change their spawn position right BEFORE they click the respawn button.
     
  9. Offline

    Ytry

    I didn't think about that, thanks. hopefully that works a little better.
     
Thread Status:
Not open for further replies.

Share This Page