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

Crash on join command

Comments in 'Plugin Development' started by LoveToBeDev, Aug 23, 2015.

  1. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    Hello guys, please help me, i don't know where is the problem, thanks for the help by the way!

    PHP:
    case 'setpblobby':
                        
    $lobby = [
                            
    $sender->getX(),
                            
    $sender->getY(),
                            
    $sender->getZ()
                        ];
                        
    $this->getConfig()->set("pblobby"$lobby)[0];
                        
    $this->getConfig()->get("pblobby");
                        
    $this->getConfig()->save();
                        
    $sender->sendMessage(Color::GREEN."[Paintball] Lobby Saved Successfully!");
                        
    $sender->sendMessage(Color::RED."[Paintball] Remember that the lobby is only for spectators");
                        break;
                    case 
    'joinpblobby':
                        
    $lobbycor $this->getConfig()->get("pblobby");
                        
    $lobbyj = new Vector3($lobbycor[0], $lobbycor[1], $lobbycor[2]);
                        
    $sender->teleport($lobbyj);
                        break;
                    case 
    'setpbspawn1':
                        
    $sspawn = [
                            
    $sender->getX(),
                            
    $sender->getZ(),
                            
    $sender->getY()
                        ];
                        
    $this->getConfig()->set("pspawn"$sspawn)[1];
                        
    $this->getConfig()->get("pspawn");
                        
    $this->getConfig()->save();
                        
    $sender->sendMessage(Color::GREEN."[Paintball] Team 1 spawn set!");
                        break;
                    case 
    'setpbspawn2':
                        
    $sspawn2 = [
                            
    $sender->getX(),
                            
    $sender->getY(),
                            
    $sender->getZ()
                        ];
                        
    $this->getConfig()->get("pswpawn2"$sspawn2)[2];
                        
    $this->getConfig()->set("pspawn2"$sspawn2);
                        
    $this->getConfig()->save();
                        
    $sender->sendMessage(Color::GREEN."[Paintball] Team 2 spawn set!");
                        break;
                    case 
    'joinpb':
                        
    $random mt_rand(12);
                        
    $name $sender->getPlayer()->getName();
                        
    $coords $this->getConfig()->get("pspawn");
                        
    $coords2 $this->getConfig()->get("pspawn2");
                        
    $pos = new Vector3($coords[0], $coords[1], $coords[2]);
                        
    $pos2 = new Vector3($coords2[0], $coords2[1], $coords2[2]);
                        
    $items = [
                         
    Item::get(332016)
                        ];
                        if(
    $random == 1){
                            
    $sender->teleport($pos);
                            
    Server::getInstance()->broadcastMessage(Color::BLUE."$name Joined to team 1!");
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                        } else {
                            
    $sender->teleport($pos2);
                            
    Server::getInstance()->broadcastMessage(Color::RED."$name Joined to team 2!");
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                        }
                        break;
                }
            } else {
                
    $sender->sendMessage(Color::RED."please run command in game");
            }
        }
       
            public function 
    saveConfig(){
            if(
    $this->getConfig()->save() === false){
                
    $this->getLogger()->critical("Could not save config to " $this->configFile);
            }
        }
           
            public function 
    onPlayerInteract(PlayerInteractEvent $event){
                
    $player $event->getPlayer(); // Get player who touches the block
                
    $block $event->getItem(); // Get block that have been touches (including air)
                // $action = $event->getAction();
                
    if($block->getId() === 332){ // If touched block id is equal to stone
                // kill player
                
    $player->kill(); // or $player->setHealth(0);
    }
    }
           
       
    }
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Wow. You know how you could help? By posting the crash dump(if you know what a crash dump is).
  3. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    oh, sorry, the problem is here:

    i added the pocketmine\math\Vector3 on the file too, but it does not work. please help
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    You want to know how you could help even more? By posting full code.
  5. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    PHP:
    <?php

    namespace paintball\lovetobedev;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\utils\TextFormat as Color;
    use 
    pocketmine\maths\Vector3;

    class 
    Main extends PluginBase{
        public function 
    onEnable() {
            
    $this->getLogger()->info(Color::GREEN."Plugin Loaded!");
            
    $this->saveDefaultConfig();
        }
       
        public function 
    onDisable() {
            
    $this->getLogger()->info(Color::RED."Plugin Disabled");
        }
       
        public function 
    onCommand(\pocketmine\command\CommandSender $sender, \pocketmine\command\Command $command$label, array $args) {
            if(
    $sender instanceof Player){
                switch (
    strtolower($command->getName())){
                    case 
    'helppbs':
                        
    $sender->sendMessage(Color::GREEN."[Paintball]");
                        
    $sender->sendMessage(Color::LIGHT_PURPLE."/setpbspawn1");
                        
    $sender->sendMessage(Color::LIGHT_PURPLE."/setpbspawn2");
                        
    $sender->sendMessage(Color::LIGHT_PURPLE."/joinpb");
                        break;
                    case 
    'setpblobby':
                        
    $lobby = [
                            
    $sender->getX(),
                            
    $sender->getY(),
                            
    $sender->getZ()
                        ];
                        
    $this->getConfig()->set("pblobby"$lobby)[0];
                        
    $this->getConfig()->get("pblobby");
                        
    $this->getConfig()->save();
                        
    $sender->sendMessage(Color::GREEN."[Paintball] Lobby Saved Successfully!");
                        
    $sender->sendMessage(Color::RED."[Paintball] Remember that the lobby is only for spectators");
                        break;
                    case 
    'joinpblobby':
                        
    $lobbycor $this->getConfig()->get("pblobby");
                        
    $lobbyj = new Vector3($lobbycor[0], $lobbycor[1], $lobbycor[2]);
                        
    $sender->teleport($lobbyj);
                        break;
                    case 
    'setpbspawn1':
                        
    $sspawn = [
                            
    $sender->getX(),
                            
    $sender->getZ(),
                            
    $sender->getY()
                        ];
                        
    $this->getConfig()->set("pspawn"$sspawn)[1];
                        
    $this->getConfig()->get("pspawn");
                        
    $this->getConfig()->save();
                        
    $sender->sendMessage(Color::GREEN."[Paintball] Team 1 spawn set!");
                        break;
                    case 
    'setpbspawn2':
                        
    $sspawn2 = [
                            
    $sender->getX(),
                            
    $sender->getY(),
                            
    $sender->getZ()
                        ];
                        
    $this->getConfig()->get("pswpawn2"$sspawn2)[2];
                        
    $this->getConfig()->set("pspawn2"$sspawn2);
                        
    $this->getConfig()->save();
                        
    $sender->sendMessage(Color::GREEN."[Paintball] Team 2 spawn set!");
                        break;
                    case 
    'joinpb':
                        
    $random mt_rand(12);
                        
    $name $sender->getPlayer()->getName();
                        
    $coords $this->getConfig()->get("pspawn");
                        
    $coords2 $this->getConfig()->get("pspawn2");
                        
    $pos = new Vector3($coords[0], $coords[1], $coords[2]);
                        
    $pos2 = new Vector3($coords2[0], $coords2[1], $coords2[2]);
                        
    $items = [
                         
    Item::get(332016)
                        ];
                        if(
    $random == 1){
                            
    $sender->teleport($pos);
                            
    Server::getInstance()->broadcastMessage(Color::BLUE."$name Joined to team 1!");
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                        } else {
                            
    $sender->teleport($pos2);
                            
    Server::getInstance()->broadcastMessage(Color::RED."$name Joined to team 2!");
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                            
    $sender->getInventory()->addItem($items);
                        }
                        break;
                }
            } else {
                
    $sender->sendMessage(Color::RED."please run command in game");
            }
        }
       
            public function 
    saveConfig(){
            if(
    $this->getConfig()->save() === false){
                
    $this->getLogger()->critical("Could not save config to " $this->configFile);
            }
        }
           
            public function 
    onPlayerInteract(PlayerInteractEvent $event){
                
    $player $event->getPlayer(); // Get player who touches the block
                
    $block $event->getItem(); // Get block that have been touches (including air)
                // $action = $event->getAction();
                
    if($block->getId() === 332){ // If touched block id is equal to stone
                // kill player
                
    $player->kill(); // or $player->setHealth(0);
    }
    }
           
       
    }
  6. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Fix pocketmine\maths\Vector3 to pocketmine\math\Vector3.
    EvolSoft likes this.
  7. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    ok, now the problem is this one, im getting crazy :mad:

  8. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    PHP:
    use pocketmine\item\Item;
    EvolSoft likes this.
  9. LoveToBeDev
    Offline

    LoveToBeDev Active Member

    Joined:
    Aug 19, 2015
    Posts:
    55
    Minecraft User:
    LoveToBeDev
    LOVE YOU, THANKS!
    CrazedMiner likes this.

Share This Page

Advertisement