I'm starting to hate yaml files... The method that I usually use: PHP: @mkdir($this->getDataFolder());$this->saveDefaultConfig();$this->reloadConfig();$this->config = $this->getConfig()->getAll(); How I can get an array from yaml? And, how I can write it as well? My (useless) method: PHP: # MySQL settingsMySQL: - Host: "127.0.0.1" - User: "user" - Password: "password" - Database: "user_data" How I (try) get it: PHP: $this->config["MySQL"]->Host;# I also tried/** $this-config["MySQL"]["Host"];*/
Code: [23:51:41] [CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerPreLoginEvent' to 'PocketRB vAdara #1': Undefined index: Host on andrew\EventListener [23:51:41] [NOTICE]: ArrayOutOfBoundsException: "Undefined index: Host" (E_NOTICE) in "/PocketRB source/src/andrew/PocketRB" at line 51
I don't know if this will make any difference, but usually if I do that method, the config file will look like this Code: MySQL: Host: "blablabla"
Now I'm getting another error... (This time using multidimensional arrays...) Code: [00:12:54] [CRITICAL]: "Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'PocketRB vAdara #1': Undefined index: y on andrew\EventListener [00:12:54] [NOTICE]: ArrayOutOfBoundsException: "Undefined index: y" (E_NOTICE) in "/PocketRB source/src/andrew/PocketRB" at line 58 Yaml: Code: Positions: RB-1: StartPosition: x: 22 y: 62 z: -61 BeastPosition: x: 29 y: 65 z: -62 LobbyPosition: x: 21 y: 65 z: -70 MiddlePosition: x: 1 y: 72 z: -14 RB-2: StartPosition: x: 22 y: 62 z: -61 BeastPosition: x: 29 y: 65 z: -62 LobbyPosition: x: 21 y: 65 z: -70 MiddlePosition: x: 1 y: 72 z: -14 RB-3: StartPosition: x: 22 y: 62 z: -61 BeastPosition: x: 29 y: 65 z: -62 LobbyPosition: x: 21 y: 65 z: -70 MiddlePosition: x: 1 y: 72 z: -14 RB-4: StartPosition: x: 22 y: 62 z: -61 BeastPosition: x: 29 y: 65 z: -62 LobbyPosition: x: 21 y: 65 z: -70 MiddlePosition: x: 1 y: 72 z: -14 RB-5: StartPosition: x: 22 y: 62 z: -61 BeastPosition: x: 29 y: 65 z: -62 LobbyPosition: x: 21 y: 65 z: -70 MiddlePosition: x: 1 y: 72 z: -14 RB-6: StartPosition: x: 22 y: 62 z: -61 BeastPosition: x: 29 y: 65 z: -62 LobbyPosition: x: 21 y: 65 z: -70 MiddlePosition: x: 1 y: 72 z: -14 RB-7: StartPosition: x: 22 y: 62 z: -61 BeastPosition: x: 29 y: 65 z: -62 LobbyPosition: x: 21 y: 65 z: -70 MiddlePosition: x: 1 y: 72 z: -14 RB-8: StartPosition: x: 22 y: 62 z: -61 BeastPosition: x: 29 y: 65 z: -62 LobbyPosition: x: 21 y: 65 z: -70 MiddlePosition: x: 1 y: 72 z: -14 RB-9: StartPosition: x: 22 y: 62 z: -61 BeastPosition: x: 29 y: 65 z: -62 LobbyPosition: x: 21 y: 65 z: -70 MiddlePosition: x: 1 y: 72 z: -14 RB-10: StartPosition: x: 22 y: 62 z: -61 BeastPosition: x: 29 y: 65 z: -62 LobbyPosition: x: 21 y: 65 z: -70 MiddlePosition: x: 1 y: 72 z: -14 How I call it: PHP: public function getGamePosition($game,$POSITION_TYPE,$pos){ # ex: $this->getGamePosition("RB-1","StartPosition","x"); return $this->config["Positions"][$game][$POSITION_TYPE][$pos]; }
Maybe your config file need to look like this Code: StartPosition: x: "y": z: I don't know why, but it works on my plugin
Not working... Code: [00:31:10] [WARNING]: RuntimeException: "yaml_parse(): parsing error encountered during parsing: did not find expected key (line 31, column 7), context while parsing a block mapping (line 29, column 5)" (E_WARNING) in "/src/pocketmine/utils/Config" at line 148 [00:31:10] [INFO]: Disabling PocketRB vAdara #1 [00:31:10] [INFO]: [PocketRB] PocketRB - Adara #1 disabled Code: Positions: RB-1: StartPosition: x: 22 "y": 62 z: -61 BeastPosition: x: 29 "y": 65 z: -62 LobbyPosition: x: 21 "y": 65 z: -70 MiddlePosition: x: 1 "y": 72 z: -14 RB-2: StartPosition: x: 22 "y": 62 z: -61 BeastPosition: x: 29 "y": 65 z: -62 LobbyPosition: x: 21 "y": 65 z: -70 MiddlePosition: x: 1 "y": 72 z: -14 RB-3: StartPosition: x: 22 "y": 62 z: -61 BeastPosition: x: 29 "y": 65 z: -62 LobbyPosition: x: 21 "y": 65 z: -70 MiddlePosition: x: 1 "y": 72 z: -14 RB-4: StartPosition: x: 22 "y": 62 z: -61 BeastPosition: x: 29 "y": 65 z: -62 LobbyPosition: x: 21 "y": 65 z: -70 MiddlePosition: x: 1 "y": 72 z: -14 RB-5: StartPosition: x: 22 "y": 62 z: -61 BeastPosition: x: 29 "y": 65 z: -62 LobbyPosition: x: 21 "y": 65 z: -70 MiddlePosition: x: 1 "y": 72 z: -14 RB-6: StartPosition: x: 22 "y": 62 z: -61 BeastPosition: x: 29 "y": 65 z: -62 LobbyPosition: x: 21 "y": 65 z: -70 MiddlePosition: x: 1 "y": 72 z: -14 RB-7: StartPosition: x: 22 "y": 62 z: -61 BeastPosition: x: 29 "y": 65 z: -62 LobbyPosition: x: 21 "y": 65 z: -70 MiddlePosition: x: 1 "y": 72 z: -14 RB-8: StartPosition: x: 22 "y": 62 z: -61 BeastPosition: x: 29 "y": 65 z: -62 LobbyPosition: x: 21 "y": 65 z: -70 MiddlePosition: x: 1 "y": 72 z: -14 RB-9: StartPosition: x: 22 "y": 62 z: -61 BeastPosition: x: 29 "y": 65 z: -62 LobbyPosition: x: 21 "y": 65 z: -70 MiddlePosition: x: 1 "y": 72 z: -14 RB-10: StartPosition: x: 22 "y": 62 z: -61 BeastPosition: x: 29 "y": 65 z: -62 LobbyPosition: x: 21 "y": 65 z: -70 MiddlePosition: x: 1 "y": 72 z: -14 ...
Here is a simple workaround for that issue you are having. Simply replace all the x, y, z variables with -. Example: OLD Code: x: 23 y: 22 z: 19 NEW Code: - "23" - "22" - "19" Then, access with 0(x), 1(y), 2(z) as the indexes. The problem should now be fixed. PHP: // your old way# ex: $this->getGamePosition("RB-1","StartPosition","x");// your new way# ex: $this->getGamePosition("RB-1","StartPosition", 0); --- Edit: The same thing for your example of MySQL at the top. Instead of: Code: MySQL: - Host: "127.0.0.1" do Code: MySQL: - "127.0.0.1" for each of the "indexes", and access them in order starting from 0.