Get If a player shot a bow

Discussion in 'Plugin Development' started by Forseth11, Apr 8, 2013.

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

    Forseth11

    What is the event and how do I use it to get if a player shot a bow?
     
  2. Offline

    Tirelessly

    DeveloperUseDoxygenEvent

    jd.bukkit.org/doxygen/
     
    Compressions likes this.
  3. Offline

    Forseth11

    Tirelessly What is that? Is there just an event like (CreatureSpawnEvent event) but is if a player shoots an arrow?
     
  4. Offline

    Tirelessly

    Yes. You can find it in a quick search on jd.bukkit.org/doxygen/. We're not here to write things for you.
     
  5. Offline

    Forseth11

    Tirelessly I looked through some of it and found this: org.bukkit.event.player.PlayerInteractEvent.getAction()
    Would this possibly work?
     
  6. Offline

    Tirelessly

    EntityShootBowEvent.
     
  7. Offline

    Forseth11

    Tirelessly Thank you! I was about to use PlayerInteractEvent and use get item in hand and left or right click air or block.
     
  8. Offline

    Compressions

    Forseth11 Are you kidding, or are you truly that stupid? :eek:
     
    microgeek likes this.
  9. Offline

    Forseth11

    Compressions Hey I didn't see that event. Plus I'm rushing to find something; I have to go to bed soon.
     
  10. Offline

    Compressions

  11. Offline

    Forseth11

    Compressions One other thing. When I use this to get the player Player p = (Player)event.getEntity(); the plugin fails to load.
    I probably did something extremely stupid.
     
  12. Offline

    Compressions

    Forseth11 Your response dumbfounded me.
     
    microgeek likes this.
  13. Offline

    Forseth11

    Compressions I don't have much time until bed, so I prefer not having to search all over the internet.
     
  14. Offline

    Compressions

    Forseth11
    Code:java
    1. if(event.getEntity instanceof Player)
     
  15. Offline

    Forseth11

    Compressions Oh I remembering seeing that on another form. Thanks. Oh, are you really 13yrs old?
     
  16. Offline

    ohtwo

    Compressions C'mon, no need to call people stupid on these forums. I've seen a reply from you that was very very wrong from a topic in Bukkit Help and instead of putting you down, plenty of people simply explained what was wrong. Honestly if you have nothing to contribute, or you don't feel like the topic warrants a response, just don't respond...
     
  17. Offline

    Forseth11

    ohtwo Compressions am I doing this right because it is not working:
    PHP:
    public void playerShootBow(EntityShootBowEvent event){
            if(
    event.getEntity() instanceof Player){
            
    Player p = (Player)event.getEntity();
            
    p.sendMessage("Working");
            }
            return;
        }
     
  18. Offline

    Compressions

    ohtwo I was simply joking. He didn't notice Tirelessly 's joke. I'm not serious when I'm calling him stupid; I'm just simply waiting for him to catch on with the joke.
    Forseth11 Yes I am. Since you have that if statement I gave you, don't define the Player as the entity. Then do event.getEntity.sendMessage("Working"); Also, don't forget @EventHandler.
     
  19. Offline

    ohtwo

    Yes, but there's no real reason to "return" if that's all that's going to be in your code. Be sure to add @EventHandler and register the event in the main class.
     
  20. Offline

    microgeek

    I like you.
     
    Compressions likes this.
  21. Offline

    Forseth11

    Compressions I assume you have been taught Java. I know c++ and basic JavaScript and I started Java like 10 days ago. Funny, I just turned 14 and I have a 13 yr old telling me what to do. (If you ever want to learn c++ or Java Script I could help you some.)

    ohtwo I have an eventhandler and I will need the return later on.

    Compressions event.getEntity.sendMessage("Working"); doesn't work.
    I have to get off my computer for bed. (Might be able to use my phone, but can't test anything.)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  22. Offline

    Compressions

    Forseth11 Did some test code, and got it working. Here you go. By the way, this code is assuming you are listening for this event in your main class. If you didn't and need help registering the event, let me know.
    Code:java
    1. @EventHandler
    2. public void onEntityBowShoot(EntityShootBowEvent e) {
    3. LivingEntity shooter = e.getEntity();
    4. if(shooter instanceof Player) {
    5. Player p = (Player) shooter;
    6. p.sendMessage("Working");
    7. }
    8. }
    9.  
    10. public void onEnable() {
    11. getServer().getPluginManager().registerEvents(this, this);
    12. }
    13.  
    14. public void onDisable() {
    15.  
    16. }
    17.  
    18. }
     
  23. Offline

    Forseth11

    Compressions Nvm thank you anyways. I looked over my code and realized I made a horable mistake. Thanks. Btw this is like my second time making a listener. One question: do you take a class to learn java or do you teach yourself?
     
  24. Offline

    Compressions

    Forseth11 As of now, I've just taught myself. Although, I do plan to attend some courses for it.
     
  25. Offline

    Forseth11

    Compressions I did the same for c++. How long have you been using java?
     
  26. Offline

    Compressions

    Forseth11 A few months of true coding now.
     
  27. Offline

    Forseth11

  28. Offline

    Compressions

    Forseth11 What are you getting at with this? I'm not here to judge your coding skills, so don't feel obligated to be defensive. It's funny though, I need to update my definition of true coding. You say 10 days of true coding, but you've made more plugins than me. :p
     
  29. Offline

    Forseth11

    Compressions sorry I wasn't trying to be defensive. I just thought it was cool that someone else is coding at this age.
    I made all those SIMPLE plugins in ten days. Plus the fourth one was an idea witch I found out it is useless because there are others like it already out there. (Didn't start on the fourth one)
     
  30. Offline

    Compressions

    Forseth11 No worries. I am also interested in who else codes Bukkit plugins for a hobby at this age. I'm interested in JavaScript and C++ but know nothing about them and their uses. PM me? :)
     
Thread Status:
Not open for further replies.

Share This Page