Solved Need Help with YML 2

Discussion in 'Spigot Plugin Development' started by MrGamingLion66, Apr 29, 2017.

  1. Hey everyone, I'm having problems with my yml file. I'm trying to put in spawn locations, 12 of them, into a config but I it stops the yml from being loaded.

    Yml data:
    Code (Text):
    Spawn-Location 1: 20.5, 131, -59.5, 0, 0
    Spawn-Location 2: -59.5, 131, 20.5, -90, 0
    Error in console:
    Caused by: org.yaml.snakeyaml.scanner.ScannerException: mapping values are not allowed here in 'string', line 9, column 59: ... 31, 20.5, -90, 0Spawn-Location 3: 0
     
  2. You are mapping the coords, you probably want to edit that though.
    Make the config like:
    Code (Text):
    Spawn:
       LOC1:
           X:
           Y:
           Z:
           Pitch:
           Yaw:
        LOC2:
           ... and do on
     
    • Agree Agree x 1
    • Optimistic Optimistic x 1
  3. WAS

    WAS

    YAML thinks they are paths, when you are defining a string.

    Code (YAML):

    Spawn-Location1
    : '20.5, 131, -59.5, 0, 0'
    Spawn-Location2
    : '-59.5, 131, 20.5, -90, 0'
    Additionally as stated above it might be better to break up the info.
     
  4. @NormaalBart @WAS
    Okay I tried this:
    Code (Text):
    Spawn:
      Loc-1:
        X: 20.5
        Y: 131
        Z: -59.5
      Yaw: 0
        Pitch: 0
        Loc-2:
        X: -59.5
        Y: 131
        Z: 20.5
        Yaw: -90
        Pitch: 0
      Loc-3:
        X: -59.5
        Y: 131
        Z: -59.5
        Yaw: -45
        Pitch: 0
      Loc-4:
        X: -19.5
        Y: 131
        Z: 60.5
        Yaw: -180
        Pitch: 0
      Loc-5:
        X: 60.5
        Y: 131
        Z: -19.5
        Yaw: 90
        Pitch: 0
      Loc-6:
        X: 60.5
        Y: 131
        Z: 60.5
        Yaw: 135
        Pitch: 0
      Loc-7:
        X: 60.5
        Y: 131
        Z: 20.5
        Yaw: 90
        Pitch: 0
      Loc-8:
        X: -59.5
        Y: 131
        Z: -19.5
        Yaw: -90
        Pitch: 0
      Loc-9:
        X: 20.5
        Y: 131
        Z: 60.5
        Yaw: -180
        Pitch: 0
      Loc-10:
        X: -19.5
        Y: 131
        Z: -59.5
        Yaw: 0
        Pitch: 0
      Loc-11:
        X: 60.5
        Y: 131
        Z: -59.5
        Yaw: 45
        Pitch: 0
      Loc-12:
        X: -59.5
        Y: 131
        Z: 60.5
        Yaw: -135
        Pitch: 0
    But it still errors out:
    Caused by: org.yaml.snakeyaml.scanner.ScannerException: mapping values are not allowed here in 'string', line 301, column 10: Pitch: 0

    Also I did it the other way with chest locations and that never errors out. Its only the spawn locations.
     
  5. WAS

    WAS

    Doesn't look formatted correctly as per YAML standards. Look at a YAML Syntax Documentation.
     
  6. I think the probleem is LOC-1 replace that with LOC1
     
    • Like Like x 1
    • Optimistic Optimistic x 1
  7. Remember that YamlConfiguration is a wrapper for SnakeYAML. Odds are OP is already using it.
     
    • Agree Agree x 2
  8. @WAS @megamichiel @NormaalBart @Sweepyoface
    Okay I solved that error but now part of the yml is returning null.

    This is the code for getting the value:
    Code (Text):
    public World getWorld()
    {
        String s = arenaConfiguration.getString("World-Name");
        return Bukkit.getWorld(s);
    }
    Here is the line in the YML
    World-Name: RomanEmpire
     
  9. Most likely because the world is null. Try to debug it

    Edit
    The arenaConfiguration can also be null, try that also
     
  10. @NormaalBart
    Yes the world is returning null. I just can't figure out how to figure that out.

    Edit: Never mind another part of the config was causing arenaConfiguration to be null. Thanks for the help!
     
    #11 MrGamingLion66, May 2, 2017
    Last edited: May 2, 2017