private function checkPerm(Player $pl, $perm)
 {
     if ($pl->hasPermission($perm)) {
         return;
     }
     $n = strtolower($pl->getName());
     $this->helper->getLogger()->warnning(mc::_("Fixing %1% for %2%", $perm, $n));
     if (!isset($this->perms[$n])) {
         $this->perms[$n] = $pl->addAttachment($this->helper);
     }
     $this->perms[$n]->setPermission($perm, true);
     $pl->recalculatePermissions();
 }
Exemple #2
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (!$this->auth) {
         $sender->sendMessage(TextFormat::RED . mc::_("SimpleAuthHelper has been disabled"));
         $sender->sendMessage(TextFormat::RED . mc::_("SimpleAuth not found!"));
         return true;
     }
     switch ($cmd->getName()) {
         case "chpwd":
             if (count($args) == 0) {
                 return false;
             }
             return $this->chpwd($sender, implode(" ", $args));
         case "resetpwd":
             if (count($args) != 1) {
                 return false;
             }
             return $this->resetpwd($sender, $args[0]);
         case "logout":
             if (count($args) != 0) {
                 return false;
             }
             return $this->logout($sender);
         case "preregister":
             if (count($args) != 2) {
                 return false;
             }
             return $this->prereg($sender, $args[0], $args[1]);
     }
     return false;
 }
 public function onJoin(PlayerJoinEvent $ev)
 {
     if ($this->ok) {
         return;
     }
     $ev->getPlayer()->kick(mc::_("Database is experiencing technical difficulties"));
 }
Exemple #4
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (!$this->auth) {
         $sender->sendMessage(TextFormat::RED . mc::_("SimpleAuthHelper has been disabled"));
         $sender->sendMessage(TextFormat::RED . mc::_("SimpleAuth not found!"));
         return true;
     }
     switch ($cmd->getName()) {
         case "chpwd":
             if (!$sender instanceof Player) {
                 $sender->sendMessage(TextFormat::RED . mc::_("This command only works in-game."));
                 return true;
             }
             if (count($args) == 0) {
                 return false;
             }
             if (!$this->auth->isPlayerRegistered($sender)) {
                 $sender->sendMessage(TextFormat::YELLOW . mc::_("register first"));
                 return true;
             }
             if ($this->authenticate($sender, implode(" ", $args))) {
                 $this->chpwd[$sender->getName()] = $sender->getName();
                 $sender->sendMessage(TextFormat::AQUA . mc::_("chpwd msg"));
                 return true;
             }
             $sender->sendMessage(TextFormat::RED . mc::_("chpwd error"));
             return false;
             break;
         case "resetpwd":
             foreach ($args as $name) {
                 $player = $this->getServer()->getOfflinePlayer($name);
                 if ($this->auth->unregisterPlayer($player)) {
                     $sender->sendMessage(TextFormat::GREEN . mc::_("%1% unregistered", $name));
                     if ($player instanceof Player) {
                         $player->sendMessage(TextFormat::YELLOW . mc::_("You are no longer registered!"));
                         $this->auth->deauthenticatePlayer($player);
                     }
                 } else {
                     $sender->sendMessage(TextFormat::RED . mc::_("Unable to unregister %1%", $name));
                 }
                 return true;
             }
             break;
     }
     return false;
 }
 public function onJoin(PlayerJoinEvent $ev)
 {
     if ($this->ok) {
         return;
     }
     //echo  __METHOD__.",".__LINE__."\n";//##DEBUG
     $this->delayedKick($ev->getPlayer(), mc::_("Database is experiencing technical difficulties"));
 }