Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Plugin Help

Comments in 'Plugin Development' started by applqpak, Dec 28, 2015.

Thread Status:
Not open for further replies.
  1. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Hello. I'm making a Client Ban plugin, and this is the PHP so far:

    PHP:
    <?php

      
    namespace ClientBan;
      use 
    pocketmine\Player;
      use 
    pocketmine\utils\TextFormat as TF;
      use 
    pocketmine\command\Command;
      use 
    pocketmine\command\CommandSender;
      use 
    pocketmine\event\player\PlayerPreLoginEvent;
      use 
    pocketmine\plugin\PluginBase;
      class 
    Main extends PluginBase implements Listener {
        public function 
    onEnable() {
       
          
    $this->getServer()->getPluginManager()->registerEvents($this$this);
          @
    mkdir($this->getDataFolder());
          if(
    file_exists($this->getDataFolder() . "bans.txt")) {
         
            
    $file file_get_contents($this->getDataFolder() . "bans.txt");
           
          }
         
        }
       
        public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $args) {
       
          if(
    strtolower($cmd->getName()) === "clientban") {
         
            if(!(isset(
    $args[0]))) {
           
              
    $sender->sendMessage("Insufficient amount of args.");
             
            } else {
           
              
    $p array_shift(args);
              
    $player $this->getServer()->getPlayer($p);
              if(!(
    $player instanceof Player)) {
             
                
    $sender->sendMessage($p " Is not Online!");
               
              } else {
             
                
    $client $player->getClientId();
                
    $name $player->getName();
                
    file_put_contents($this->getDataFolder() . "bans.txt""$client||$name\n"FILE_APPEND);
                
    $player->kick("You have been Client Banned!");
                
    $sender->sendMessage("Banned " $p);
               
              }
             
            }
           
          } else if(
    strtolower($cmd->getName()) === "clientpardon") {
         
            if(!(isset(
    $args[0]))) {
           
              
    $sender->sendMessage("Insufficient amount of args.");
             
            } else {
         
              if(!(
    $player instanceof Player)) {
           
                
    $sender->sendMessage($p " Is not Online!");
             
              } else if(!(
    strstr($this->getDataFolder() . "bans.txt""$client||$name"))) {
             
                
    $sender->sendMessage($p " Is not in the Ban List.");
             
              } else {
           
                if(
    strstr($this->getDataFolder() . "bans.txt""$client||$name")) {
             
                  
    str_replace("$client||$name"""$file);
                  
    $sender->sendMessage($p " Has been Pardoned!");
               
                }
             
              }
             
            }
           
          }
         
        }
       
        public function 
    onPreLogin(PlayerPreLoginEvent $ev) {
       
          if(
    strstr($file"$client||$name")) {
         
            
    $ev->setKickMessage("You are client banned.");
            
    $ev->setCancelled();
           
          }
         
        }
       
      }
    ?>
    Would this work?
  2. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Instead of asking whether it will work.. It will be much faster to test it out yourself
  3. KubixQ
    Offline

    KubixQ Active Member

    Joined:
    Sep 13, 2015
    Posts:
    85
    Minecraft User:
    KubixQ
    I can edit ClientID in mcpe files. :p
  4. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    I would.. If I had a server... :p
  5. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Um.. Pretty much anyone can with an Android/Jailbroken iOS device. :p
  6. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Use pmt.mcpe.me
  7. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    What does that have to do with it?
  8. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    It has features such as it will find the errors in your code and make it into a phar
    applqpak likes this.
  9. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Okay, I did it and it said everything passed and 1 good PHP file(s) and 0 bad PHP file(s)
Thread Status:
Not open for further replies.

Share This Page

Advertisement