PHP: $this->database = new \mysqli($this->config["host"],$this->config["user"],$this->config["pass"], $this->config["bdd"]); if ($this->database->connect_error) { throw new \RuntimeException("Invalid MySql settings"); return; } $sql = "CREATE TABLE IF NOT EXISTS Users ( player VARCHAR(16) NOT NULL, password TEXT NOT NULL, argent INT NOT NULL, PRIMARY KEY (player) )"; $this->database->query($sql); Server::getInstance()->getLogger()->info("Connected to MySQL server"); The plugin connect to the database but the table is not created, why ?
Check if the result of query() is identical to false. If it is, throw an exception with $database->error.
I'm tired :/ PHP: public function onJoin(PlayerJoinEvent $event){ $level = $event->getPlayer()->getLevel()->getName();$player = $event->getPlayer();if ($this->isRegistered($player) == false){$this->registerPlayer($player);}} PHP: public function isRegistered($player){ $result = $this->database->query("SELECT * FROM Users WHERE player = '" . $this->database->escape_string($player->getName())."'");if($result instanceof \mysqli_result){if(count($result) > 0){return true;}else{return false;}}}public function registerPlayer($player){ $name = trim(strtolower($player->getName())); $data = [ "password" => "", "argent" => 0, "classe" => "undefined", "grade" => "Joueur" ]; $this->database->query("INSERT INTO Users (player, password, argent, classe, grade) VALUES ('".$this->database->escape_string($name)."', ".$data["password"].", ".$data["argent"].", ".$data["classe"].", '".$data["grade"]."') "); return true; } Why player isn't register after joining ?