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

Error with my plugin

Comments in 'Plugin Development' started by Skullex, Mar 5, 2016.

  1. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Ok, my plugin passed all the checks and stuff I'm pmt. I add it to my server and it gets disabled, I don't know why. My console is long so I'll put the error in a separate post after thi's so I can have time to find it. Please help me with any found errors here!!

    Thanks :)

    PHP:
    <?php

    namespace PvPTeamer;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;

    use 
    pocketmine\event\EntityDamageEvent;

    use 
    pocketmine\event\EntityDamageByEntityEvent;

    use 
    pocketmine\event\PlayerJoinEvent;

    use 
    pocketmine\event\PlayerQuitEvent;


    use 
    pocketmine\Server;


    class 
    PvPTeamer extends PluginBase implements Listener{

    function 
    onLoad(){
    $this->getLogger()->info("PvPTeamer Loaded!");
    }

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

    function 
    onDisable(){
    $this->getLogger()->info("PvPTeamer has been disabled");
    }

    function 
    onJoin(PlayerJoinEvent $e){
    $p $e->getPlayer();
    if(
    $p->loggedIn()){
      
    $n $p->getName();
      
    $a $this->a;
      
    $b $this->b;
      if(
    $a $b){
       
    $p->sendMessage("§f[§e§lSH§r§f]§7 You are on the §9A §7team!");
       
    $p->setNameTag("§9§l[A]§r".$n."");
       
    $p->setDisplayName("§9[A]§f".$n."");
       
    $this->$a 1;
    }elseif(
    $a $b){
       
    $p->sendMessage("§f[§e§lSH§r§f] §7You are on the §cB§7 team!");
       
    $p->setNameTag("§c§l[B]§r".$n."");
       
    $p->setDisplayName("§c[B]§f".$n."");
       
    $this->$b 1;
    }else{
       
    $p->sendMessage("§f[§e§lSH§r§f]§7 You are on the §9A§7 team!");
       
    $p->setNameTag("§9§l[A]§r".$n."");
       
    $p->setDisplayName("§9[A]§f".$n."");
       
    $this->$a 1;
      }
    }
    }

    function 
    onQuit(PlayerQuitEvent $e){
    $p $e->getPlayer();
    if(
    $p->LoggedIn){
      
    $t $p->getDisplayName();
      
    $a $this->a;
      
    $b $this->b;
      
    $aa explode("]",$t);
      
    $bb str_replace("[","",$aa[0]);
      if(
    $bb == "A"){
       
    $this->$a 1;
      }else{
       
    $this->$b 1;
      }
    }
    }

    function 
    onEntityDamage(EntityDamageEvent $event){
    $entity $event->getEntity();
    if(
    $entity instanceof Player && $event->getCause() == 1){
      if(
    $event->getDamager() instanceof Player){
       
    $p $event->getDamager()->getPlayer();
       
    $e $event->getEntity();
       
    $et $e->getDisplayName();
       
    $pt $p->getDisplayName();
       
    $pa explode("]",$pt);
       
    $pb str_replace("[","",$pa[0]);
       
    $ea explode("]",$et);
       
    $eb str_replace("[","",$ea[0]);
       if(
    $pb == "A" && $eb == "A"){
        
    $event->setCancelled(true);
       }elseif(
    $pb == "B" && $eb == "B"){
        
    $event->setCancelled(true);
       }
      }
    }
    }
    }
  2. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    The Error
    Code:
    ReflectionException: "Class pocketmine\event\PlayerJoinEvent does not exist" (EXCEPTION) in "/src/pocketmine/plugin/PluginManager" at line 728
    
  3. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Please check your use paths
    PlayerJoin event for example is
    use pocketmine\event\player\PlayerJoinEvent;
  4. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Lol we posted at the same time
  5. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Oh, wow XD <3 I got worried for nothing. Thanks so much! I don'tpay attenetion to the class's that much
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You actually didn't! xD Screenshot_2016-03-05-23-11-42.png
    applqpak likes this.
  7. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Ok, a few seconds
  8. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    New problem
    My plugin does absolutely nothing. When I type /plugins it's green "enabled, running" but nothing happens :/

    PHP:
    <?php

    /*
    * PVP Teams for StrongHold Beta
    * By Skull3x
    * <3 :DD
    * For kitpvp servers only!!
    */

    namespace PvPTeamer;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;

    use 
    pocketmine\event\entity\EntityDamageEvent;

    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;

    use 
    pocketmine\event\player\PlayerJoinEvent;

    use 
    pocketmine\event\player\PlayerQuitEvent;


    use 
    pocketmine\Server;


    class 
    PvPTeamer extends PluginBase implements Listener {

    function 
    onLoad(){
     
    $this->getLogger()->info("PvPTeamer Loaded!");
    }

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

    function 
    onDisable(){
    $this->getLogger()->info("PvPTeamer has been disabled");
    }

    function 
    onJoin(PlayerJoinEvent $event){
     
    $player $event->getPlayer();
     if(
    $player->loggedIn()){
      
    $name $player->getName();
      
    $a $this->a;
      
    $b $this->b;
      if(
    $a $b){
       
    $player->sendMessage("§f[§e§lSH§r§f]§7 You are on the §9A §7team!");
       
    $player->setNameTag("§9§l[A]§r".$name."");
       
    $player->setDisplayName("§9[A]§f".$name."");
       
    $this->$a 1;
     }elseif(
    $a $b){
       
    $player->sendMessage("§f[§e§lSH§r§f] §7You are on the §cB§7 team!");
       
    $player->setNameTag("§c§l[B]§r".$name."");
       
    $player->setDisplayName("§c[B]§f".$name."");
       
    $this->$b 1;
     }else{
       
    $player->sendMessage("§f[§e§lSH§r§f]§7 You are on the §9A§7 team!");
       
    $player->setNameTag("§9§l[A]§r".$name."");
       
    $player->setDisplayName("§9[A]§f".$name."");
       
    $this->$a 1;
      }
     }
    }

    function 
    onQuit(PlayerQuitEvent $event){
     
    $player $event->getPlayer();
     if(
    $player->LoggedIn()){
      
    $tag $player->getDisplayName();
      
    $a $this->a;
      
    $b $this->b;
      
    $aa explode("]",$tag);
      
    $bb str_replace("[","",$aa[0]);
      if(
    $bb == "A"){
       
    $this->$a 1;
      }else{
       
    $this->$b 1;
      }
     }
    }

    function 
    onEntityDamage(EntityDamageEvent $event){
     
    $entity $event->getEntity();
     if(
    $entity instanceof Player && $event->getCause() == 1){
      if(
    $event->getDamager() instanceof Player){
       
    $player $event->getDamager()->getPlayer();
       
    $entity $event->getEntity();
       
    $entity $event->getDisplayName();
       
    $playertag $player->getDisplayName();
       
    $pa explode("]",$playertag);
       
    $pb str_replace("[","",$pa[0]);
       
    $ea explode("]",$entity);
       
    $eb str_replace("[","",$ea[0]);
       if(
    $pb == "A" && $eb == "A"){
        
    $event->setCancelled(true);
       }elseif(
    $pb == "B" && $eb == "B"){
        
    $event->setCancelled(true);
       }
      }
     }
    }
    }
    ?>
  9. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Any errors?
  10. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    You should use an IDE. Your intentation is all wack.
    applqpak and Skullex like this.
  11. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Nope, but I'll check the console again
  12. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    No errors
  13. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    if($player->loggedIn()){ WTF is that for?
    CraftYourBukkit likes this.
  14. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Remove that
    Skullex likes this.
  15. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Off-Topic: This is OOP, no need for the PHP Closing Tag(?>). Also, use TextFormat instead of Color Codes.
    Skullex and applqpak like this.
  16. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Something that one of my friends added to the plugin :/ gave it a try

Share This Page

Advertisement