Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Getting YAML Data

Comments in 'Plugin Development' started by ImagicalGamer, Jun 3, 2016.

  1. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    I know how to get data from a YAML file and set it etc, but how can I get it without it being cap sensitive? If I want to get ImagicalGamer from data.yml but I do /find imagicalgamer it returns null. (/find is a command for a plug I'm working on).
  2. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    have you tried strtolower when getting the data from yml
  3. TheDragonRing
    Offline

    TheDragonRing New Member

    Joined:
    Mar 27, 2016
    Posts:
    22
    Minecraft User:
    TheDragonRing
    But doesn't that mean that although /find imagicalgamer would work /find ImagicalGamer wouldn't???
  4. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    @amiremad Thanks! I didn't think about using strtolower xD, I used it when setting the data to the yaml and when getting it. Works now!
    amiremad likes this.
  5. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Then just use strtolower on the command argument.
    PHP:
    if(strtolower($yamlData) == strtolower($args[0]))
    applqpak and TheDragonRing like this.
  6. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    And if $yamlData is not a string?

    @ImagicalGamer you can try these methods:

    1. array_change_key_case
    PHP:
    $simplfiedYamlData array_change_key_case($yamlDataCASE_LOWER);
    $exists = isset($simplifiedYamlData[strtolower($yourUserInput)]);
    2. If you are using the Config class, use this method:
    PHP:
    assert($config instanceof Config);

    $config->exists($yourUserInputTRUE);
  7. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    If $yamlData is not a string, then he didn't understand the code. Actually, not really our problem..
    Hotshot_9930 likes this.
  8. ImagicalGamer
    Offline

    ImagicalGamer Active Member

    Joined:
    Feb 25, 2016
    Posts:
    141
    Minecraft User:
    ImagicalGamer
    I used strtolower on the command and everything works now.

Share This Page

Advertisement