Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.48 KB | None | 0 0
  1. <?php
  2.  
  3. namespace moch\TopMoneys;
  4.  
  5. use pocketmine\plugin\PluginBase;
  6. use pocketmine\utils\Config;
  7. use pocketmine\math\Vector3;
  8. use pocketmine\command\CommandSender;
  9. use pocketmine\command\Command;
  10. use pocketmine\Player;
  11. use pocketmine\event\entity\EntityLevelChangeEvent;
  12. use pocketmine\event\player\PlayerJoinEvent;
  13. use pocketmine\event\Listener;
  14.  
  15. class Main extends PluginBase implements Listener{
  16.  
  17.     private $particles = [];
  18.     private $particles1 = [];
  19.     private $particles2 = [];
  20.     private $particles3 = [];
  21.     private $particles4 = [];
  22.     private $particles5 = [];
  23.  
  24.     public function onEnable(){
  25.      $this->config = (new Config($this->getDataFolder()."config.yml", Config::YAML))->getAll();
  26.      if(empty($this->config["positions"])){
  27.       $this->getServer()->getLogger()->Info(" Position is empty");
  28.       return;
  29.      }
  30.      if(empty($this->config["positions1"])){
  31.       $this->getServer()->getLogger()->Info("Position1 is empty");
  32.       return;
  33.       }
  34.       if(empty($this->config["positions2"])){
  35.       $this->getServer()->getLogger()->Info("Position3 is empty");
  36.       return;
  37.       }
  38.       if(empty($this->config["positions3"])){
  39.       $this->getServer()->getLogger()->Info("Position4 is empty");
  40.       return;
  41.       }
  42.       if(empty($this->config["positions4"])){
  43.       $this->getServer()->getLogger()->Info("Position5 is empty");
  44.       return;
  45.       }
  46.       if(empty($this->config["positions5"])){
  47.       $this->getServer()->getLogger()->Info("Position6 is empty");
  48.       return;
  49.       }
  50.      $pos = $this->config["positions"];
  51.      $this->particles[] = new FloatingText($this, new Vector3($pos[0], $pos[1], $pos[2]));
  52.      $pos1 = $this->config["positions1"];
  53.      $this->particles1[] = new FloatingText($this, new Vector3($pos1[0], $pos1[1], $pos1[2]));
  54.      $pos2 = $this->config["positions2"];
  55.      $this->particles2[] = new FloatingText($this, new Vector3($pos2[0], $pos2[1], $pos2[2]));
  56.      $pos3 = $this->config["positions3"];
  57.      $this->particles3[] = new FloatingText($this, new Vector3($pos3[0], $pos3[1], $pos3[2]));
  58.      $pos4 = $this->config["positions4"];
  59.      $this->particles4[] = new FloatingText($this, new Vector3($pos4[0], $pos4[1], $pos4[2]));
  60.      $pos5 = $this->config["positions5"];
  61.      $this->particles5[] = new FloatingText($this, new Vector3($pos5[0], $pos5[1], $pos5[2]));
  62.      $this->getServer()->getLogger()->Info("floatingPlayerCounter enabled");
  63.       $this->getServer()->getPluginManager()->registerEvents($this, $this);
  64.     }
  65.  
  66.     public function onCommand(CommandSender $p, Command $command, string $label, array $args):bool{
  67.      if($command->getName() === "setblockparty"){
  68.       if(!$p instanceof Player) return false;
  69.       if(!$p->isOp()) return false;
  70.       $config = new Config($this->getDataFolder()."config.yml", Config::YAML);
  71.       $config->set("positions", [round($p->getX()), round($p->getY()), round($p->getZ())]);
  72.       $config->save();
  73.       $p->sendMessage("§a* blockparty set§r§f!");
  74.      } elseif ($command->getName() === "setplots"){
  75.       if(!$p instanceof Player) return false;
  76.       if(!$p->isOp()) return false;
  77.       $config1 = new Config($this->getDataFolder()."config.yml", Config::YAML);
  78.       $config1->set("positions1", [round($p->getX()), round($p->getY()), round($p->getZ())]);
  79.       $config1->save();
  80.       $p->sendMessage("§a* plots set§r§f!");
  81.      } elseif ($command->getName() === "setrace"){
  82.       if(!$p instanceof Player) return false;
  83.       if(!$p->isOp()) return false;
  84.       $config2 = new Config($this->getDataFolder()."config.yml", Config::YAML);
  85.       $config2->set("positions2", [round($p->getX()), round($p->getY()), round($p->getZ())]);
  86.       $config2->save();
  87.       $p->sendMessage("§a* race set§r§f!");
  88.      } elseif ($command->getName() === "setbridge"){
  89.       if(!$p instanceof Player) return false;
  90.       if(!$p->isOp()) return false;
  91.       $config3 = new Config($this->getDataFolder()."config.yml", Config::YAML);
  92.       $config3->set("positions3", [round($p->getX()), round($p->getY()), round($p->getZ())]);
  93.       $config3->save();
  94.       $p->sendMessage("§a*  bridge set§r§f!");
  95.      } elseif ($command->getName() === "setparkour"){
  96.       if(!$p instanceof Player) return false;
  97.       if(!$p->isOp()) return false;
  98.       $config1 = new Config($this->getDataFolder()."config.yml", Config::YAML);
  99.       $config1->set("positions4", [round($p->getX()), round($p->getY()), round($p->getZ())]);
  100.       $config1->save();
  101.       $p->sendMessage("§a* parkour set§r§f!");
  102.      } elseif ($command->getName() === "setkoth"){
  103.       if(!$p instanceof Player) return false;
  104.       if(!$p->isOp()) return false;
  105.       $config1 = new Config($this->getDataFolder()."config.yml", Config::YAML);
  106.       $config1->set("positions5", [round($p->getX()), round($p->getY()), round($p->getZ())]);
  107.       $config1->save();
  108.       $p->sendMessage("§a* koth set§r§f!");
  109.      }
  110.      return true;
  111.     }
  112.  
  113.      public function join(PlayerJoinEvent $e){
  114.         $player = $e->getPlayer();
  115.      $this->getScheduler()->scheduleTask(new UpdateTask($this));
  116.      }
  117.      
  118.     public function levelChange(EntityLevelChangeEvent $event) {
  119.             $pl = $event->getEntity();
  120.             if($pl instanceof Player){
  121.                 $Origin = $event->getOrigin();
  122.                 $OriginName = $Origin->getFolderName();
  123.                 $Target = $event->getOrigin();
  124.                 $TargetName = $Target->getFolderName();
  125.                 $this->getScheduler()->scheduleTask(new UpdateTask($this));
  126.    }
  127.   }
  128.  
  129.     public function getLeaderBoard():string{
  130.         $message = "playing: unknown";
  131. if ($this->getServer()->isLevelLoaded("blockparty")) {
  132.       $playercount2 = count($this->getServer()->getLevelByName("blockparty")->getPlayers());
  133.      
  134.      $message = "§aPlaying:§f $playercount2";
  135.      }
  136.      $return = (string) $message;
  137.      return $return;
  138.     }
  139.    
  140.     public function getLeaderBoard1():string{
  141. $message = "playing: unknown";
  142. if ($this->getServer()->isLevelLoaded("p")) {
  143.    $playercount1 = count($this->getServer()->getLevelByName("p")->getPlayers());
  144.  
  145.      $message = "§aPlaying:§f $playercount1";
  146.      }
  147.      $return = (string) $message;
  148.      return $return;
  149.     }
  150.    
  151.     public function getLeaderBoard2():string{
  152. $message = "playing: unknown";
  153. if ($this->getServer()->isLevelLoaded("race")) {
  154.    $playercount1 = count($this->getServer()->getLevelByName("race")->getPlayers());
  155.  
  156.      $message = "§aPlaying:§f $playercount1";
  157.      }
  158.      $return = (string) $message;
  159.      return $return;
  160.     }
  161.    
  162.     public function getLeaderBoard3():string{
  163. $message = "playing: unknown";
  164. if (!$this->getServer()->isLevelLoaded("thebridge") OR !$this->getServer()->isLevelLoaded("thebridge1") OR !$this->getServer()->isLevelLoaded("thebridge-DUO")){
  165.     $message = "playing: unknown";
  166.     } else {
  167.    $playercount1 = count($this->getServer()->getLevelByName("thebridge")->getPlayers());
  168.    $playercount2 = count($this->getServer()->getLevelByName("thebridge1")->getPlayers());
  169.    $playercount3 = count($this->getServer()->getLevelByName("thebridge-DUO")->getPlayers());
  170.    
  171.  
  172.      $message = "§aPlaying:§f $playercount1 §7(SOLO Map1)\n§aPlaying:§f $playercount2 §7(SOLO Map2)\n§aPlaying:§f $playercount3 §7(DUO)";
  173.      }
  174.    
  175.    
  176.      $return = (string) $message;
  177.      return $return;
  178.     }
  179.    
  180.     public function getLeaderBoard4():string{
  181. $message = "playing: unknown";
  182. if ($this->getServer()->isLevelLoaded("par3")) {
  183.    $playercount1 = count($this->getServer()->getLevelByName("par3")->getPlayers());
  184.  
  185.      $message = "§aPlaying:§f $playercount1";
  186.      }
  187.      $return = (string) $message;
  188.      return $return;
  189.     }
  190.    
  191.     public function getLeaderBoard5():string{
  192. $message = "playing: unknown";
  193. if ($this->getServer()->isLevelLoaded("koth")) {
  194.    $playercount1 = count($this->getServer()->getLevelByName("koth")->getPlayers());
  195.  
  196.      $message = "§aPlaying:§f $playercount1";
  197.      }
  198.      $return = (string) $message;
  199.      return $return;
  200.     }
  201.  
  202.     public function getParticles():array{
  203.      return $this->particles;
  204.     }
  205.    
  206. public function getParticles1():array{
  207.      return $this->particles1;
  208.     }
  209.    
  210.     public function getParticles2():array{
  211.      return $this->particles2;
  212.     }
  213.    
  214.     public function getParticles3():array{
  215.      return $this->particles3;
  216.     }
  217.    
  218.     public function getParticles4():array{
  219.      return $this->particles4;
  220.     }
  221.    
  222.     public function getParticles5():array{
  223.      return $this->particles5;
  224.     }
  225.  
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement