Spectating (POV) prevent player s from leaving via Esc key

Discussion in 'Spigot Plugin Development' started by NoahNok, Jun 15, 2018.

  1. So, like in Spectator mode you can click on a player to see their POV.

    However , I would like to do this without the player having to go in to spectator. Im doing this for after a player dies in my gamemode.

    How would I go about doing this? I understand its probably going to use NMS. Does protocolLib have something for this?

    Thanks!
     
  2. Yes, I noticed just after I posted it. I didnt realise Spigot had something built in.

    For anyone else: you MUST make sure the player is in spectator mode first otherwise you will get an error.

    thanks for the hekp anyway @BillyGalbreath
     
  3. For my use, packets seems unnecessary. Why do it with packets when I can do it with the API directly. And putting them into Spectator in a one liner so.
     
  4. Yeah definitely use the API if it fits your needs, just giving you this option too since you said that the player shouldn't have to go into spectator mode.
     
    • Agree Agree x 1
  5. Ok, I have it working. But I need to make it so players cannot quit it via the Esc (Escape) key. How would I go about doing this? Is there a SpectateEvent or would I need to listen for a packet?
     
  6. // offtopic

    Quick question, I have a similar issue to the OP, does this method support 1.8 or only the latest 1.12?
     
  7. Unless there's some sort of event (Use EventDebug to determine this), you could just repeatedly set the spectating target.
     
  8. Why not use 1.12. Pretty sure 1.8 isn’t supported on the forums anymore. Just out of question, do you use 1.8 because you don’t like 1.9 (If so then get over it)

    And I don’t believe 1.8 has this method (It might though)
     
    • Optimistic Optimistic x 1
  9. How do I use Event Debug? I’ve never heard of it. Is it a server setting or something I do in my plugin?
     
  10. No, it's because I want to implement it into one of my plugins but it needs to support 1.8 and up to 1.12. I just checked and unfortunately, it is not available. I guess the only option at this point would be NMS. Thanks for helping out anyways :p