SHARE
TWEET

Untitled

a guest Jul 17th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. namespace basprohop;
  3.  
  4. use basprohop\libraries\MinecraftQuery;
  5. use basprohop\libraries\MinecraftQueryException;
  6. use pocketmine\plugin\PluginBase;
  7. use pocketmine\event\Listener;
  8. use pocketmine\event\server\QueryRegenerateEvent;
  9.  
  10. use pocketmine\level\Level;
  11. use pocketmine\event\player\PlayerJoinEvent;
  12. use pocketmine\entity\Entity;
  13. use pocketmine\level\Position;
  14. use pocketmine\level\particle\FloatingTextParticle;
  15. use pocketmine\level\Position\getLevel;
  16. use pocketmine\nbt\tag\ByteTag;
  17. use pocketmine\nbt\tag\CompoundTag;
  18. use pocketmine\nbt\tag\DoubleTag;
  19. use pocketmine\nbt\tag\ListTag;
  20. use pocketmine\nbt\tag\FloatTag;
  21. use pocketmine\nbt\tag\ShortTag;
  22. use pocketmine\nbt\tag\StringTag;
  23. use pocketmine\level\particle\Particle;
  24. use pocketmine\command\ConsoleCommandSender;
  25. use pocketmine\command\CommandSender;
  26. use pocketmine\command\Command;
  27. use basprohop\Task\bwTask;
  28.  
  29. use pocketmine\math\Vector3;
  30.  
  31.  
  32. class CombinedSlots extends PluginBase implements Listener {
  33.  
  34.     private $Query;
  35.     private $server = array(), $timeout = 3;
  36.      public $NPC = [];
  37.     public function onEnable() {
  38.  
  39.    
  40.         @mkdir($this->getDataFolder());
  41.         $this->saveDefaultConfig();
  42.  
  43.         $this->timeout = $this->getConfig()->get("timeout");
  44.  
  45.         $server = $this->getConfig()->get("servers");
  46.         $server1 = $this->getConfig()->get("ss");
  47.         $server2 = $this->getConfig()->get("sw");
  48.         $server3 = $this->getConfig()->get("crea");
  49.         $server4 = $this->getConfig()->get("surv");
  50.         $server5 = $this->getConfig()->get("bw");
  51.         $server6 = $this->getConfig()->get("ew");
  52.  
  53.         foreach($server as $server){
  54.             $this->server[]=$server;
  55.         }
  56.         foreach($server1 as $server1){
  57.             $this->server1[]=$server1;
  58.         }
  59.          foreach($server2 as $server2){
  60.             $this->server2[]=$server2;
  61.         }
  62.          foreach($server3 as $server3){
  63.             $this->server3[]=$server3;
  64.         }
  65.          foreach($server4 as $server4){
  66.             $this->server4[]=$server4;
  67.         }
  68.          foreach($server5 as $server5){
  69.             $this->server5[]=$server5;
  70.         }
  71.         foreach($server6 as $server6){
  72.             $this->server6[]=$server6;
  73.         }
  74.    
  75.    
  76.  
  77.         $this->Query = new MinecraftQuery();
  78.         $this->getServer()->getPluginManager()->registerEvents($this, $this);
  79.  
  80.     }
  81.              public function AnotherPrepare(){
  82.     Server::getInstance()->getCommandMap()->register("npc", new npc());
  83.  
  84.   }
  85.  
  86.    public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){
  87.      
  88.        
  89.        
  90.         if($cmd->getName() == "loobby"){
  91.         new bwTask();
  92.         $sender->sendMessage("ahoj");
  93.         }
  94.  
  95.         }
  96.  
  97.     public function queryRegen(QueryRegenerateEvent $ev)
  98.     {
  99.         $totalPlayers = 0;
  100.         $maxPlayers = 0;
  101.         foreach ($this->server as $server) {
  102.             $server = explode(":", $server);
  103.             try {
  104.                 $this->Query->Connect($server[0], $server[1], $this->timeout);
  105.                 $array = ($this->Query->GetInfo());
  106.  
  107.                 $totalPlayers = $totalPlayers + $array['Players'];
  108.                 $maxPlayers = $maxPlayers + $array['MaxPlayers'];
  109.             } catch (MinecraftQueryException $e) {
  110.                 $this->getLogger()->critical($e->getMessage());
  111.             }
  112.         }
  113.         $localPlayersCount = count($this->getServer()->getOnlinePlayers());
  114.         $localMaxPlayerCount = $this->getServer()->getMaxPlayers();
  115.  
  116.         $ev->setPlayerCount($localPlayersCount + $totalPlayers);
  117.         $ev->setMaxPlayerCount($localMaxPlayerCount + $maxPlayers);
  118.  
  119.     }
  120.    
  121.  
  122.     public function bw($x, $y, $z, $yaw, $pitch, Level $World, $pro)
  123.     {
  124.     $level = $this->getServer()->getLevelByName("MainLobby");
  125.         $totalPlayers = 0;
  126.         $maxPlayers = 0;
  127.         foreach ($this->server5 as $server5) {
  128.             $server5 = explode(":", $server5);
  129.             try {
  130.                 $this->Query->Connect($server5[0], $server5[1], $this->timeout);
  131.                 $array = ($this->Query->GetInfo());
  132.  
  133.                 $totalPlayers = $totalPlayers + $array['Players'];
  134.                 $maxPlayers = $maxPlayers + $array['MaxPlayers'];
  135.             } catch (MinecraftQueryException $e) {
  136.                 $this->getLogger()->critical($e->getMessage());
  137.             }
  138.         }
  139.         $localPlayersCount = count($this->getServer()->getOnlinePlayers());
  140.         $localMaxPlayerCount = $this->getServer()->getMaxPlayers();
  141.  
  142.      
  143.     $nametag = "§l§4Bed§fWars §bBeta \n. players online: $totalPlayers";
  144.     $nbt = new CompoundTag("", [
  145.       "Pos" => new ListTag("Pos", [
  146.         new DoubleTag("", $x),
  147.         new DoubleTag("", $y),
  148.         new DoubleTag("", $z)
  149.       ]),
  150.       "Motion" => new ListTag("Motion", [
  151.         new DoubleTag("", 0),
  152.         new DoubleTag("", 0),
  153.         new DoubleTag("", 0)
  154.       ]),
  155.       "Rotation" => new ListTag("Rotation", [
  156.         new FloatTag("", $yaw),
  157.         new FloatTag("", $pitch)
  158.       ]),
  159.     ]);
  160.     $nbt->Health = new ShortTag("Health", 10);
  161.     $nbt->CustomName = new StringTag("CustomName", "§6players online ");
  162.     $World->loadChunk($x >> 4, $z >> 4);
  163.     $koylu = Entity::createEntity("Villager", $World, $nbt, "testuji ");
  164.     $koylu->setNameTag($nametag);
  165.     $koylu->setNameTagVisible(true);
  166.     $koylu->setNameTagAlwaysVisible(true);
  167.     $koylu->spawnToAll();
  168.    
  169.      
  170.     }
  171.    
  172.  
  173.    
  174.    
  175.       }
  176.      
  177.      
  178.  
  179.  
  180.  
  181.  
  182. <?php
  183.  
  184. namespace basprohop\Task;
  185.  
  186. use basprohop\CombinedSlots;
  187. use pocketmine\inventory\PlayerInventory;
  188. use pocketmine\item\Item;
  189. use pocketmine\Player;
  190. use pocketmine\scheduler\AsyncTask;
  191. use pocketmine\Server;
  192. use pocketmine\level\Level;
  193. use pocketmine\event\player\PlayerJoinEvent;
  194. use pocketmine\entity\Entity;
  195. use pocketmine\level\Position;
  196. use pocketmine\level\particle\FloatingTextParticle;
  197. use pocketmine\level\Position\getLevel;
  198. use pocketmine\nbt\tag\ByteTag;
  199. use pocketmine\nbt\tag\CompoundTag;
  200. use pocketmine\nbt\tag\DoubleTag;
  201. use pocketmine\nbt\tag\ListTag;
  202. use pocketmine\nbt\tag\FloatTag;
  203. use pocketmine\nbt\tag\ShortTag;
  204. use pocketmine\nbt\tag\StringTag;
  205.  
  206. class bwTask extends AsyncTask{
  207.  
  208.     public $items;
  209.     public $name;
  210.  
  211.     public function __construct(CombinedSlots $plugin, $items, $name) {
  212.         $this->items = $items;
  213.         $this->name = $name;
  214.        
  215.          $this->Query = new MinecraftQuery();
  216.         foreach($server5 as $server5){
  217.             $this->server5[]=$server5;
  218.         }
  219.  
  220.         $plugin->getServer()->getScheduler()->scheduleAsyncTask($this);
  221.     }
  222.  
  223.      public function bw($x, $y, $z, $yaw, $pitch, Level $World, $pro)
  224.     {
  225.     $level = $this->getServer()->getLevelByName("MainLobby");
  226.         $totalPlayers = 0;
  227.         $maxPlayers = 0;
  228.         foreach ($this->server5 as $server5) {
  229.             $server5 = explode(":", $server5);
  230.             try {
  231.                 $this->Query->Connect($server5[0], $server5[1], $this->timeout);
  232.                 $array = ($this->Query->GetInfo());
  233.  
  234.                 $totalPlayers = $totalPlayers + $array['Players'];
  235.                 $maxPlayers = $maxPlayers + $array['MaxPlayers'];
  236.             } catch (MinecraftQueryException $e) {
  237.                 $this->getLogger()->critical($e->getMessage());
  238.             }
  239.         }
  240.         $localPlayersCount = count($this->getServer()->getOnlinePlayers());
  241.         $localMaxPlayerCount = $this->getServer()->getMaxPlayers();
  242.  
  243.      
  244.     $nametag = "§l§4Bed§fWars §bBeta \n. players online: $totalPlayers";
  245.     $nbt = new CompoundTag("", [
  246.       "Pos" => new ListTag("Pos", [
  247.         new DoubleTag("", $x),
  248.         new DoubleTag("", $y),
  249.         new DoubleTag("", $z)
  250.       ]),
  251.       "Motion" => new ListTag("Motion", [
  252.         new DoubleTag("", 0),
  253.         new DoubleTag("", 0),
  254.         new DoubleTag("", 0)
  255.       ]),
  256.       "Rotation" => new ListTag("Rotation", [
  257.         new FloatTag("", $yaw),
  258.         new FloatTag("", $pitch)
  259.       ]),
  260.     ]);
  261.     $nbt->Health = new ShortTag("Health", 10);
  262.     $nbt->CustomName = new StringTag("CustomName", "§6players online ");
  263.     $World->loadChunk($x >> 4, $z >> 4);
  264.     $koylu = Entity::createEntity("Villager", $World, $nbt, "testuji ");
  265.     $koylu->setNameTag($nametag);
  266.     $koylu->setNameTagVisible(true);
  267.     $koylu->setNameTagAlwaysVisible(true);
  268.     $koylu->spawnToAll();
  269.    
  270.      
  271.     }
  272.    
  273.  
  274. }
RAW Paste Data
Top