Arrow Cycle

Discussion in 'Plugin Development' started by Areoace, Oct 3, 2013.

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

    Areoace

    What I am trying to do:

    Left click with bow: "Fire arrows"

    Left click again with bow: "Slow Arrows"

    Left click: "Fire arrows"

    ext ext. I've tried many ways to do this but I've been feeling really sick and as a dev I need to get this done quickly by tomorrow :S How would I do this using HashMaps???
     
  2. Offline

    thegarfish

    You want left click to shoot flame arrows and right click to shoot normal arrows?
     
  3. Offline

    Areoace

    No, I want to do: Left click to enter fire mode, whenever their arrows hit someone it burns them.

    Left click again to enter slow mode whenever their arrows hit someone the target is slowed then it goes back to fire and then back to slow.
     
  4. Offline

    MrSnare

    Code:java
    1. HashMap<Player, String> playerState
    2.  
    3. //on left click
    4. if(playerState.get(player) == "fire"){
    5. playerState.put(player, "slow");
    6. }else{
    7. playerState.put(player, "fire");
    8. }
    9.  
    10. //on arrow hit
    11.  
    12. if(the arrow was shot by a player){
    13. Player shooter = //get the shooter
    14.  
    15. if(playerState.get(shooter) == "fire"){
    16. //set the person who was hit on fire
    17. }else if(playerState.get(shooter) == "slow")){
    18. //add slowness to the person who was hit
    19. }
    20.  
    21. }


    This is not real java code. fix it yourself
     
  5. my tip: change the display name of the bow when you click in the air, is rather easy. then when a bow hits, iterate through the shooters inventory and chech what the bow is named.
     
    MrSnare likes this.
  6. Offline

    Areoace

    Done that but I think I messed my method up. Thanks for the suggestion tho :p
     
  7. Offline

    MrSnare

    How does the rest of it work?
     
  8. Offline

    Areoace

    MrSnare sorry to be a pain but I've still got a migraine, would you be able to explain how to use the code you gave me before. My previous methods were setting the lore > check the lore then set it again, but the issue im having is putting them back to the start.
     
  9. Offline

    MrSnare

    Do you know how to use HashMaps? If not, go learn how to use it. This code is pretty simple. I even told you what events to put the lines in.
     
  10. Offline

    Areoace

    MrSnare, I'm using your playerstate thing and when I click it gives me a NullPointer
     
  11. Offline

    MrSnare

    when you create the class do: playerState = new HashMap<Player, String>();

    you have to instantiate it.
     
Thread Status:
Not open for further replies.

Share This Page