getLogger() public method

public getLogger ( ) : PluginLogger
return PluginLogger
コード例 #1
0
ファイル: MoneyAPI.php プロジェクト: DWWf/pocketmine-plugins
 /**
  * Show a notice when the money API is found
  *
  * @param PluginBase $plugin - current plugin
  * @param PluginBase $api - found plugin
  * @param LogLevel $level - optional log level
  */
 public static function foundMoney(PluginBase $plugin, $api, $level = LogLevel::INFO)
 {
     if (class_exists(__NAMESPACE__ . "\\mc", false)) {
         $plugin->getLogger()->log($level, TextFormat::BLUE . mc::_("Using money API from %1%", $api->getFullName()));
     } else {
         $plugin->getLogger()->log($level, TextFormat::BLUE . "Using money API from " . $api->getFullName());
     }
 }
コード例 #2
0
 public function __construct(PluginBase $owner)
 {
     $cf = $owner->getCfg("MySql");
     $this->database = new \mysqli($cf["host"], $cf["user"], $cf["password"], $cf["database"], $cf["port"]);
     if ($this->database->connect_error) {
         throw new \RuntimeException("Invalid MySql settings");
         return;
     }
     $sql = "CREATE TABLE IF NOT EXISTS Scores (\n\t\t\tplayer VARCHAR(16) NOT NULL,\n\t\t\ttype VARCHAR(128) NOT NULL,\n\t\t\tcount INT NOT NULL,\n\t\t\tPRIMARY KEY (player,type)\n\t\t)";
     $this->database->query($sql);
     $owner->getServer()->getScheduler()->scheduleRepeatingTask(new PluginCallbackTask($owner, [$this, "pingMySql"]), 600);
     $owner->getLogger()->info("Connected to MySQL server");
 }
コード例 #3
0
ファイル: MySqlMgr.php プロジェクト: DWWf/pocketmine-plugins
 public function __construct(PluginBase $owner, $cf)
 {
     $this->owner = $owner;
     $this->isGlobal = $cf["settings"]["global"];
     $this->database = new \mysqli($cf["MySql"]["host"], $cf["MySql"]["user"], $cf["MySql"]["password"], $cf["MySql"]["database"], $cf["MySql"]["port"]);
     if ($this->database->connect_error) {
         throw new \RuntimeException("Invalid MySql settings");
         return;
     }
     $sql = "CREATE TABLE IF NOT EXISTS NetherChests (\n      player VARCHAR(16) NOT NULL,\n      world VARCHAR(128) NOT NULL,\n      slot INT NOT NULL,\n      id INT NOT NULL,\n      damage INT NOT NULL,\n      count INT NOT NULL,\n      PRIMARY KEY (player,world,slot)\n    )";
     $this->database->query($sql);
     $owner->getServer()->getScheduler()->scheduleRepeatingTask(new PluginCallbackTask($owner, [$this, "pingMySql"]), 600);
     $owner->getLogger()->info("Connected to MySQL server");
 }
コード例 #4
0
 public function __construct(Plugin $plugin, $goods, $dfts)
 {
     $this->owner = $plugin;
     $this->owner->getServer()->getPluginManager()->registerEvents($this, $this->owner);
     $this->goods = [];
     foreach ($goods as $cf) {
         $item = Item::fromString($cf);
         if (($item = $item->getId()) == Item::AIR) {
             $plugin->getLogger()->error(mc::_("Invalid trade-good: %1%", $cf));
             continue;
         }
         $this->goods[$item] = $item;
     }
     $this->defaults = $dfts;
     $this->state = [];
 }
コード例 #5
0
 public function __construct(Plugin $plugin, $xfg)
 {
     $this->owner = $plugin;
     $this->keepers = [];
     $cfg = (new Config($plugin->getDataFolder() . "shops.yml", Config::YAML))->getAll();
     $this->state = [];
     foreach ($cfg as $i => $j) {
         $this->keepers[$i] = [];
         if (isset($j["messages"])) {
             $this->keepers[$i]["messages"] = $j["messages"];
         } else {
             $this->keepers[$i]["messages"] = [];
         }
         $this->keepers[$i]["attack"] = isset($j["attack"]) ? $j["attack"] : 5;
         $this->keepers[$i]["slim"] = isset($j["slim"]) ? $j["slim"] : false;
         $this->keepers[$i]["displayName"] = isset($j["display"]) ? $j["display"] : "default";
         // Load the skin in memory
         if (is_file($plugin->getDataFolder() . $j["skin"])) {
             $this->keepers[$i]["skin"] = zlib_decode(file_get_contents($plugin->getDataFolder() . $j["skin"]));
         } else {
             $this->keepers[$i]["skin"] = null;
         }
         if (isset($cfg[$i]["msgs"])) {
             $this->keepers[$i]["msgs"] = $cfg[$i]["msgs"];
         }
         $items = isset($cfg[$i]["items"]) && $cfg[$i]["items"] ? $cfg[$i]["items"] : ["IRON_SWORD,2", "APPLE,10,1"];
         $this->keepers[$i]["items"] = [];
         foreach ($items as $n) {
             $t = explode(",", $n);
             if (count($t) < 2 || count($t) > 3) {
                 $plugin->getLogger()->error(mc::_("Item error: %1%", $n));
                 continue;
             }
             $item = Item::fromString(array_shift($t));
             if ($item->getId() == Item::AIR) {
                 $plugin->getLogger()->error(mc::_("Unknown Item error: %1%", $n));
                 continue;
             }
             $price = intval(array_pop($t));
             if ($price <= 0) {
                 $plugin->getLogger()->error(mc::_("Invalid price: %1%", $n));
                 continue;
             }
             if (count($t)) {
                 $qty = intval($t[0]);
                 if ($qty <= 0 || $qty >= $item->getMaxStackSize()) {
                     $plugin->getLogger()->error(mc::_("Bad quantity: %1%", $n));
                     continue;
                 }
                 $item->setCount($qty);
             }
             echo "Item: " . $item->getId() . "," . $item->getCount() . "\n";
             //##DEBUG
             $this->keepers[$i]["items"][implode(":", [$item->getId(), $item->getDamage()])] = [$item, $price];
         }
         if (count($this->keepers[$i]["items"])) {
             continue;
         }
         $plugin->getLogger()->error(mc::_("ShopKeep %1% disabled!", $i));
         unset($this->keepers[$i]);
         continue;
     }
     if (count($this->keepers) == 0) {
         $plugin->getLogger()->error(mc::_("No shopkeepers found!"));
         $this->keepers = null;
         return;
     }
     Entity::registerEntity(TraderNpc::class, true);
     $this->owner->getServer()->getPluginManager()->registerEvents($this, $this->owner);
     $this->owner->getServer()->getScheduler()->scheduleRepeatingTask(new PluginCallbackTask($this->owner, [$this, "spamPlayers"], [$xfg["range"], $xfg["freq"]]), $xfg["ticks"]);
 }