Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/LegionPE-Core/src/legionpe/games/kitpvp/PvpGame.php b/LegionPE-Core/src/legionpe/games/kitpvp/PvpGame.php
- index 0638efc..5a5b69f 100644
- --- a/LegionPE-Core/src/legionpe/games/kitpvp/PvpGame.php
- +++ b/LegionPE-Core/src/legionpe/games/kitpvp/PvpGame.php
- @@ -164,7 +164,7 @@ class PvpGame implements Game{
- ) AS sel;", MysqlConnection::RAW);
- $i = 1;
- while(is_array($row = $result->fetch_assoc())){
- - $output .= sprintf("#%d) %s (%d kills, %d deaths)\n", $i++, $row["name"], $row["kills"], $row["deaths"]); // I'm not sure about the associative names
- + $output .= sprintf("#%d) %s (%d kills, %d deaths)\n", $i++, $row["name"], (int) $row["kills"], (int) $row["deaths"]); // I'm not sure about the associative names
- }
- $result->close();
- return $output;
- @@ -275,7 +275,7 @@ class PvpGame implements Game{
- }
- $res = $this->main->getMySQLi()->query("SELECT kills FROM kitpvp WHERE uid = $uid;", MysqlConnection::ASSOC);
- if(is_array($res)){
- - return $res["kills"];
- + return (int) $res["kills"];
- }
- return 0;
- }
- @@ -292,7 +292,7 @@ class PvpGame implements Game{
- }
- $res = $this->main->getMySQLi()->query("SELECT deaths FROM kitpvp WHERE uid = $uid;", MysqlConnection::ASSOC);
- if(is_array($res)){
- - return $res["deaths"];
- + return (int) $res["deaths"];
- }
- return 0;
- }
- @@ -313,7 +313,7 @@ class PvpGame implements Game{
- else{
- $res = $this->main->getMySQLi()->query("SELECT kills,deaths FROM kitpvp WHERE uid = $uid;", MysqlConnection::ASSOC);
- if(is_array($res)){
- - list($kills, $deaths) = [$res["kills"], $res["deaths"]];
- + list($kills, $deaths) = [(int) $res["kills"], (int) $res["deaths"]];
- }
- }
- list($kills, $deaths) = [(int) $kills, (int) $deaths];
- @@ -371,6 +371,7 @@ class PvpGame implements Game{
- if($from === $to){
- return "You cannot add yourself as friend!";
- }
- + var_dump($from, $to);
- if($toLarger = $to > $from){
- $large = $to;
- $small = $from;
- @@ -382,17 +383,23 @@ class PvpGame implements Game{
- $result = $db->query("SELECT * FROM kitpvp_friends WHERE smalluid = $small AND largeuid = $large;", MysqlConnection::ASSOC);
- if(!is_array($result)){
- $result = ["smalluid" => $small, "largeuid" => $large, "type" => self::TYPE_BROKE];
- - $null = true;
- + $null = true; // insert
- + }
- + else{
- + foreach(["smalluid", "largeuid", "type"] as $key){
- + $result[$key] = (int) $result[$key];
- + }
- }
- switch($result["type"]){
- case self::TYPE_BROKE:
- // send
- $type = $toLarger ? self::TYPE_FROM_SMALL:self::TYPE_FROM_LARGE;
- + var_dump($type, $small, $large);
- if(isset($null) and $null === true){
- $db->query("INSERT INTO kitpvp_friends (smalluid, largeuid, type) VALUES (%d, %d, %d);", MysqlConnection::RAW, $small, $large, $type);
- }
- else{
- - $db->query("UPDATE kitpvp_friends SET type = %d WHERE smalluid = %d AND largeuid = %d", $type, $small, $large);
- + $db->query("UPDATE kitpvp_friends SET type = %d WHERE smalluid = %d AND largeuid = %d;", $type, $small, $large);
- }
- $otherSession = $this->main->getSessions()->getSessionByUID($to);
- if($otherSession instanceof Session){
- @@ -429,7 +436,7 @@ class PvpGame implements Game{
- if($rank === false){
- $result = $this->main->getMySQLi()->query("SELECT rank FROM ranks WHERE uid = $uid;", MysqlConnection::ASSOC);
- if(is_array($result)){
- - $rank = $result["rank"];
- + $rank = (int) $result["rank"];
- }
- else{
- $rank = Settings::RANK_IMPORTANCE_DEFAULT;
- @@ -438,6 +445,7 @@ class PvpGame implements Game{
- $max = Settings::kitpvp_maxFriends($rank);
- $result = $this->main->getMySQLi()->query("SELECT COUNT(*) AS cnt FROM kitpvp_friends WHERE (smalluid = $uid OR largeuid = $uid) AND type = %d", MysqlConnection::ASSOC, self::TYPE_FRIEND);
- if(is_array($result)){
- + $result["cnt"] = (int) $result["cnt"];
- if($result["cnt"] >= $max){
- return false; // cannot have more
- }
- @@ -497,9 +505,10 @@ class PvpGame implements Game{
- ) AS friends
- ) AS sel;", MysqlConnection::ALL);
- $names = [];
- - foreach($result as $row){
- + foreach($result as &$row){
- + $row["theirFriendsCnt"] = (int) $row["theirFriendsCnt"];
- $name = $row["name"];
- - if($row["theirFriendsCnt"] >= Settings::kitpvp_maxFriends($row["rank"])){
- + if($row["theirFriendsCnt"] >= Settings::kitpvp_maxFriends((int) $row["rank"])){
- $name = TextFormat::RED . "$name (full)" . TextFormat::RESET;
- }
- $names[] = $name;
- @@ -540,4 +549,9 @@ class PvpGame implements Game{
- public function getPlayerData(){
- return $this->playerData;
- }
- + public function updateAllToMySQL(){
- + foreach($this->playerData as $data){
- + $data->update(false);
- + }
- + }
- }
- diff --git a/LegionPE-Core/src/legionpe/games/kitpvp/PvpSessionData.php b/LegionPE-Core/src/legionpe/games/kitpvp/PvpSessionData.php
- index f1d391e..b604249 100644
- --- a/LegionPE-Core/src/legionpe/games/kitpvp/PvpSessionData.php
- +++ b/LegionPE-Core/src/legionpe/games/kitpvp/PvpSessionData.php
- @@ -23,6 +23,9 @@ class PvpSessionData{
- $this->origGm = $origGm;
- $this->uid = $uid;
- if(is_array($data)){
- + foreach(array_keys($data) as $key){
- + $data[$key] = (int) $data[$key];
- + }
- $this->data = $data;
- $this->isUpdate = true;
- }
- @@ -63,29 +66,30 @@ class PvpSessionData{
- }
- public function close(){
- $this->game->getMain()->getLogger()->debug("KitPvP player data close");
- - var_dump($this);
- - if($this->needSave){
- - $this->game->getMain()->getLogger()->debug("Saving...");
- - if($this->isUpdate){
- - $this->game->getMain()->getLogger()->debug("with UPDATE");
- - $this->game->getMain()->getMySQLi()->query(
- - "UPDATE kitpvp SET kills = %d, deaths = %d, kit = %d WHERE uid = %d;",
- - MysqlConnection::RAW,
- - $this->getKills(), $this->getDeaths(), $this->getKit(), $this->getUID()
- - );
- - }
- - else{
- - $this->game->getMain()->getLogger()->debug("with INSERT");
- - $this->game->getMain()->getMySQLi()->query(
- - "INSERT INTO kitpvp (uid, kills, deaths, kit) VALUES (%d, %d, %d, %d)",
- - MysqlConnection::RAW,
- - $this->getUID(), $this->getKills(), $this->getDeaths(), $this->getKit()
- - );
- - }
- + $this->update();
- + }
- + public function update($force = false){
- + if(!$force and !$this->needSave){
- + return;
- + }
- + if($this->isUpdate){
- + $this->game->getMain()->getLogger()->debug("with UPDATE");
- + $this->game->getMain()->getMySQLi()->query(
- + "UPDATE kitpvp SET kills = %d, deaths = %d, kit = %d WHERE uid = %d;",
- + MysqlConnection::RAW,
- + $this->getKills(), $this->getDeaths(), $this->getKit(), $this->getUID()
- + );
- }
- else{
- - $this->game->getMain()->getLogger()->debug("does not need save");
- + $this->game->getMain()->getLogger()->debug("with INSERT");
- + $this->game->getMain()->getMySQLi()->query(
- + "INSERT INTO kitpvp (uid, kills, deaths, kit) VALUES (%d, %d, %d, %d)",
- + MysqlConnection::RAW,
- + $this->getUID(), $this->getKills(), $this->getDeaths(), $this->getKit()
- + );
- }
- + $this->isUpdate = true;
- + $this->needSave = false;
- }
- /**
- * @return int
- diff --git a/LegionPE-Core/src/legionpe/games/parkour/ParkourSessionData.php b/LegionPE-Core/src/legionpe/games/parkour/ParkourSessionData.php
- index d587c77..be92f5a 100644
- --- a/LegionPE-Core/src/legionpe/games/parkour/ParkourSessionData.php
- +++ b/LegionPE-Core/src/legionpe/games/parkour/ParkourSessionData.php
- @@ -21,6 +21,9 @@ class ParkourSessionData{
- $mysqli = $this->main->getMySQLi();
- $result = $mysqli->query("SELECT uid, progress, completions FROM parkour WHERE uid = $this->uid;", MysqlConnection::ASSOC);
- if(is_array($result)){
- + foreach(array_keys($result) as $key){
- + $result[$key] = (int) $result[$key];
- + }
- $this->setValuesToArray($result);
- }
- else{
- diff --git a/LegionPE-Core/src/legionpe/session/MysqlSession.php b/LegionPE-Core/src/legionpe/session/MysqlSession.php
- index 563b528..29df1af 100644
- --- a/LegionPE-Core/src/legionpe/session/MysqlSession.php
- +++ b/LegionPE-Core/src/legionpe/session/MysqlSession.php
- @@ -19,6 +19,9 @@ class MysqlSession{
- // "SELECT * FROM players WHERE INSTR(names, %s);",
- // MysqlConnection::ASSOC, $session->getPlayer()->getName() . "|");
- $this->data = $this->session->getMain()->getMySQLi()->query("SELECT * FROM players WHERE primaryname = %s;", MysqlConnection::ASSOC, strtolower($session->getPlayer()->getName()));
- + foreach(["uid", "coins", "lastonline", "registry", "ipconfig"] as $key){
- + $this->data[$key] = (int) $this->data[$key];
- + }
- if(!is_array($this->data)){
- $this->rank = Settings::RANK_IMPORTANCE_DEFAULT | Settings::RANK_PERM_DEFAULT | Settings::RANK_PREC_STD | Settings::shiftTeamLimit(Settings::defaultTeamLimit());
- $session->getMain()->getStats()->increment(LegionPE::TITLE_LEGIONPE_NEW_JOINS);
- @@ -26,7 +29,7 @@ class MysqlSession{
- $rk = $this->session->getMain()->getMySQLi()->query(
- "SELECT rank FROM ranks WHERE uid = %d;", MysqlConnection::ASSOC, $this->data["uid"]);
- if(is_array($rk) and isset($rk["rank"])){
- - $this->rank = $rk["rank"];
- + $this->rank = (int) $rk["rank"];
- }
- else{
- $this->rank = Settings::RANK_IMPORTANCE_DEFAULT | Settings::RANK_PERM_DEFAULT | Settings::RANK_PREC_STD | Settings::shiftTeamLimit(Settings::defaultTeamLimit());
- @@ -34,8 +37,8 @@ class MysqlSession{
- $prch = $this->session->getMain()->getMySQLi()->query("SELECT * FROM purchases WHERE owner = %d AND expiry >= %d;", MysqlConnection::ALL, $this->data["uid"], time());
- if(is_array($prch)){
- foreach($prch as $p){
- - $purchase = new Purchase($p["primary_id"], $p["product"], $p["expiry"]);
- - $this->purchases[$p["primary_id"]] = $purchase;
- + $purchase = new Purchase((int) $p["primary_id"], (int) $p["product"], (int) $p["expiry"]);
- + $this->purchases[(int) $p["primary_id"]] = $purchase;
- }
- }
- }
- @@ -67,6 +70,10 @@ class MysqlSession{
- public function setData(array $data){
- $data["lastonline"] = time();
- $this->data = $data;
- + var_dump($this->data);
- + var_dump($this->session);
- + var_dump($this->session->getUID());
- + var_dump($data["uid"]);
- $result = $this->session->getMain()->getMySQLi()->query("INSERT INTO players
- (uid, names, hash, coins, lastonline, registry,
- lastip, histip, ipconfig, ignoring, primaryname)
- @@ -77,7 +84,7 @@ class MysqlSession{
- names = %s, hash = %s, coins = %d, lastonline = %d, registry = %d,
- lastip = %s, histip = %s, ipconfig = %d, ignoring = %s, primaryname = %s;",
- MysqlConnection::RAW,
- - $data["uid"],
- + (int) $data["uid"],
- $data["names"], $data["hash"], $data["coins"], $data["lastonline"], $data["registry"],
- $data["lastip"], $data["histip"], $data["ipconfig"], $data["ignoring"], $data["primaryname"],
- $data["names"], $data["hash"], $data["coins"], $data["lastonline"], $data["registry"],
- diff --git a/LegionPE-Core/src/legionpe/session/Session.php b/LegionPE-Core/src/legionpe/session/Session.php
- index a3695d3..7e0febf 100644
- --- a/LegionPE-Core/src/legionpe/session/Session.php
- +++ b/LegionPE-Core/src/legionpe/session/Session.php
- @@ -563,7 +563,7 @@ class Session extends PluginTask implements SessionEvents, ChannelSubscriber{
- $this->mysqlSession->data["ignoring"] = $this->ignoring;
- $this->mysqlSession->setData($this->mysqlSession->data);
- }
- - unset($this->player);
- + unset($this->player); // garbage player
- }
- public function h_onPreCmd(PlayerCommandPreprocessEvent $event){
- diff --git a/build/LegionPE_Eta.phar b/build/LegionPE_Eta.phar
- index 46eae3c..f6bcff4 100644
- Binary files a/build/LegionPE_Eta.phar and b/build/LegionPE_Eta.phar differ
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement