Solved Question about yaml (config) layout design setup [Req: Close post]

Discussion in 'Plugin Development' started by ti07shadow, Apr 22, 2015.

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


    Alright, ive been wanting to do this particular type of setup and was wondering how its done. Ive seen some other plug'ns do this but not quite sure how to do this. Im more than willing to be just pushed in the right direction on setting up a layout like this. Just not sure where to look to find out how to do this.

    Here's an example of what i'm looking to do in my config. And be able to update and get this information as well. (do note I know how to setup a custom config, just not sure how to do this specifically.

    ----Location: {World: world, X: -1320, Y: 17, Z: 1984, Yaw: -91.50002, Pitch: 12.899996}

    specifically how its setup in the "Location" section
  2. Offline


    Try something along the lines of this; implying you know how to add the location and mytestlocation already.

    plugin.config.put("Location", "{World: " + variableworld + ", X:" + variablex + ", y:" + variabley + ", z:" + variablez + ", Yaw:" + variableyaw + ", Pitch:" + variablepitch + "}")

    you just need to add the variables
  3. Offline


    @RuthlessRage @ti07shadow or use configuration sections like
          X: 2 
          Y: 3
          Z: 1
    It seems simpler to me and Easter as far as avoiding mistypes and errors is concerned.
  4. Offline


  5. Offline


    Assuming some command saves a players location, you can do this
    config.set("Location.myTestLocation", "Location: {World: "+p.getWorld().getName()+", X: "+(int)p.getLocation().getX()+", Y: "+(int)p.getLocation().getY()+", Z: "+(int)p.getLocation().getZ()+", Yaw: "+p.getLocation().getYaw()+", Pitch: "+p.getLocation().getPitch()+"}");
  6. Offline


    @mine-care @1Rogue @Koobaczech he want it to go horizontal so what i said was correct.

    plugin.config.put("Location", "{World: " + variableworld + ", X:" + variablex + ", y:" + variabley + ", z:" + variablez + ", Yaw:" + variableyaw + ", Pitch:" + variablepitch + "}")

    you just need to add the variables
  7. Offline


    You're right, that's the correct way to do it incorrectly.
    Msrules123 likes this.
  8. Offline


    @1Rogue What are you referring to when you says "that's" and what's "it", i recon you learn proper english before taking on java. No need for your comma and you're stating a double negative, you can't do something correctly if the result's incorrect. Before you try to act like a Smart*** behind a computer screen check yourself.
    Last edited: Apr 22, 2015
  9. Offline


  10. Offline


    I see where your username comes from. Anyways, you aren't one to talk about grammar, yours is extremely sloppy. Also, his sentence was grammatically correct.
    ^ That's the best way to do it.
  11. Offline


    Okay then

    It's okay if English is too hard for you. Here's how that sentence works:

    Refers to the method you suggested
    "it" referring to the task that OP wants to do (save a location in YAML)

    Referring to your solution again.

    The entire point of the statement is that you are doing it correctly for a solution which is incorrect.

    Thank god I don't post things without knowing what I'm talking about. Such as "double negative" where there is none. If you want to make responses to my posts as a personal attack on me (rather than posting to help the OP) then that's something you can have fun spending your time doing. I don't really care.
    SuperOriginal and Msrules123 like this.
  12. Offline


    @Msrules123 Never did i say 1Rogue's method was wrong or incorrect. My way is much easier in my preference.

    @1Rogue "i recon" is something you call slang, maybe if you passed High School you would understand what a double negatives. Ounce again here you are trying to be a Smart***, you can't have a solution that's incorrect; you're just contradicting yourself kid. It's sad how other people feel the need to explain what you were trying to say; implying that I'm right you're wrong and they feel sorry. You're retired staff obviously if you were any good help you would still be a moderator, get with the program.
    Last edited: Apr 22, 2015
  13. Offline


    He's referring to you saying my grammar was wrong, when it clearly wasn't. Not my post about the solution.

    So we're now going on trying to play on my age/education. I'll rectify one point now (if you bothered to read my age): I'm not a child.

    As something I said in skype:
    At any rate...
    Maybe if you passed highschool (which I did), you'd realize slang isn't proper english. Additionally, I'd love to see how you define a double negative, as there isn't any. On top of that:

    They're only explaining it for your sake, you're literally the only person not understanding it

    I chose to retire, because I don't want to be a moderator. I'm currently using my time towards paid work, rather than volunteer. The fact you think a person's value is based upon the power they hold is fairly childish on it's own.

    One last thing:

    If you don't even get the concept of "incorrect solution", then I'm not even going to bother replying anymore. Clearly you're either trolling or really need to step back and get a better grasp on why anyone (or myself) should post here: To help people with problems. Not to nitpick grammar.

    At any rate I'm done replying (don't have anymore time atm), thanks for the humor.
    Last edited: Apr 23, 2015
  14. Offline


    Quite frankly, I'm just going to say this. I doubt you are even old enough to be in high school, as you can't correctly form a sentence. These threads are to help people who are having trouble solving a problem, not argue about whose grammar is correct. (Which yours isn't, in case you wanted to know) Also, I wouldn't refer to people as "kids" whether or not they are a retired staff, most people get offended when a younger being is attempting to insult them.
  15. Offline


    @1Rogue Who is "He" grammar can't be wrong it's not the result of anything, your grammar was incorrect. Ounce again what is "it", and "Not my post about the solution" is a fragment sentence. Matter a fact "Not my post about the solution" makes absolutely no sense. Like seriously did you graduate High School, just because you added apostrophes doesn't make you look smart; my Pc does that automatically anyways???

    @Msrules123 I'm not even going to argue this is between me and 1Rogue, don't try to defend him cause ill make both of you look even more stupid. I'm in college and i didn't have to get a GED I've graduated on time. Your grammar is trash just read it aloud and maybe you'll see, don't bother replying; I'm done with this pointless thread full of uneducated bums.
  16. Offline



    "i recon" isn't "slang," it's just spelled incorrectly, nor is "correct way to do it incorrectly" a double negative. It is perfectly valid English, not even close to what a double negative is. You should look up what the phrase "double negative" means before you try to use . Also, that comma in his sentence was indeed necessary, as "you're right" serves as an interjection in that statement. I think you might need to "check yourself" before you wreck yourself.

    Furthermore, your "solution" was significantly sloppier than the one @1Rogue suggested, there is a reason that ConfigurationSerializable is provided. "i recon" you're just salty that he destroyed your post.

    You have no capitalization, and your the first sentence of your most recent post doesn't even make sense. Your spelling is atrocious.

    I honestly think you're just trolling at this point.
    nlthijs48 and Msrules123 like this.
  17. Offline



    Last edited: Apr 22, 2015
    SuperOriginal and Msrules123 like this.
  18. Offline


    You seriously need to find something better to do than argue with a bunch of people on the internet about how you are unable to form a proper sentence.
    Msrules123 likes this.
  19. Offline


    this is genuinely top kek
  20. Offline


    I appreciate it. It doesn't however give me the output I would prefer. I know there's a proper way of doing the "flow" method I showed. As I prefer to use a flow method rather than block method. (unless there's something i'm missing and it can do flow instead of block?)

    I mean I looked at this and thought of it before hand
    That just leads to extra needless coding and the possibility of error. I know there is a proper way of doing this
    Location: {World: world, X:-1320, Y: 17, Z: 1984, Yaw: -91.50002, Pitch: 12.899996}
    as plugins such as world guard use such a method. But it only gives x,y,z. Here's an example of a region in world guard i na config. I would just sift through the code to see how they did it. But of course due to well code everywhere I cant narrow down where they have done this.

    ------type: cuboid
    ------min: {x: -1556.0, y: 6.0, z: 2409.0}
    ------max: {x: -1542.0, y: 48.0, z: 2423.0}
    ------priority: 0
    ------flags: {creeper-explosion: deny, ice-melt: deny, mob-spawning: allow}
    ------owners: {}
    ------members: {}
    Last edited: Apr 23, 2015
  21. Offline


    I'm not sure what you mean by "flow," but if you set that up properly, you'll get output similar to this:

        loc1: Location{ x: ...
                       y: ....
                       z: .....
                       pitch: .....
                       yaw: .....
                       world: ....}
          loc2: ....
    I don't see how that isn't what you're looking for.
  22. Offline


    No, there isn't a "proper" way for that, it's the same thing that was previously suggested: String parsing and building. It's sloppy, and just because worldguard (or some other plugin) does it doesn't make it a good way to do it.

    I don't remember if org.bukkit.util.Vector has a special exception for serialization, but that's what worldguard's max/min use
    Last edited: Apr 23, 2015
  23. Offline


    @ti07shadow Needless coding? If it gets the job done then it's all you need. You don't know another solution and its only like lines of defined variable, like seriously.
  24. Offline

    timtower Administrator Administrator Moderator

    To all, back on topic please.
    If you want to start a flame war about something then please do that somewhere else.
  25. Offline



    There's quite a bit to be said for getting the job done properly, which is what configuration serialization allows you to do. OP is not wrong when he says that what you suggested is very prone to error. So no, "getting the job done" isn't "all you need."


    Vector does implement ConfigurationSerializable, I know Location doesn't, but I believe that's because it maintains a reference to the World that it's in, which complicates things slightly.
  26. Offline


    I know it's ConfigurationSerializable, wasn't sure if Worldguard has a special way of saving it or if it goes under the typical bukkit serialization (e.g. '==' => Class)
  27. Offline


    @mythbusterma The only way you'll get errors is if you define the varriables wrong. My code is simply put all you need is correct variables and you won't get any errors.
  28. Offline



    plugin.config.put("Location", "{World: " + variableworld + ", X:" + varialbex + ", y:" + variabley + ", z:" + variablez + ", Yaw:" + variableyaw + ", Pitch:" + variablepitch + "}")

    This block of code doesn't work, but looks exactly the same as yours. Starting to see why it's a terrible idea not to serialize?
  29. Offline


    I figure that world guard serializes or such in their own way. See this is what it looks like actually in the config
    As well as the "flags" spot. Now I know you cant achieve this with RuthlessRage's method. Due to it not being a string.. Looks like a bunch of sub nodes in a node but in a horizontal list of sorts.

    I know yaml handles lists like
    - item 1
    - item 2
    - item 3

    is there a way to achieve this but like the following? because this effect they have for min, max is also done in flags, owners and members
  30. Offline


    That specific case is YAML object notation, it's equivalent to:

      x: -1550.0
      y: 9.0
      z: 2109.0
    As far as I know bukkit doesn't have any built-in support for this, you'd need to do that parsing yourself.
Thread Status:
Not open for further replies.

Share This Page