I'm working on a plugin that would involve players adding lines to the config file. However, I'm wondering how this would be possible. Code at the moment: PHP: class cmdr implements Plugin{ private $api; public function __construct(ServerAPI $api, $server = false){ $this->api = $api; } public function init(){ $this->path = $this->api->plugin->createConfig($this, array( "cmd1" => $cmd[0], "cmd2" => $cmd[1], "cmd3" => $cmd[2], )); $this->config = $this->api->plugin->readYAML($this->path."config.yml"); $this->config["cmd1"] = $cmd[0]; $this->config["cmd2"] = $cmd[1]; $this->config["cmd3"] = $cmd[2]; $this->api->plugin->writeYAML($this->path."config.yml", $this->config); foreach($this->config as $read => $run){ $this->api->console->run($run); } } public function __destruct(){ }}
It's not only denied because you bugged staff about approving it, your "framework" is just bad. If you have a string with a ^ it won't work anymore, and storing objects is also not possible. If you don't like don't like yaml the you could use json or a database.
I don't know where you're getting your information about ^ in strings, but last time I checked, you just couldn't put ' or " (depending on which one the string is enclosed in).
You implode array's with the character ^ so if you would use ^ in a string then when you read the file it will be split wrong
I made this plugin for LegionPE, and I am releasing a very small part of it (really small, Lambo, don't blame me): PHP: define("MINKILLCOUNT_SAVE_SPLITER","::::"); PHP: public function save(){ $c=0; foreach($this->playersData as $ign=>$data){ file_put_contents($this->playerStreams[$ign], implode(MINKILLCOUNT_SAVE_SPLITER,$data)); $c++; } $i=0; foreach ($this->independentSave as $ign => $data) { file_put_contents($this->playerStreams[$ign], implode(MINKILLCOUNT_SAVE_SPLITER,$data)); $i++; } $this->independentSave=array(); console(FORMAT_AQUA."[INFO] Saved $c online player database files and $i just-went-offline player database files."); } PHP: $contents=file_get_cotents($this->playerStreams[$player->username]);//input the old file (if exists) $data=explode(MINKILLCOUNT_SAVE_SPLITER,$contents); First it is me who wrote this code, second this is just not even 10% inside the code, so you see. I use constants (not too short to be generic, not too long to lag the server, so I used four colons) to split the data so that it is easier to split the data since each datum is a number and a number doesn't start/end with a colon. And even if I somehow later when updating the code find out that I have to save a string with a potential "::::", I can easily just change the four colons to something else, like "````".
In fact, plugins with large databases and a lot of I/O like SimpleAuth should use this too because in its databases the YAML files are simple arrays (not nested): Example: Code: --- registerdate: 1389597556 logindate: 1389670416 lastip: 192.168.0.101 hash: > ********HIDDEN FOR SECURITY******** The first two are dec long data as timestamps, the second is an IP address that is always four numbers with three dots inside, and the hash code is only a hex long datum. So if SimpleAuth does not put the prefixes (regiserdate, logindate, lastip, hash) the efficiency will be faster as PHP does not need to search for the Config class then the Spyc class to toString-ize the array. If it just saves like this: Code: 1389597556~~1389670416~~192.168.0.101~~1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef It will be faster. The reason why I put two ~s instead of one is, in fact, nothing with the computer. It is for the sake of convenience to the debugger, in case any bugs occurred. Moreover, ~ once is uncommon enough even for strings, and twice is even more. But of course, a line break is even better, but the problem of supporting multiple OS (like \r and \r\n and \n) would occur.
Never mind if I really did because the early bird gets the worm. Anyway I just didn't look at whatever you are talking about because I had never read any code you wrote. Moreover this is not a releasing plugin on the forums. Just a private plugin between Lambo and me.