Beispiel #1
0
 public function __construct(iZone $plugin)
 {
     $this->plugin = $plugin;
     if (!file_exists($plugin->getDataFolder() . "Database.db")) {
         $this->database = new \SQLite3($plugin->getDataFolder() . "Database.db", SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
         $resource = $this->plugin->getResource("sqlite3.sql");
         $this->database->exec(stream_get_contents($resource));
         fclose($resource);
     } else {
         $this->database = new \SQLite3($plugin->getDataFolder() . "Database.db", SQLITE3_OPEN_READWRITE);
     }
 }
Beispiel #2
0
 /**
  * @param iZone $plugin
  * @param int $name
  * @param Player $owner
  * @param Position $pos1
  * @param Position $pos2
  */
 public function __construct(iZone $plugin, $name, $owner, Position $pos1, Position $pos2, $pvpAvailable = false)
 {
     $this->plugin = $plugin;
     $this->name = $name;
     $this->minX = min($pos1->x, $pos2->x);
     $this->minY = min($pos1->y, $pos2->y);
     $this->minZ = min($pos1->x, $pos2->z);
     $this->maxX = max($pos1->x, $pos2->x);
     $this->maxY = max($pos1->y, $pos2->y);
     $this->maxZ = max($pos1->z, $pos2->z);
     $this->owner = $owner instanceof Player ? $owner->getName() : $owner;
     $this->levelName = $pos1->getLevel()->getName();
     //Register owner's permissions
     if ($owner instanceof Player) {
         $this->plugin->addPermission($owner, $name . OWNER);
         $this->plugin->getDataProvider()->setPermission($owner, $name . OWNER);
     }
     $this->pvpAvailable = $pvpAvailable;
 }
Beispiel #3
0
 public function __construct(iZone $plugin)
 {
     $this->_plugin = $plugin;
     $config = $plugin->getConfig()->get("dataProviderSettings", []);
     if (!isset($config["host"]) or !isset($config["user"]) or !isset($config["password"]) or !isset($config["database"])) {
         $this->_plugin->getLogger()->critical("Invalid MySQL settings");
         $this->_plugin->setDataProvider(new DummyProvider($this->_plugin));
         return;
     }
     $this->database = new \mysqli($config["host"], $config["user"], $config["password"], $config["database"], isset($config["port"]) ? $config["port"] : 3306);
     if ($this->database->connect_error) {
         $this->_plugin->getLogger()->critical("Couldn't connect to MySQL: " . $this->database->connect_error);
         $this->_plugin->setDataProvider(new DummyProvider($this->_plugin));
         return;
     }
     $resource = $this->_plugin->getResource("mysqli.sql");
     $this->database->query(stream_get_contents($resource));
     fclose($resource);
     $this->_plugin->getServer()->getScheduler()->scheduleRepeatingTask(new MySQLiTask($this->_plugin, $this->database), 600);
     //Each 30 seconds
     $this->_plugin->getLogger()->info("Connected to MySQL server");
 }
Beispiel #4
0
 /**
  * @param EntityDamageByEntityEvent $event
  *
  * @priority HIGH
  * @ignoreCancelled true
  */
 public function onEntityDamageByEntity(EntityDamageByEntityEvent $event)
 {
     $damager = $event->getDamager();
     $damaged = $event->getEntity();
     if ($damager instanceof Player && !$damager->isOp() && $damaged instanceof Player) {
         foreach ($this->plugin->getAllZones() as $zone) {
             if ($zone->isIn($damaged)) {
                 if ($zone->pvpAvailable) {
                     break;
                 }
                 $event->setCancelled(true);
                 $damager->sendMessage("[iZone] You are trying to attack in a private zone");
                 break;
             }
         }
     }
 }
Beispiel #5
0
 public function __construct(iZone $plugin)
 {
     $this->_plugin = $plugin;
     $this->zonesConfig = new Config($plugin->getDataFolder() . "zones.yml", Config::YAML);
     $this->permConfig = new Config($plugin->getDataFolder() . "permissions.yml", Config::YAML);
 }