HashMaps, Lists, Strings, and Locations: any help?

Discussion in 'Plugin Development' started by WampyCakes, Dec 7, 2014.

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

    WampyCakes

    So I am working on a plugin to have a HashMap as follows:
    Code:
    HashMap<Location, Player> c_m_hm = new HashMap<Location, Player>();
    When I try to use lists with it I can't figure out how to convert it. So basically I want to know if there is a way to convert a Location to a String, and a Player to a String.
    And help is appriciated!
    ~Wampy

    EDIT: @timtower This thread is no longer needed!
     
    Last edited: Dec 10, 2014
  2. Offline

    mine-care

    Player to a string, hmm use player's UUID toString(); value.
    And about location, I made a serialisable location in the past but can't access it from phone... Anyway, if you wana save it as a string use : as seperator and do it like:
    X:y:z:yaw:pitch
    And decode it to location this way,
    And just to point it out, make sure you handle player objects correctly in lists maps ect because they tend to cause ram leaking
     
  3. Offline

    WampyCakes

    mine-care If you could help me out on using UUIDs and putting the X, Y, and Z cords in a string that would be amazing! I kinda get what you mean up there ^. But I am not completely sure how to do it.
     
  4. Offline

    Creeoer

    WampyCakes
    Just get the UUID and use .toString() method. I believe you could get the x values of the location and use the toString method on that as well..
    EDIT: Use the String.valueOf(double) for that actually.
     
  5. Offline

    WampyCakes

    Okay, I figured out how to use toString() and it worked. But I need to now figure out how to change Strings back into Locations, and Players. Any help?
     
  6. Offline

    mythbusterma

    WampyCakes

    Why do they have to be Strings? Storing them as UUIDs and Locations isn't detrimental in any way shape or form.
     
  7. Offline

    WampyCakes

    mythbusterma It's the way I am using the Lists, HashMaps, and config.
     
  8. Offline

    mythbusterma

    WampyCakes

    That's not a justification, that's an excuse. Are you asking how to serialize them?
     
    mine-care likes this.
  9. Offline

    WampyCakes

    mythbusterma I just need to know how to convert the Location and Player STRING Back to a LOCATION and PLAYER.
     
  10. Offline

    mythbusterma

  11. Offline

    WampyCakes

    I'll try it. Thank you.
     
Thread Status:
Not open for further replies.

Share This Page