Пример #1
0
 public function announce($pp, $points, $money)
 {
     if ($points) {
         if ($points > 0) {
             $pp->sendMessage(TextFormat::BLUE . mc::n(mc::_("one point awarded!"), mc::_("%1% points awarded!", $points), $points));
         } else {
             $pp->sendMessage(TextFormat::RED . mc::n(mc::_("one point deducted!"), mc::_("%1% points deducted!", $points), $points));
         }
     }
     if ($money) {
         if ($money > 0) {
             $pp->sendMessage(TextFormat::GREEN . mc::n(mc::_("You earn \$1"), mc::_("You earn \$%1%", $money), $money));
         } else {
             $pp->sendMessage(TextFormat::YELLOW . mc::n(mc::_("You are fined \$1"), mc::_("You are fined \$%1%", $money), $money));
         }
     }
 }
Пример #2
0
 public function deadDealer($pv)
 {
     if ($pv instanceof Player) {
         // Score that this player died!
         $deaths = $this->updateDb($pv->getName(), "deaths");
         if ($this->settings["reset-on-death"] && $this->settings["reset-on-death"] > 0) {
             if ($deaths >= $this->settings["reset-on-death"]) {
                 // We died too many times... reset scores...
                 $this->getServer()->getPluginManager()->callEvent($ev = new KillRateResetEvent($this, $pv));
                 if (!$ev->isCancelled()) {
                     $this->delScore($pv->getName());
                     $this->ranks->resetRank($pv);
                     $pv->sendMessage(mc::_("GAME OVER!!!"));
                     $this->getServer()->broadcastMessage(mc::n(mc::_("%1% died. RIP!", $pv->getDisplayName()), mc::_("%1% died %2% times. RIP!", $pv->getDisplayName(), $deaths), $deaths));
                 }
             }
         }
         $this->kstreak->endStreak($pv);
     }
     $cause = $pv->getLastDamageCause();
     // If we don't know the real cause, we can score it!
     if (!$cause instanceof EntityDamageEvent) {
         return;
     }
     switch ($cause->getCause()) {
         case EntityDamageEvent::CAUSE_PROJECTILE:
             $pp = $cause->getDamager();
             break;
         case EntityDamageEvent::CAUSE_ENTITY_ATTACK:
             $pp = $cause->getDamager();
             break;
         case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
             $pp = $cause->getDamager();
             if ($pp instanceof Projectile) {
                 $pp = $pp->shootingEntity;
             }
             break;
         default:
             return;
     }
     if (!$pp instanceof Player) {
         return;
     }
     // Not killed by player...
     // No scoring for creative players...
     if ($pp->isCreative() && !$this->settings["creative"]) {
         return;
     }
     $perp = $pp->getName();
     $vic = $pv->getName();
     if ($pv instanceof Player) {
         $vic = "Player";
         // OK killed a player... check for a kill streak...
         $pv->sendMessage(TextFormat::RED . mc::_("You were killed by %1%!", $pp->getName()));
         if ($this->kstreak->scoreStreak($pp)) {
             $this->achievements->awardSerialKiller($pp);
         }
     }
     $perp = $pp->getName();
     list($points, $money) = $this->updateScores($pp, $perp, $vic);
     $this->announce($pp, $points, $money);
 }