Get if arrow hits a creative mode player

Discussion in 'Plugin Development' started by libraryaddict, Sep 14, 2012.

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


    ProjectileHitEvent offers just one thing for any projectile interacting with and hitting a block and player.

    Nice and helpful 0.o

    So I'm trying to get a way to know when someone in creative has been hit by an arrow.

    This is practically impossible.
    It does not offer something like distance = 0.1.
    Infact its sometimes 3.5!

    If someone has a nifty way to somehow find out if it had hit a creative mode player.
    I would be grateful.
  2. Offline


    Run a check to see if event.getEntity() is instanceof a player. Then cast it to player. Then check if the player is in creative, if so do whatever you need. Simple as that!
  3. Offline


    One problem with that logic.
    Why does event.getEntity() return a projectile ^^
  4. Offline


    Then it's returning the arrow....
  5. Offline


    What Im getting at is thats its always going to return the projectile.
    You will never receive the player.
  6. Offline


    Or you can add a metadata to the arrow that says it was shot by a player in creative.

    I haven’t used metadata so much so I can't comment much, but it should be relatively easy.
  7. Offline


    Maybe tou could instead of ProjectileHitEvent use EntityDamageByEntityEvent.It would be something like this:
        public void onDamage(EntityDamageByEntityEvent e){
            if (e.getDamager() instanceof Arrow && e.getEntity() instanceof Player){
                Player player = (Player)e.getEntity();
                if (player.getGameMode() == GameMode.CREATIVE){
  8. Offline


    Creative mode does not take damage
  9. Offline


    I also need help with this same problem
  10. I dont think you can incept that, because the array is actually `bounced` away, so there is none damage event called, so the array doesn´t break
  11. Offline


    Do this:

    Everytime someones in a GameMode or types the 'GameMode Command', get if they are in Creative and put them in a HashMap. Or you can check if they are in GameMode by checking though the: PlayerMoveEvent. Then once you have put them player that is in GameMode Creative. Then you call the event if the player is damaged in GameMode. Only thing I know is you might wanna ask the Bukkit Creators. About all I offer.

    I know I have done it. But I forgot a long time ago :(
  12. Offline


    > October 3rd, 2012

    Also, what you said doesn't really make any sense.
  13. Offline


    If you think logically then you would understand. You obviously didn't get the point, did you?
  14. Offline


    mrgreen33gamer Combined with grammar mistakes, it's pretty difficult to understand. Also you could just check if they are in gamemode through player.getGameMode() in the DamageEvent.

    Also no need to dig up a 2 year old thread.
Thread Status:
Not open for further replies.

Share This Page