public function execute(CommandSender $sender, $lbl, array $args) { if ($sender instanceof Player) { if (!$this->getPlugin()->getSessions()->getSession($sender)->isMod()) { $sender->sendMessage($this->getPermissionMessage()); return true; } } if (!isset($args[2])) { return false; } $target = $this->getPlugin()->getSessions()->getSession($name = array_shift($args)); if (!$target instanceof Session) { $sender->sendMessage(TextFormat::RED . "Cannot find player \"{$name}\"."); return true; } $duration = (int) ((double) array_shift($args) * 60); if ($duration === 0) { return false; } $issue = new MuteIssue(); $issue->issuer = $ip = $sender->getName(); $issue->target = $target->getPlayer()->getAddress(); $issue->reason = implode(" ", $args); $issue->from = time(); $issue->duration = MUtils::time_secsToString($duration); $issue->till = time() + $duration; $target->tell(TextFormat::BLACK . str_repeat("~", 20)); $target->tell($issue->notify("you", TextFormat::YELLOW)); $target->tell(TextFormat::BLACK . str_repeat("~", 20)); $this->getPlugin()->getServer()->broadcast($issue->notify($target->getRealName(), TextFormat::DARK_GREEN), Server::BROADCAST_CHANNEL_ADMINISTRATIVE); $this->getPlugin()->getSessions()->mutedIps[$ip] = $issue; return true; }
/** * @param string $issuer * @param Warning|null $lastWarning */ public function recalcPenalty($issuer, $lastWarning = null) { $pts = $this->getWarningPoints(); switch (true) { case $pts >= 100: $ban = 6480000; break; case $pts >= 80: $ban = 5184000; break; case $pts >= 60: $ban = 3888000; break; case $pts >= 50: $ban = 2592000; break; case $pts >= 40: $ban = 1209600; break; case $pts >= 30: $ban = 604800; break; case $pts >= 28: $mute = 7200; break; case $pts >= 24: $mute = 3600; break; case $pts >= 21: $mute = 2700; break; case $pts >= 18: $mute = 1800; break; case $pts >= 15: $mute = 1500; break; case $pts >= 12: $mute = 1200; break; case $pts >= 7: $mute = 900; break; case $pts >= 4: $mute = 300; break; } if (isset($ban)) { $this->banPlayer($issuer, TextFormat::GOLD . "You have accumulated {$pts} warning points and have been banned for " . TextFormat::BLUE . $ban / 86400 . TextFormat::GOLD . " days." . ($lastWarning !== null ? " Your latest warning: " . $lastWarning->toString() : ""), $ban); return; } if (isset($mute)) { $this->sesList->mutedIps[$this->getPlayer()->getAddress()] = $mi = new MuteIssue(); $mi->reason = "Accumulated {$pts} warning points"; $mi->issuer = $issuer; $mi->target = $this->getPlayer()->getAddress(); $mi->from = time(); $mi->duration = $mute; $mi->till = time() + $mute; $mi->notify("you", TextFormat::GOLD); } }