Beispiel #1
0
 public function placeSign(SignChangeEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     if ($ev->getBlock()->getId() != Block::SIGN_POST && $ev->getBlock()->getId() != Block::WALL_SIGN) {
         return;
     }
     $tile = $ev->getPlayer()->getLevel()->getTile($ev->getBlock());
     if (!$tile instanceof Sign) {
         return;
     }
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     $sign = $ev->getLines();
     if (!isset($this->signtxt[$sign[0]])) {
         return;
     }
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     $pl = $ev->getPlayer();
     if (!MPMU::access($pl, "killrate.signs.place")) {
         //echo __METHOD__.",".__LINE__."\n";//##DEBUG
         SignUtils::breakSignLater($this->owner, $tile);
         return;
     }
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     $pl->sendMessage(mc::_("Placed [KillRate] sign"));
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     $this->owner->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this->owner, [$this, "updateTimer"], []), 10);
 }
Beispiel #2
0
 public function placeSign(SignChangeEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     if ($ev->getBlock()->getId() != Block::SIGN_POST && $ev->getBlock()->getId() != Block::WALL_SIGN) {
         return;
     }
     $tile = $ev->getPlayer()->getLevel()->getTile($ev->getBlock());
     if (!$tile instanceof Sign) {
         return;
     }
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     $sign = $ev->getLines();
     if (!isset($this->cfg["signs"][$sign[0]])) {
         return;
     }
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     $pl = $ev->getPlayer();
     if (!MPMU::access($pl, "killrate.signs.place")) {
         //echo __METHOD__.",".__LINE__."\n";//##DEBUG
         $l = $pl->getLevel();
         $l->setBlockIdAt($tile->getX(), $tile->getY(), $tile->getZ(), Block::AIR);
         $l->setBlockDataAt($tile->getX(), $tile->getY(), $tile->getZ(), 0);
         $tile->close();
         return;
     }
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     $pl->sendMessage(mc::_("Placed [KillRate] sign"));
     $this->stats = [];
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     $this->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this, [$this, "updateTimer"], []), 10);
 }
Beispiel #3
0
 private function cmdStats(CommandSender $c, $args)
 {
     if (count($args) == 0) {
         if (!MPMU::inGame($c)) {
             return true;
         }
         $args = [$c->getName()];
     }
     foreach ($args as $pl) {
         if (MPMU::inGame($c, false) && $pl != $c->getName()) {
             if (!MPMU::access($c, "killrate.cmd.stats.other")) {
                 return true;
             }
         }
         $score = $this->dbm->getScores($pl);
         if ($score == null) {
             $c->sendMessage(mc::_("No scores found for %1%", $pl));
             continue;
         } else {
             if (count($args) != 1) {
                 $c->sendMessage(TextFormat::BLUE . $pl);
             }
             list($k, $d) = [null, null];
             foreach ($score as $row) {
                 if ($row["type"] == "player") {
                     $k = (double) $row["count"];
                 }
                 if ($row["type"] == "deaths") {
                     $d = $row["count"];
                 }
                 $c->sendMessage(TextFormat::GREEN . $row['type'] . ": " . TextFormat::WHITE . $row['count']);
             }
             if ($k !== null && $d !== null && $d > 0) {
                 $c->sendMessage(TextFormat::GREEN . mc::_("kdratio: ") . TextFormat::WHITE . round($k / $d, 2));
             }
         }
     }
     return true;
 }