OS : Android 5.1 php : 7 I built under code. but config doesn't update. What where do I have to make changes? Code: <?php namespace takesi; use pocketmine\entity\Entity; use pocketmine\event\player\PlayerJoinEvent; use pocketmine\event\Listener; use pocketmine\plugin\PluginBase; use pocketmine\utils\Config; use pocketmine\Player; class Main extends PluginBase implements Listener{ public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this,$this); if(!file_exists($this->getDataFolder())) mkdir($this->getDataFolder()); new Config($this->getDataFolder() . "config.yml", Config::YAML); } public function addConfig($name, $device){ $this->data = $this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML); if($this->data->exists($name)){ $this->data->set($name, $this->data->get($name)+$device); $this->data->save(); return true; }else{ return false; } } public function PlayerJoin(PlayerJoinEvent $event){ $this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML); $player = $event->getPlayer(); $device = $player->getDeviceModel(); $name = $player->getName(); $this->addConfig($name,$device); $this->getLogger()->info("added"); } }
use Code: your code here around your code it makes it less messy and its easier to tell whats what and the moderators ask that we do that
wtf? addConfig looks really weird. Why are you creating a new config object everytime and writing it to 2 different class variables? why are you trying to use '+' on strings? you are supposed to join them with '.'. Also getDeviceModel does not exist in PM, stop using spoons.