Question about YMLs.

Discussion in 'Plugin Development' started by antflga, Oct 3, 2015.

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

    antflga

    Hi all, a while ago I updated my YML tools without checking if they functioned afterwards -- stupid, I know. Anyway, now when I try to get some nodes that previously looked like.
    Code:
    plugin:
      locations:
        '1':
        - 141
        - 64
        - 132
        '2':
        - 117
        - 64
        - 145
    
    they now look like

    Code:
    plugin:
      locations:
        '1': &id001
        - 141
        - 64
        - 132
        '2': &id002
        - 117
        - 64
        - 145
    
    and when I try to grab the results and place them elsewhere

    Code:
      areas:
        lol:
          locations:
          - '1'
          - '2'
          coordinates:
            setOne: *id001
            setTwo: *id002
    
    All it returns is what looks like a pointer to the original , how do I avoid this?
     
  2. Offline

    dlange

    @antflga What are you trying to store/get & what for? If you are trying to store locations to use later, i store them as a string (with this format "x:y:z: pitch:yaw") /* dont put a space between ':' and 'p' it just kept changing it to a smiley face */ and in a list like this:
    Code:
    locations:
    - x:y:z:pitch:yaw
    - x:y:z:pitch:yaw
    - x:y:z:pitch:yaw
    - x:y:z:pitch:yaw
    - x:y:z:pitch:yaw
    There are your 5 locations, then use .split(":")[int] to get each one.
    Example:
    Code:
    List<String> locs = (List<String>) getConfig().getList("locations");
    
    for (String sLoc : locs) {
        Location loc = new Location(Bukkit.getWorlds().get(0), Double.valueOf(sLoc.split(":")[0]), Double.valueOf(sLoc.split(":")[1]), Double.valueOf(sLoc.split(":")[2]), Float.valueOf(sLoc.split(":")[3]), Float.valueOf(sLoc.split(":")4]),
    }

    Note: You could always add a section for world name, i just made it get the first world in the worlds list. There may also be errors in my code, but you get the general idea (i just whipped it up in Chrome).
     
  3. Offline

    antflga

    I use IntegerLists because they were easier to fetch, and work natively for what I need. What I'm trying to figure out is why it makes these 'pointers'.
     
Thread Status:
Not open for further replies.

Share This Page