Assuming you've decided you don't want to use the simpler config defaults with pocketmine, you can do it using just PHP. You don't need PM to create/write in files. This link is a good resource on creating and writing to files. If you wanted to do it involving Pocketmine API methods, check out JackNoordhuis' Config tutorial. The Config class supports multiple file types, so you can use txt instead of YAML.
Code: $myfile = fopen("$filename.txt", "w") or die("File not found"); fwrite($myfile, $txt); fclose($myfile);
Assuming you are in your plugin's main file, you can use $this->getDataFolder() to return the resource folder for your plugin, I believe.
PHP: $myfile = fopen(MainClass::getInstance()->getDataFolder() . "test.txt", "w") or die("Unable to open file!");$txt = "hi this test";fwrite($myfile, $txt);fclose($myfile);
Any error or output to the console? Have you tried a simple echo statement in the same block to see if the code is being run at all?
PHP: in commandsPreproccessevent file_put_contents($plugin->getDataFolder()."logger.txt",$event->getMessage()."\n"); it doesnt write new lines
There are different modes in fopen in php. Code: fopen("file.txt", "w+"); would be the best option todo in your case. if you want it to write at the top of the text file or if you want it to erase text file and create a new one Code: unlink('file.txt'); the w+ mode will create a new file every time
w: write only, * w+: read/write, * fopen with w letter denotes that text is appended to the end of the file, while w+ deletes the content of the file and starts writing new content into the file. I was assuming that he would do something extreme with his code that he would require w+ and it will create the same output, even though it will take longer (in super small time) to generate