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

Why doesn't this plugin work?

Comments in 'Plugin Development' started by myst02, May 17, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
  2. myst02
    Offline

    myst02 Active Member

    Joined:
    Mar 23, 2015
    Posts:
    97
    Minecraft User:
    myst02
    Okay....looked through the code again and made changes....

    Now I get:
    2015-05-17 10:05:43 [EMERGENCY] An unrecoverable error has occurred and the server has crashed. Creating a crash dump
    2015-05-17 10:05:43 [EMERGENCY] Please submit the "/home/kjj/CrashDump_Sun_May_17-10.05.43-UTC_2015.log" file to the Bug Reporting page. Give as much info as you can.

    Plugin code:
    PHP:
    <?php

    namespace kjjnetwork\TwinPVP;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Server;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\event\block\SignChangeEvent;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\tile\Tile;

    class 
    Main extends PluginBase implements Listener{
      private 
    $api$server$path;

      public function 
    onEnable(){
      
    $this->getServer()->getPluginManager()->registerEvents($this$this);
      }

      public function 
    playerBlockTouch(PlayerInteractEvent $event){
      if(
    $event->getBlock()->getID() == 323 || $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68){
      
    $sign $event->getPlayer()->getLevel()->getTile($event->getBlock());
      if(!(
    $sign instanceof Sign)){
      return;
      }
      
    $sign $sign->getText();
      
    $players count($this->getServer()->getLevelByName("PVP")->getPlayers());
      
    $x "107";
      
    $y "76";
      
    $z "128";
      if(
    $sign[0]=='[PVP]'){
      if(
    $players <= 2){
      if(
    Server::getInstance()->loadLevel("PVP") != false){
      
    $event->getPlayer()->sendMessage("[server] teleporting you to arena...");
      
    $event->getPlayer()->teleport(new Position($x$y$z$this->getServer()->getLevelByName("PVP")));
      
      }else{
      
    $event->getPlayer()->sendMessage("[server] There are already two people in the arena!");
      }
      }
      }
      }
      }
    }
     

    Crash dump:
    Code:
    PocketMine-MP Crash Dump Sun May 17 10:05:43 UTC 2015
    
    Error: Call to a member function getPlayers() on null
    File: /TwinPVP/src/kjjnetwork/TwinPVP/Main
    Line: 35
    Type: E_ERROR
    
    THIS CRASH WAS CAUSED BY A PLUGIN
    BAD PLUGIN: TwinPVP v0.105
    
    Code:
    [26]  }
    [27]
    [28]  public function playerBlockTouch(PlayerInteractEvent $event){
    [29]  if($event->getBlock()->getID() == 323 || $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68){
    [30]  $sign = $event->getPlayer()->getLevel()->getTile($event->getBlock());
    [31]  if(!($sign instanceof Sign)){
    [32]  return;
    [33]  }
    [34]  $sign = $sign->getText();
    [35]  $players = count($this->getServer()->getLevelByName("PVP")->getPlayers());
    [36]  $x = "107";
    [37]  $y = "76";
    [38]  $z = "128";
    [39]  if($sign[0]=='[PVP]'){
    [40]  if($players <= 2){
    [41]  if(Server::getInstance()->loadLevel("PVP") != false){
    [42]  $event->getPlayer()->sendMessage("[server] teleporting you to arena...");
    [43]  $event->getPlayer()->teleport(new Position($x, $y, $z, $this->getServer()->getLevelByName("PVP")));
    [44]   
    [45]  }else{
    
    Backtrace:
    #0 (): pocketmine\Server->crashDump()
    
    PocketMine-MP version: 1.4.1 #980 [Protocol 20; API 1.11.0]
    Git commit: 0000000000000000000000000000000000000000
    uname -a: Linux ..... 3.2.41-042stab094.7 #1 SMP Wed Oct 22 12:43:21 MSK 2014 x86_64
    PHP Version: 5.6.6
    Zend version: 2.6.0
    OS : Linux, linux
    
    Loaded plugins:
    ...........
    Last edited: May 17, 2015
  3. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Hmm...
    Maybe to count players you must load the level on PocketMine first
  4. myst02
    Offline

    myst02 Active Member

    Joined:
    Mar 23, 2015
    Posts:
    97
    Minecraft User:
    myst02
    How does this work?
    Thanks for your patience with me, I'm stupid newbie ;)

    EDIT: THANK YOU!!!! NOW IT WORKS!!!!
    EvolSoft likes this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    • No need to define $api and $server and $path as private properties if you don't use them.
    • Block IDs are never greater than 255, so it won't be 323. Remove that check.
    • Use a proper IDE if you don't know programming. It teaches you a lot.
    EvolSoft likes this.

Share This Page

Advertisement