Exemple #1
0
 public function addLand($player, $startX, $startZ, $endX, $endZ, $level, $expires = null)
 {
     if ($level instanceof Level) {
         $level = $level->getFolderName();
     }
     if ($player instanceof Player) {
         $player = $player->getName();
     }
     if (is_numeric($this->config->get("player-land-limit"))) {
         $cnt = count($this->db->getLandsByOwner($player));
         if ($cnt >= $this->config->get("player-land-limit")) {
             return self::RET_LAND_LIMIT;
         }
     }
     if ($startX > $endX) {
         $tmp = $startX;
         $startX = $endX;
         $endX = $tmp;
     }
     if ($startZ > $endZ) {
         $tmp = $startZ;
         $startZ = $endZ;
         $endZ = $tmp;
     }
     $startX--;
     $endX++;
     $startZ--;
     $endZ++;
     //	$result = $this->land->query("SELECT * FROM land WHERE startX <= $endX AND endX >= $endX AND startZ <= $endZ AND endZ >= $endZ AND level = '$level'")->fetchArray(SQLITE3_ASSOC);
     $result = $this->db->checkOverlap($startX, $endX, $startZ, $endZ, $level);
     if ($result) {
         return self::RET_LAND_OVERLAP;
     }
     $price = ($endX - $startX - 1) * ($endZ - $startZ - 1) * $this->config->get("price-per-y-axis");
     //	$this->land->exec("INSERT INTO land (startX, endX, startZ, endZ, owner, level, price, invitee".($expires === null?"":", expires").") VALUES ($startX, $endX, $startZ, $endZ, '$player', '$level', $price, ','".($expires === null ? "":", $expires").")");
     $id = $this->db->addLand($startX, $endX, $startZ, $endZ, $level, $price, $player, $expires);
     if ($expires !== null) {
         //$info = $this->land->query("SELECT seq FROM sqlite_sequence")->fetchArray(SQLITE3_ASSOC);
         $this->getServer()->getScheduler()->scheduleDelayedTask(new ExpireTask($this, $id), $expires * 1200);
         $this->expire[$id] = array($expires * 60, time());
     }
     return true;
 }
Exemple #2
0
 public function checkOverlap($startX, $endX, $startZ, $endZ, $level)
 {
     return $this->db->checkOverlap($startX, $endX, $startZ, $endZ, $level);
 }
Exemple #3
0
 public function getLandInfo($landId)
 {
     return $this->db->getLandById($landId);
 }