Solved Is there a way to check if a player is leaving an entity other than a vehicle?

Discussion in 'Plugin Development' started by Tiliondc, Jan 4, 2015.

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

    Tiliondc

    Hi, Im trying to check if a player is ejecting from an entity that is an arrow. But the VehicleExitEvent doesn't check for arrows. Is there any way around this? I also tried making a seperate thread that checks if the player is still a passenger on the arrow but that didn't work for some reason.
     
  2. Offline

    gogobebe2

    How can they leave an arrow?
     
    nverdier likes this.
  3. Offline

    nverdier

    @Tiliondc I'm guessing you mean if they are hit off by an arrow?
     
  4. Offline

    sethrem

    Spigot.
     
    ChipDev likes this.
  5. Offline

    nverdier

    ?

    @gogobebe2 @nverdier
    I'm guessing he's setting the passenger of an arrow the player. Check if the vehicle is an arrow using something like
    if (event.getVehicle instanceof Arrow) {

    @Jaaakee224 Well an arrow isn't a vehicle...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 17, 2020
  6. Offline

    SuperOriginal

  7. Offline

    nverdier

  8. Offline

    sethrem

    The spigot api has events such has exiting an entity vehicle or entering one, and bukkit doesn't have these events.
     
    ChipDev and gogobebe2 like this.
  9. Offline

    Konato_K

    As far I know, there is no way to do this with bukkit/craftbukkit

    However, other server softwares *cough* spigot *cough* include a special event for players unriding any entity
     
  10. Offline

    Tiliondc

    Too bad there isn't a way for craftbukkit. Then I just have to find another way to solve it
     
  11. Offline

    xMakerx

    Spigot is a fork of Bukkit, so you'll get everything here plus more.
     
  12. Offline

    bennie3211

    I dunno if it will work, but sneak event, check if its riding an entity and if the entity is an arrow?
     
  13. Offline

    ChipDev

    You cannot do that without schedulers, or PlayerMoveEvent <--- Resource intensive.
    Sneak event will call after you leave the arrow/will not call (I think correct me on this because you could create an entity with metadata), so you would have to create these metadata crap and stuff.
    I would just use Spigot . they have an actual entity leave event, which would work more!
    *Also, with spigot, call the player.spigot() method and say 'collidesWithEntities(false)' because you would hit the arrow and fall off unexpectedly without sneaking.
    They could be riding an arrow and hit 'Shift' or whatever their sneak key is (Im a bow/parkour guy, mine is 'S', Because I taught myself typing and I type with 2 fingers :p Inefficient 70 wpm!
     
  14. How the hell do you walk backwards? 0.o
     
  15. Offline

    ChipDev

    B.
    Forward: F
    Left: R
    Right : L <-- ok, that should be left, but its on the right :(
    So everything starts with what it should except tab-lift stuff 'Q'
    ^ Getting of point :p
     
  16. Offline

    Tiliondc

    The reason I don't want to make it spigot only compatible is because I don't want people who wants to use my plugin to have to use spigot. It should be friendly for those who wants to use craftbukkit too.

    I solved my problem in another way instead.
     
    AdamQpzm likes this.
  17. @Tiliondc If you wouldn't mind, could you say how you solved it? It might be useful to other users who stumble upon this thread when looking into the same thing.
     
  18. Offline

    Tiliondc

    @AdamQpzm Yes i was considering doing that but since i didn't explain full situation I didn't think you wanted to know the solution.

    What I wanted to do was to create an arrow that I could ride.
    I made a new ItemStack with the custom arrow. Checked if the custom arrow was launched. if the arrow was custom then I spawned a new arrow with the properties of the entityshootbow projectile and cancelled the event. The reason I did this was because If you use the existing entity, the flying will be really laggy.
    I also set the player to spectator mode, cause if the player is in survival mode the player will be hit by the arrow midair.
    But I am considering changing it to creative mode and just cancel any inventory interaction, cause then I open up the possibility of the playing shooting a new arrow midair. I also made a hashmap that saves the flying arrow id and the playeruuid. Then I have a projectileHitEvent which i check if the arrowId of the projectile exists in the hashmap. If so the player will be teleported to where the arrow landed and the player will be set back to the players original gamemode. This was the easy server friendly solution.
    Another way to do it is to check if the arrow is more than 2 blocks away from the player while the arrow is in the air, if so the player will be set as a passanger to the arrow again. This way is probably a little more resource heavy, but the upside is that the player actually wont be able to climb off the arrow.

    Was this clear enough, or do you want me to describe my solution in more depth?
     
    bennie3211 and gogobebe2 like this.
Thread Status:
Not open for further replies.

Share This Page