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

Config problems :/

Comments in 'Plugin Development' started by WitherTube, May 22, 2016.

  1. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    Hello
    when i started yesterday my plugin it didn't start and this error came out .
    PHP:
    [Server thread/ERROR]: Could not load 'C:\Users\Mouad\Desktop\PocketMine-MP\plugins\JumpKill' in folder 'C:\Users\Mouad\Desktop\PocketMine-MP\plugins\': yaml_parse(): scanning error encountered during parsing: mapping values are not allowed in this context (line 16, column 17)
    [23:13:54] [Server thread/WARNING]: RuntimeException: "yaml_parse(): scanning error encountered during parsing: mapping values are not allowed in this context (line 16, column 17)" (E_WARNING) in "/src/pocketmine/plugin/PluginDescription" at line 51
    [23:13:54] [Server thread/INFO]: Loading DevTools v1.10.0
    [23:13:54] [Server thread/INFO]: Enabling DevTools v1.10.0
    [23:13:54] [Server thread/ERROR]: Could not load '
    C:\Users\Mouad\Desktop\PocketMine-MP\plugins\JumpKill' in folder 'C:\Users\Mouad\Desktop\PocketMine-MP\plugins\': yaml_parse(): scanning error encountered during parsing: mapping values are not allowed in this context (line 16, column 17)
    [23:13:54] [Server thread/WARNING]: RuntimeException: "yaml_parse(): scanning error encountered during parsing: mapping values are not allowed in this context (line 16, column 17)" (E_WARNING) in "/src/pocketmine/plugin/PluginDescription" at line 51
    Here is my written plugin :
    PHP:
    /*
    *
    *
    * _ _ _____ __ __ _____ _____ _____ __ __ ______ ______
    * | | | |(_)|__ __|| | | || ___|| \ |__ __|| | | | | __ || _____|
    * | | | || | | | | |_| || |___ | (__) \ | | | | | | | |__|_|| |____
    * | |____| || | | | | _ || ___|| | | | | | | | | __ || ____|
    * | __ || | | | | | | || |___ | | \ | | | | |_| | | |__| || |____
    * |__/ \__||_| |_| |__| |_ ||_____||__| \_| |_| |_______| |______||______|
    * This plugin was made by WitherTube :D.
    * It was published on PocketMine-Forum , GitHub or Twitter ^^.
    * For upcoming News follow me on Twitter and maybe subscribe my channel :D.
    *
    *
    * @author WitherTube
    * @link Twitter : https://twitter.com/WitherDevPE
    * @link YouTube : https://www.youtube.com/channel/UCBcXzwKx27T1OEXCU9_NZiQ
    * @link Pocketmine : https://forums.pocketmine.net/members/withertube.40392/
    * @link GitHub : It is disabled :(
    *
    */

    namespace WitherTube ;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\event\Cancellable;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\event\SignChangeEvent;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\utils\Config;

    class 
    JumpKill extends PluginBase implements Listener {

    public 
    $prefix "[Jump" TextFormat::RED "Kill]";

    public 
    $arenas = array();

    public 
    $x1;
    public 
    $x2;
    public 
    $x3;
    public 
    $x4;
    public 
    $x5;

    public 
    $y1;
    public 
    $y2;
    public 
    $y3;
    public 
    $y4;
    public 
    $y5;

    public 
    $z1;
    public 
    $z2;
    public 
    $z3;
    public 
    $z4;
    public 
    $z5;


    public function 
    onEnable()
    {
    $this->getServer()->getPluginManager()->registerEvents($this $this);
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new RefreshSings($this) , 30);
    $this->getLogger()->info($this->prefix " wurde aktiviert");
    @
    mkdir($this->getDataFolder());
    $config = new Config ($this->getDataFolder() . "config.yml" Config::YAML);


    if(empty(
    $config->get("X1"))){
    $config->set("X1" 000);
    }
    if(empty(
    $config->get("X2"))){
    $config->set("X2" 000);
    }

    if(empty(
    $config->get("X3"))){
    $config->set("X3" 000);
    }

    if(empty(
    $config->get("X4"))){
    $config->set("X4" 000);
    }

    if(empty(
    $config->get("X5"))){
    $config->set("X5" 000);
    }

    if(empty(
    $config->get("Y1"))){
    $config->set("Y1" 000);
    }

    if(empty(
    $config->get("Y2"))){
    $config->set("Y2" 000);
    }

    if(empty(
    $config->get("Y3"))){
    $config->set("Y3" 000);
    }

    if(empty(
    $config->get("Y4"))){
    $config->set("Y4" 000);
    }

    if(empty(
    $config->get("Y5"))){
    $config->set("Y5" 000);
    }

    if(empty(
    $config->get("Z1"))){
    $config->set("Z1" 000);
    }

    if(empty(
    $config->get("Z2"))){
    $config->set("Z2" 000);
    }

    if(empty(
    $config->get("Z3"))){
    $config->set("Z3" 000);
    }

    if(empty(
    $config->get("Z4"))){
    $config->set("Z4" 000);
    }

    if(empty(
    $config->get("Z5"))){
    $config->set("Z5" 000);
    }
    $x1 $config->get("X1");
    $x2 $config->get("X2");
    $x3 $config->get("X3");
    $x4 $config->get("X4");
    $x5 $config->get("X5");

    $y1 $config->get("Y1");
    $y2 $config->get("Y2");
    $y3 $config->get("Y3");
    $y4 $config->get("Y4");
    $y5 $config->get("Y5");

    $z1 $config->get("Z1");
    $z2 $config->get("Z2");
    $z3 $config->get("Z3");
    $z4 $config->get("Z4");
    $z5 $config->get("Z5");

    }
    public function 
    Met()
    {
    $players $this->getServer()->getOnlinePlayers();
    foreach(
    $players as $player)
    {
    $player[0]->teleport(new position($this->x1 $this->y1 $this->z1) ;
    $player[1]->teleport(new position($this->x2 $this->y2 $this->z2) ;
    $player[2]->teleport(new position($this->x3 $this->y3 $this->z3) ;
    $player[3]->teleport(new position($this->x4 $this->y4 $this->z4) ;
    $player[4]->teleport(new position($this->x5 $this->y5 $this->z5) ;
    }
    }
    public function 
    onJoin(PlayerJoinEvent $event)
    {
    $players $event->getServer()->getOnlinePLayer();
    $choosenplayer $players[array_rand($players)] ;
    $item item::get(276);
    foreach (
    $players as $player )
    {
    if(!
    $player==$choosenplayer)
    {
    $player->getInventory()->addItem($item);

    $id 8;

    $amplifier 3;

    $visibility false;

    $duration =0x7fffffff;

    $effect Effect::getEffect($id);

    $effect->setVisible($visibility);

    $effect->setDuration($duration);

    $effect->setAmplifier($amplifier);

    $choosenplayer->addEffect($effect);
    }

    public function 
    onMove(PlayerMoveEvent $event)
    {
    $players $this->getServer()->getOnlinePlayers();
    $choosenplayer $players[array_rand($players)];
    $this->getServer()->broadcastMessage($this->prefix " Spieler " $choosenplayer->getName() . " ist jetzt das Opfer , schnappt ihn euch !");
    }
    if (
    $players 5)
    {
    $event->setCancelled(true);
    }
    else
    {
    $event->setCancelled(false);
    }
    public function 
    onAttack(EntityDamageEvent $event)
    {
    $victim $event->getEntity();
    foreach(
    $this->players as $player)
    {
    if(
    $this->choosenplayer==$victim)
    {
    $event->setCancelled(true);
    }
    else
    {
    $event->setCancelled(false);
    }
    }
    }
    }
  2. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    And for all who think that my name is "Mouad" it is a nickname :p
  3. Intyre
    Offline

    Intyre Staff Member PocketMine Team

    Joined:
    Aug 24, 2013
    Posts:
    118
    Minecraft User:
    Intyre
    Before you start with programming you should first learn how to use Google.
    - http://bfy.tw/5tbm
    - http://php.net/manual/en/control-structures.elseif.php
    - http://php.net/manual/en/control-structures.foreach.php

    What where you thinking when you wrote this?
    Code:
    foreach($players as $player){
        $player[0]->teleport(new position($this->x1 , $this->y1 , $this->z1) ;
        $player[1]->teleport(new position($this->x2 , $this->y2 , $this->z2) ;
        $player[2]->teleport(new position($this->x3 , $this->y3 , $this->z3) ;
        $player[3]->teleport(new position($this->x4 , $this->y4 , $this->z4) ;
        $player[4]->teleport(new position($this->x5 , $this->y5 , $this->z5) ;
    }
    
    Bad practice! Don't use the numerical ID because ID's can change and then your plugin won't work anymore.
    Code:
    $item = item::get(276);
    
    What where you thinking?
    Code:
    if(!$player==$choosenplayer)
    
    This is just a selection of all the weirdness in your plugin. Keep in mind that YOU are writing a plugin so YOU also need to put some effort into it.
  4. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Firstly, please learn proper (OO-)PHP, and the PocketMine API.

    Secondly, You're attempting to make a new Position, when you haven't even used it... How does the PHP interpreter know what / where the Position class is, if you haven't used It? It's like you walk into a Lolly shop and simply say "I want that Lolly!", how the shop clerk supposed to know which Lolly you're talking about? And, BTW, it is:
    PHP:
    new Position();
    And, not:
    PHP:
    new position();
    Thirdly, why are you using a foreach loop then having $player[x]->teleport()? I hope you know foreach splits up an array. So why are you trying to access the player variable as an array?

    Fourthly, there is too many issues with your code, please refer to my first point! :D
    jojoe77777, WitherTube and Vaivez66 like this.
  5. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    1. I want to teleport each player to a position.
    2. How i can make it without ID ?
    3. There is a random player and i want to say if those player aren't the choosenplayer they get weapons.
    Thanks for the wisdom :D
  6. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    Thank you i will discard the whole plugin and start from the beginning :D
    applqpak likes this.
  7. Mat
    Offline

    Mat Active Member Plugin Developer

    Joined:
    Jun 15, 2014
    Posts:
    179
    Plugins:
    1
    Minecraft User:
    matcracker
    1. Remove array syntax, so $player->teleport(); and not $player[0]->teleport();
    2. Use Item::BLOCK_NAME
    3. Use $player !== $choosenplayer
    WitherTube and applqpak like this.
  8. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    Thanks i will do this and then post the plugin :D
    but to the first point i want to say that i want to teleport each player to a position,
    Last edited: May 24, 2016
  9. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    That's what foreach already does!
  10. Mat
    Offline

    Mat Active Member Plugin Developer

    Joined:
    Jun 15, 2014
    Posts:
    179
    Plugins:
    1
    Minecraft User:
    matcracker
    PHP:
    foreach($players as $player){
           
    $player->teleport(new Position($x$y$z));
    }
    This teleports all the players that are in "players" array.[/CODE]
    Last edited: May 25, 2016
    applqpak likes this.
  11. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    I founded the method to teleport the players :
    PHP:
    $pos = [new Position($this->x1 $this->y1 $this->z1), new Positon($this->x2 $this->y2 $this->z2), new Position($this->x3 $this->y3 $this->z3)];
    $c 0;
    foreach(
    $this->getServer()->getOnlinePlayers() as $p){
    $p->teleport($pos[$c]);
    $c++
    Thank you !
  12. Mat
    Offline

    Mat Active Member Plugin Developer

    Joined:
    Jun 15, 2014
    Posts:
    179
    Plugins:
    1
    Minecraft User:
    matcracker
    Wtf, use this, it's better..
    PHP:
    foreach($this->getServer()->getOnlinePlayers() as $p)
         
    $p->teleport($this->x3 $this->y3 $this->z3);
  13. WitherTube
    Offline

    WitherTube New Member

    Joined:
    Dec 21, 2015
    Posts:
    44
    Minecraft User:
    Wither_Tube
    There is a new problem with the same error message like before .
    I searched it in google but it didn't solve my problem :/
    PHP:
    /**** _ _ _____ __ __ _____ _____ _____ __ __ ______ ______* | | | |(_)|__ __|| | | || ___|| \ |__ __|| | | | | __ || _____|* | | | || | | | | |_| || |___ | (__) \ | | | | | | | |__|_|| |____* | |____| || | | | | _ || ___|| | | | | | | | | __ || ____|* | __ || | | | | | | || |___ | | \ | | | | |_| | | |__| || |____* |__/ \__||_| |_| |__| |_ ||_____||__| \_| |_| |_______| |______||______|* This plugin was made by WitherTube :D.* It was published on PocketMine-Forum , GitHub or Twitter ^^.* For upcoming News follow me on Twitter and maybe subscribe my channel :D.*** @author WitherTube* @link Twitter : https://twitter.com/WitherDevPE* @link YouTube : https://www.youtube.com/channel/UCBcXzwKx27T1OEXCU9_NZiQ* @link Pocketmine : https://forums.pocketmine.net/members/withertube.40392/* @link GitHub : It is disabled :(**/namespace WitherTube ;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\utils\TextFormat;use pocketmine\event\player\PlayerMoveEvent;use pocketmine\event\Cancellable;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\item\Item;use pocketmine\tile\Sign;use pocketmine\event\SignChangeEvent;use pocketmine\scheduler\PluginTask;use pocketmine\utils\Config;class JumpKill extends PluginBase implements Listener {public $prefix "[Jump" TextFormat::RED "Kill]";public $arenas = array();public $x1;public $x2;public $x3;public $x4;public $x5;public $y1;public $y2;public $y3;public $y4;public $y5;public $z1;public $z2;public $z3;public $z4;public $z5;public function onEnable(){$this->getServer()->getPluginManager()->registerEvents($this $this);$this->getServer()->getScheduler()->scheduleRepeatingTask(new RefreshSings($this) , 30);$this->getLogger()->info($this->prefix " wurde aktiviert");@mkdir($this->getDataFolder());$config = new Config ($this->getDataFolder() . "config.yml" Config::YAML);if(empty($config->get("X1"))){ $config->set("X1" 000);}if(empty($config->get("X2"))){ $config->set("X2" 000);}if(empty($config->get("X3"))){$config->set("X3" 000);}if(empty($config->get("X4"))){$config->set("X4" 000);}if(empty($config->get("X5"))){$config->set("X5" 000);}if(empty($config->get("Y1"))){$config->set("Y1" 000);}if(empty($config->get("Y2"))){$config->set("Y2" 000);}if(empty($config->get("Y3"))){$config->set("Y3" 000);}if(empty($config->get("Y4"))){$config->set("Y4" 000);}if(empty($config->get("Y5"))){$config->set("Y5" 000);}if(empty($config->get("Z1"))){$config->set("Z1" 000);}if(empty($config->get("Z2"))){$config->set("Z2" 000);}if(empty($config->get("Z3"))){$config->set("Z3" 000);}if(empty($config->get("Z4"))){$config->set("Z4" 000);}if(empty($config->get("Z5"))){$config->set("Z5" 000);}$x1 $config->get("X1");$x2 $config->get("X2");$x3 $config->get("X3");$x4 $config->get("X4");$x5 $config->get("X5");$y1 $config->get("Y1");$y2 $config->get("Y2");$y3 $config->get("Y3");$y4 $config->get("Y4");$y5 $config->get("Y5");$z1 $config->get("Z1");$z2 $config->get("Z2");$z3 $config->get("Z3");$z4 $config->get("Z4");$z5 $config->get("Z5");}public function Met(){$players $this->getServer()->getOnlinePlayers();foreach($players as $p){$pos = [new Position($this->x1 $this->y1 $this->z1) , new Position($this->x2 $this->y2 $this->z2) , new Position($this->x3 $this->y3 $this->z3), new Position($this->x4 $this->y4 $this->z4) ,new Position($this->x5 $this->y5 $this->z5) ]}}public function onJoin(PlayerJoinEvent $event){$players $event->getServer()->getOnlinePLayer();$choosenplayer $players[array_rand($players)] ;$item Item::DIAMOND_SWORD;foreach ($players as $player ){if($player!==$choosenplayer){$player->getInventory()->addItem($item);$id 8;$amplifier 3;$visibility false;$duration =0x7fffffff;$effect Effect::getEffect($id);$effect->setVisible($visibility);$effect->setDuration($duration);$effect->setAmplifier($amplifier);$choosenplayer->addEffect($effect);}public function onMove(PlayerMoveEvent $event){$players $this->getServer()->getOnlinePlayers();$choosenplayer $players[array_rand($players)];$this->getServer()->broadcastMessage($this->prefix " Spieler " $choosenplayer->getName() . " ist jetzt das Opfer , schnappt ihn euch !");}if ($players 5){$event->setCancelled(true);}else{$event->setCancelled(false);}public function onAttack(EntityDamageEvent $event){$victim $event->getEntity();foreach($this->players as $player){if($this->choosenplayer==$victim){$event->setCancelled(true);}else{$event->setCancelled(false);}}}}
    Last edited: May 28, 2016

Share This Page

Advertisement