How can I read .yml files with bare-bones Java

Discussion in 'Plugin Development' started by MGlolenstine, Jun 26, 2017.

Thread Status:
Not open for further replies.
  1. I know, I know... You're gonna say "This isn't connected to Bukkit in anyway" or something along those lines, but there is something I'm trying to achieve, something which is connected to Bukkit in everyway.

    So I'm trying to read from Bukkit's config, because I need to get balance from it. But the problem is, that I can't use Bukkit API, as I'm not building a Bukkit plugin.

    Well... I tried to use SnakeYML, but as you might know you need to cast the object you get from that into a Map with pre-defined values for Strings. I currently use a Bukkit config, which has a variety of different amounts of configs per key.

    So my config is as following:
    Code:
    players:
      a6804638-dc5e-404d-b050-60bc37e4ce1e:
        name: MGlolenstine
        balance: 7290519
        deposited: 0
        edit: false
      f7e21c90-1308-44a0-b206-30b9570f1d80:
        balance: 1710306
        name: BicySuper
        deposited: 0
        edit: true
    worlds:
      default: world
      warzone: warzone
    ores:
      COAL_ORE:
        percentage: 16
        delay: 1
        drop: 1
        itemdrop: COAL
      IRON_ORE:
        percentage: 14
        delay: 1
        drop: 1
        itemdrop: IRON_INGOT
      LAPIS_ORE:
        percentage: 14
        delay: 1
        drop: 1
        itemdrop: LAPIS
      GLOWING_REDSTONE_ORE:
        percentage: 14
        delay: 1
        drop: 6
        itemdrop: REDSTONE
      GOLD_ORE:
        percentage: 14
        delay: 1
        drop: 1
        itemdrop: GOLD_INGOT
      DIAMOND_ORE:
        percentage: 14
        delay: 1
        drop: 1
        itemdrop: DIAMOND
      EMERALD_ORE:
        percentage: 14
        delay: 1
        drop: 1
        itemdrop: EMERALD
    and all I want to get is players.<uuid>.balance. How can I achieve this?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @MGlolenstine Which plugin is it? Is it yours? If so: why not add an API to it?
     
    MGlolenstine likes this.
  3. Offline

    InstanceofDeath

  4. Offline

    timtower Administrator Administrator Moderator

Thread Status:
Not open for further replies.

Share This Page