Solved Elytra events?

Discussion in 'Spigot Plugin Development' started by Azmidium, Mar 10, 2016.

  1. I was searching around the Spigot API for something on the Elytra, I had no luck. I saw infinite flight elytra plugins, just wondering how they know if they person:

    a) Starts flying with the elytra
    b) Is in flight with elytra
    c) Ending flight with elytra
    d) Ways to stop midflight with elytra

    Thanks for helping in advance! :)
  2. I use PlayerMoveEvent. Cast Player to EntityPlayer, then player.cB() is true if flying with the elytra.
    You can use that to detect when they start and stop. I put all flying players into a list.

    Not sure about forcing them to stop flying though.
    • Useful Useful x 4
  3. I am still on the hunt for that one, but thanks so much!
  4. Make your own event
    • Agree Agree x 1
  5. in order to force a player to stop using the elytra, you can do as follows: (sorry for the spoonfeeding, I don't know any other way to explain it)

    Code (Text):
    public void onMove(PlayerMoveEvent event) {
           EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle();
           player.setFlag(7, false);
    the DataWatcher's flag 7 keeps track of whether an Entity is in-flight with an elytra
    • Like Like x 3
    • Agree Agree x 1
    • Informative Informative x 1
    • Useful Useful x 1
  6. Hex

    IRC Staff

    • Like Like x 3
    • Winner Winner x 1
  7. Someone just released an API to handle exactly what you want. It's on the resources page.
  8. yes, that was me. I wrote it up in a few minutes after I realized there was no official API. if you find anything missing from it, let me know! thanks
  9. I will be checking it out! ;)

    Thanks in advance!
  10. Hex

    IRC Staff

    Something to note is that when we start making plugins to handle things that an API should do, we're both supporting API incompleteness and likely reducing the popular need to add this API. That's why I'd personally suggest waiting for an official API to do this, but that's just my opinion.
    • Agree Agree x 3
  11. All I am doing is checking it out since it is open source, and learning for myself. I won't be using the actual API. I don't like to use APIs decides obviously the Spigot API. :3
    • Like Like x 1