Solved Storage of Locations

Discussion in 'Plugin Development' started by TheKomputerKing, Aug 14, 2013.

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


    Hi there,

    I have my code set up so when somebody fires an egg, It creates a web where the egg was fired. I need to have some kind of way to store the webs (I think it's a HashMap I need) and at the end of the game, turn all of the webs in the storage to air.

    Komp :)
  2. then store the locations or blocks in a hashmap, you are correct. Don't know how?
  3. Offline


    mollekake No, sorry I'm not that experienced in Java :p
  4. Offline


    Maybe you should use a List.
    A Hashmap has 2 different entries but I think you just need one. Or do you want to put player and his web together?

    //Creates a List
    List<Location> locs = new ArrayList<Location();
    //Add the location object into the list
    //Creates a HashMap
    HashMap<Player, Location> map = new HashMap<Player, Location>();
    //add player and location to the map
    map.put(player, location)
    That's the code to save locations but I think you will have a web class because you will need that. Then Just replace Location to Web and you can save your web objects in a list.

    PS: The third line in your signature is very bad code.
    p.hasHelpedYou is a boolean that is true.
    The if content will be executed when the condition is true, but the variable is already to. You don't have to check the equality of true to true.
    You don't write if(true == true) doSomething(); You just write if(true) doSomething();
    (You will never write if(true) because you wouldn't need a clause if the happening is everytime the same (the content of the if clause) but this is just an example ;) ).
  5. Offline


    Would you please stop storing the Player object? I guess i will add that to my signature now as i have seen this too often ^.^
  6. Offline


    and I'll fix my signature.

    (P.S I wouldn't do that in my code xD)

    For the locs would I be able to get them all in a for loop? How would I do this?

    I did it anyway thanks though :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 3, 2016
  7. Offline


    locked per OP request.
Thread Status:
Not open for further replies.

Share This Page