public function __construct(SignShop $SignShop)
 {
     if (file_exists($SignShop->getDataFolder() . "/resources/player.db")) {
         $this->plr = new \SQLite3($SignShop->getDataFolder() . "/resources/player.db", SQLITE3_OPEN_READWRITE);
     } else {
         $this->plr = new \SQLite3($SignShop->getDataFolder() . "/resources/player.db", SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
     }
     if (file_exists($SignShop->getDataFolder() . "/resources/sign.db")) {
         $this->sign = new \SQLite3($SignShop->getDataFolder() . "/resources/sign.db", SQLITE3_OPEN_READWRITE);
     } else {
         $this->sign = new \SQLite3($SignShop->getDataFolder() . "/resources/sign.db", SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
     }
     $this->sign->exec('CREATE TABLE IF NOT EXISTS sign (var varchar(255), id int(5), damage int(5), amount int(2), available varchar(15), cost int(15), maker varchar(255), sold int(50), earned int(50), direction int(2), type VARCHAR(4) DEFAULT "buy", need INT(15))');
     $this->plr->exec('CREATE TABLE IF NOT EXISTS plr (player varchar(255), authorized varchar(10), changed int(15), echo varchar(6))');
     if ($SignShop->getSetup()->get("version") != "oneone") {
         $this->sign->exec("ALTER TABLE sign ADD type VARCHAR(4) DEFAULT 'buy', need INT(15)");
         $SignShop->getSetup()->set("version", "oneone");
         foreach ($this->getAllPlayers() as $var => $c) {
             if ($c["authorized"] == "super") {
                 $c["authorized"] = "root";
             } elseif ($c["authorized"] == "auth") {
                 $c["authorized"] = "allow";
             } elseif ($c["authorized"] == "unauth") {
                 $c["authorized"] = "denied";
             }
             $this->setPlayer($var, $c);
         }
         foreach ($this->getAllSigns() as $var => $c) {
             $pos = explode(":", $var);
             $pos[3] = str_replace("%", " ", $pos[3]);
             $this->removeSign($var);
             $this->setSign($pos, $c);
         }
     }
 }
Example #2
0
 public function __construct(SignShop $SignShop)
 {
     $this->SignShop = $SignShop;
     if (count($SignShop->getProvider()->getAllSigns()) <= 0) {
         return;
     }
     foreach ($SignShop->getProvider()->getAllSigns() as $var => $c) {
         $pos = explode(":", $var);
         $this->signs[$this->getWorld($pos[3])][$pos[0] . ":" . $pos[1] . ":" . $pos[2]] = true;
     }
     foreach ($this->signs as $world => $sign) {
         ksort($this->signs[$world]);
     }
     $this->reload();
 }
 public function __construct(SignShop $SignShop, $dataResources)
 {
     $this->SignShop = $SignShop;
     $file_message = new Config($dataResources . "messages.yml", Config::YAML, $this->message);
     $this->dataResources = $dataResources;
     if ($file_message->get("version_mex") != "oneone") {
         $SignShop->getServer()->getLogger()->info(TextFormat::RED . "Please update the file messages.yml");
     }
     foreach ($this->message as $var => $c) {
         if ($file_message->exists($var) && isset($file_message->get($var)["message"]) && !empty($file_message->get($var)["message"])) {
             $c = $file_message->get($var)["message"];
         } else {
             $c = str_replace("_", " ", $var);
         }
         $this->message[$var]["message"] = $c;
     }
     $this->message["version_mex"] = "oneone";
     $file_message->setAll($this->message);
     $file_message->save();
 }
Example #4
0
 public function __construct(SignShop $SignShop)
 {
     $config = $SignShop->getSetup()->get("dataProviderSettings");
     if (!isset($config["host"]) or !isset($config["user"]) or !isset($config["password"]) or !isset($config["database"])) {
         $SignShop->getLogger()->critical("Invalid MySQL settings");
         $SignShop->getServer()->shutdown();
         return;
     }
     $this->database = new \mysqli($config["host"], $config["user"], $config["password"], $config["database"], isset($config["port"]) ? $config["port"] : 3306);
     if ($this->database->connect_error) {
         $SignShop->getLogger()->critical("Couldn't connect to MySQL: " . $this->database->connect_error);
         $SignShop->getServer()->shutdown();
         return;
     }
     $this->database->query('CREATE TABLE IF NOT EXISTS sign (var varchar(255), id int(5), damage int(5), amount int(2), available varchar(15), cost int(15), maker varchar(255), sold int(50), earned int(50), direction int(2), type VARCHAR(4) DEFAULT "buy", need INT(15))');
     $this->database->query('CREATE TABLE IF NOT EXISTS plr (player varchar(255), authorized varchar(10), changed int(15), echo varchar(6))');
     if ($SignShop->getSetup()->get("version") != "oneone") {
         $this->database->query("ALTER TABLE sign ADD type VARCHAR(4) DEFAULT 'buy', need INT(15)");
         $SignShop->getSetup()->set("version", "oneone");
     }
     $SignShop->getServer()->getScheduler()->scheduleRepeatingTask(new TaskPingMySQL($SignShop), 600);
 }
 public function __construct(SignShop $SignShop)
 {
     parent::__construct("sign", "Buy and Sell the items using Signs with virtual-money.", "/sign <command> <value>");
     $this->SignShop = $SignShop;
     $this->MessageManager = $SignShop->messageManager();
 }
Example #6
0
 public function __construct(SignShop $SignShop)
 {
     if ($SignShop->getServer()->getPluginManager()->getPlugin("PocketMoney") instanceof Plugin) {
         $version = explode(".", $SignShop->getServer()->getPluginManager()->getPlugin("PocketMoney")->getDescription()->getVersion());
         if ($version[0] < 4) {
             $SignShop->getLogger()->critical("The version of PocketMoney is too old! Please update PocketMoney to version 4.0.1");
             $SignShop->getServer()->shutdown();
         }
         $this->PocketMoney = $SignShop->getServer()->getPluginManager()->getPlugin("PocketMoney");
     } elseif ($SignShop->getServer()->getPluginManager()->getPlugin("EconomyAPI") instanceof Plugin) {
         $version = explode(".", $SignShop->getServer()->getPluginManager()->getPlugin("EconomyAPI")->getDescription()->getVersion());
         if ($version[0] < 2) {
             $SignShop->getLogger()->critical("The version of EconomyAPI is too old! Please update EconomyAPI to version 2.0.8");
             $SignShop->getServer()->shutdown();
         }
         $this->EconomyS = $SignShop->getServer()->getPluginManager()->getPlugin("EconomyAPI");
     } elseif ($SignShop->getServer()->getPluginManager()->getPlugin("MassiveEconomy") instanceof Plugin) {
         $this->MassiveEconomy = $SignShop->getServer()->getPluginManager()->getPlugin("MassiveEconomy");
     } else {
         $SignShop->getLogger()->critical("This plugin to work needs the plugin PocketMoney or EconomyS or MassiveEconomy.");
         $SignShop->getServer()->shutdown();
     }
 }
Example #7
0
 public function __construct(SignShop $SignShop)
 {
     $dataResources = $SignShop->getDataFolder() . "/resources/";
     if (file_exists($dataResources . "player_authorized.yml")) {
         rename($dataResources . "player_authorized.yml", $dataResources . "player.yml");
     }
     $this->sign = new Config($dataResources . "sign.yml", Config::YAML);
     $this->plr = new Config($dataResources . "player.yml", Config::YAML);
     if ($SignShop->getSetup()->get("version") != "oneone") {
         foreach ($this->plr->getAll() as $var => $c) {
             if (!isset($c["earned"])) {
                 $c["earned"] = 0;
             }
             if (!isset($c["totEarned"])) {
                 $c["totEarned"] = 0;
             }
             if (!isset($c["totSpent"])) {
                 $c["totSpent"] = 0;
             }
             if (!isset($c["echo"])) {
                 $c["echo"] = true;
             }
             if ($c["authorized"] == "super") {
                 $c["authorized"] = "root";
             }
             if ($c["authorized"] == "auth") {
                 $c["authorized"] = "allowed";
             }
             if ($c["authorized"] == "unauth") {
                 $c["authorized"] = "denied";
             }
             $this->plr->set($var, $c);
             $this->plr->save();
         }
         foreach ($this->sign->getAll() as $var => $c) {
             if (!isset($c["type"])) {
                 $c["type"] = "buy";
             }
             if (!isset($c["need"])) {
                 $c["need"] = 0;
             }
             if (!isset($c["sold"])) {
                 $c["sold"] = 0;
             }
             if (!isset($c["earned"])) {
                 $c["earned"] = 0;
             }
             if (!isset($c["direction"])) {
                 $c["direction"] = 0;
             }
             if (!isset($c["damage"])) {
                 $c["damage"] = $c["meta"];
                 unset($c["meta"]);
             }
             $pos = explode(":", $var);
             $pos[3] = str_replace("%", " ", $pos[3]);
             $this->sign->remove($var);
             $this->sign->set(implode(":", $pos), $c);
             $this->sign->save();
         }
         $SignShop->getSetup()->set("version", "oneone");
         $SignShop->getSetup()->save();
     }
 }