1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved What is the wrong in my plugin?

Discussion in 'Development' started by 7awariGamer, Sep 6, 2018.

  1. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    What is the wrong in this code??
    PHP:
    <?php
    /*this is a special way to show your server info to the players !
    by 7awariGamer !!
    */
    namespace info;

    use 
    pocketmine\event\inventory\InventoryOpenEvent;
    use 
    pocketmine\event\inventory\InventoryTransactionEvent;
    use 
    pocketmine\event\player\PlayerExhaustEvent;
    use 
    pocketmine\level\Location;
    use 
    pocketmine\level\particle\BubbleParticle;
    use 
    pocketmine\level\particle\ExplodeParticle;
    use 
    pocketmine\level\particle\HeartParticle;
    use 
    pocketmine\level\particle\HugeExplodeParticle;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\event\entity\ProjectileLaunchEvent;
    use 
    pocketmine\utils\Terminal;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\event\player\PlayerDropItemEvent;
    use 
    pocketmine\event\inventory\InventoryPickupItemEvent;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\Player;
    use 
    pocketmine\entity\Effect;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\entity\Item as ItemEntity;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\math\Vector2;
    use 
    pocketmine\level\particle\DustParticle;
    use 
    pocketmine\level\particle\FlameParticle;
    use 
    pocketmine\level\particle\RedstoneParticle;
    use 
    pocketmine\level\particle\LavaParticle;
    use 
    pocketmine\level\particle\PortalParticle;
    use 
    pocketmine\level\sound\PopSound;
    use 
    pocketmine\level\sound\GhastSound;
    use 
    pocketmine\event\player\PlayerPreLoginEvent;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\event\player\PlayerCommandPreprocessEvent;
    use 
    PowerNick\NickAPI\NickAPI;
    use 
    PowerNick\PowerNick;

    class 
    Main extends PluginBase implements Listener{

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->rgisterEvents($this$this);
            
    $this->getLogger()->Info("the ppppp enabled LOL");
            
    $this->getScheduler()->scheduleRepeatingTask(new ItemsLoad($this), 10);
            
    $this->getScheduler()->scheduleRepeatingTask(new TypeType($this), 20);
            
    $this->getServer()->getNetwork()->setName(TextFormat::BOLD TextFormat::GREEN "MineLegends");
            
    $this->getServer()->getDefaultLevel()->setTime(1000);
            
    $this->getServer()->getDefaultLevel()->stopTime();



        }

        public function 
    onDesable(){
            
    $this->getLogger()->Info("the ppppp has fucking error LOL");
        }

        public function 
    onJoin(PlayerJoinEvent $ev) {

            
    $player->getInventory()->setItem(1Item::get(330)->setCustomName("§l§1Info"));
        }

        public function 
    onCommand(CommandSender $senderCommand $cmdstring $label , array $args){
            if(
    $sender instanceof Player){
               switch(
    $cmd->getName()){
                  case 
    "hub";
                      
    $item Item::get(330,0,1);
                      
    $inv $sender->getInventory();
                      
    $item->setCustomName("§l§1Info");
                      
    $inv->addItem($item);
                  case 
    "lobby";
                      
    $item Item::get(330,0,1);
                      
    $inv $sender->getInventory();
                      
    $item->setCustomName("§l§1Info");
                      
    $inv->addItem($item);
                      return 
    true;
                }
            }

        }

        public function 
    onInteract(PlayerInteractEvent $event)
        {
                
    $player $event->getPlayer();
                
    $name $player->getName();
                
    $in $event->getPlayer()->getInventory()->getItemInHand()->getCustomName();
                
    $inv $player->getInventory();
                
    $blockid $event->getBlock()->getID();
                
    $block $event->getBlock();
                
    $config = new Config($this->getDataFolder() . "config.yml"Config::YAML);

            if (
    $in == "§l§1Info") {
                        
    $this->getServer()->dispatchCommand($event->getPlayer(), "");


          }

    }
    }

     
    ?>
     
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    PHP:
    <?php
    /*this is a special way to show your server info to the players !
    by 7awariGamer !!
    */
    namespace info;

    use 
    pocketmine\event\inventory\InventoryOpenEvent;
    use 
    pocketmine\event\inventory\InventoryTransactionEvent;
    use 
    pocketmine\event\player\PlayerExhaustEvent;
    use 
    pocketmine\level\Location;
    use 
    pocketmine\level\particle\BubbleParticle;
    use 
    pocketmine\level\particle\ExplodeParticle;
    use 
    pocketmine\level\particle\HeartParticle;
    use 
    pocketmine\level\particle\HugeExplodeParticle;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\event\entity\ProjectileLaunchEvent;
    use 
    pocketmine\utils\Terminal;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\event\player\PlayerDropItemEvent;
    use 
    pocketmine\event\inventory\InventoryPickupItemEvent;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\Player;
    use 
    pocketmine\entity\Effect;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\entity\Item as ItemEntity;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\math\Vector2;
    use 
    pocketmine\level\particle\DustParticle;
    use 
    pocketmine\level\particle\FlameParticle;
    use 
    pocketmine\level\particle\RedstoneParticle;
    use 
    pocketmine\level\particle\LavaParticle;
    use 
    pocketmine\level\particle\PortalParticle;
    use 
    pocketmine\level\sound\PopSound;
    use 
    pocketmine\level\sound\GhastSound;
    use 
    pocketmine\event\player\PlayerPreLoginEvent;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\event\player\PlayerCommandPreprocessEvent;
    use 
    PowerNick\NickAPI\NickAPI;
    use 
    PowerNick\PowerNick;

    class 
    Main extends PluginBase implements Listener
    {
        
        public function 
    onEnable()
        {
            
    $this->getServer()->getPluginManager()->rgisterEvents($this$this);
            
    $this->getLogger()->Info("the ppppp enabled LOL");
            
    //$this->getScheduler()->scheduleRepeatingTask(new ItemsLoad($this), 10);
            //$this->getScheduler()->scheduleRepeatingTask(new TypeType($this), 20);
            
    $this->getServer()->getNetwork()->setName(TextFormat::BOLD TextFormat::GREEN "MineLegends");
            
    $this->getServer()->getDefaultLevel()->setTime(1000);
            
    $this->getServer()->getDefaultLevel()->stopTime();
            
            
            
        }
        
        public function 
    onDisable()
        {
            
    $this->getLogger()->Info("the ppppp has fucking error LOL");
        }
        
        public function 
    onJoin(PlayerJoinEvent $ev)
        {
            
            
    $player->getInventory()->setItem(1Item::get(330)->setCustomName("§l§1Info"));
        }
        
        public function 
    onCommand(CommandSender $senderCommand $cmdstring $label, array $args)
        {
            if (
    $sender instanceof Player) {
                switch (
    $cmd->getName()) {
                    case 
    "hub";
                        
    $item Item::get(33001);
                        
    $inv  $sender->getInventory();
                        
    $item->setCustomName("§l§1Info");
                        
    $inv->addItem($item);
                        break;
                    case 
    "lobby";
                        
    $item Item::get(33001);
                        
    $inv  $sender->getInventory();
                        
    $item->setCustomName("§l§1Info");
                        
    $inv->addItem($item);
                        break;
                }
            }
            return 
    true;
        }
        
        public function 
    onInteract(PlayerInteractEvent $event)
        {
            
    $player $event->getPlayer();
            
    $name $player->getName();
            
    $in $event->getPlayer()->getInventory()->getItemInHand()->getCustomName();
            
    $inv $player->getInventory();
            
    $blockid $event->getBlock()->getID();
            
    $block $event->getBlock();
            
    $config = new Config($this->getDataFolder() . "config.yml"Config::YAML);
            
            if (
    $in == "§l§1Info") {
                
    $this->getServer()->dispatchCommand($event->getPlayer(), "");
            }
        }
    }
    A lot of useless imported classes by the way, but this should work.
     
  3. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    Ok lol I will try it
     
  4. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    No your code is wrong !
    my code is true but the cosole say there is a mistake in line56
     
  5. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Send 56
     
    OnTheVerge likes this.
  6. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    we are not your personal debugger
    no error code or description = no help
     
  7. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    My code is there up
     
  8. 7awariGamer

    7awariGamer Baby Zombie

    Messages:
    120
    GitHub:
    7awariGamer
    That's my code
    PHP:
    <?php
    /*this is a special way to show your server info to the players !
    by 7awariGamer !!
    */
    namespace info;

    use 
    pocketmine\event\inventory\InventoryOpenEvent;
    use 
    pocketmine\event\inventory\InventoryTransactionEvent;
    use 
    pocketmine\event\player\PlayerExhaustEvent;
    use 
    pocketmine\level\Location;
    use 
    pocketmine\level\particle\BubbleParticle;
    use 
    pocketmine\level\particle\ExplodeParticle;
    use 
    pocketmine\level\particle\HeartParticle;
    use 
    pocketmine\level\particle\HugeExplodeParticle;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\event\entity\ProjectileLaunchEvent;
    use 
    pocketmine\utils\Terminal;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\event\player\PlayerDropItemEvent;
    use 
    pocketmine\event\inventory\InventoryPickupItemEvent;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\Player;
    use 
    pocketmine\entity\Effect;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\entity\Item as ItemEntity;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\math\Vector2;
    use 
    pocketmine\level\particle\DustParticle;
    use 
    pocketmine\level\particle\FlameParticle;
    use 
    pocketmine\level\particle\RedstoneParticle;
    use 
    pocketmine\level\particle\LavaParticle;
    use 
    pocketmine\level\particle\PortalParticle;
    use 
    pocketmine\level\sound\PopSound;
    use 
    pocketmine\level\sound\GhastSound;
    use 
    pocketmine\event\player\PlayerPreLoginEvent;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\event\player\PlayerCommandPreprocessEvent;
    use 
    PowerNick\NickAPI\NickAPI;
    use 
    PowerNick\PowerNick;

    class 
    Main extends PluginBase implements Listener{

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->rgisterEvents($this$this);
            
    $this->getLogger()->Info("the ppppp enabled LOL");
            
    $this->getScheduler()->scheduleRepeatingTask(new ItemsLoad($this), 10);
            
    $this->getScheduler()->scheduleRepeatingTask(new TypeType($this), 20);
            
    $this->getServer()->getNetwork()->setName(TextFormat::BOLD TextFormat::GREEN "MineLegends");
            
    $this->getServer()->getDefaultLevel()->setTime(1000);
            
    $this->getServer()->getDefaultLevel()->stopTime();



        }

        public function 
    onDesable(){
            
    $this->getLogger()->Info("the ppppp has fucking error LOL");
        }

        public function 
    onJoin(PlayerJoinEvent $ev) {

            
    $player->getInventory()->setItem(1Item::get(330)->setCustomName("§l§1Info"));
        }

        public function 
    onCommand(CommandSender $senderCommand $cmdstring $label , array $args){
            if(
    $sender instanceof Player){
               switch(
    $cmd->getName()){
                  case 
    "hub";
                      
    $item Item::get(330,0,1);
                      
    $inv $sender->getInventory();
                      
    $item->setCustomName("§l§1Info");
                      
    $inv->addItem($item);
                  case 
    "lobby";
                      
    $item Item::get(330,0,1);
                      
    $inv $sender->getInventory();
                      
    $item->setCustomName("§l§1Info");
                      
    $inv->addItem($item);
                      return 
    true;
                }
            }

        }

        public function 
    onInteract(PlayerInteractEvent $event)
        {
                
    $player $event->getPlayer();
                
    $name $player->getName();
                
    $in $event->getPlayer()->getInventory()->getItemInHand()->getCustomName();
                
    $inv $player->getInventory();
                
    $blockid $event->getBlock()->getID();
                
    $block $event->getBlock();
                
    $config = new Config($this->getDataFolder() . "config.yml"Config::YAML);

            if (
    $in == "§l§1Info") {
                        
    $this->getServer()->dispatchCommand($event->getPlayer(), "");


          }

    }
    }

     
    ?>
     
  9. RyanShaw

    RyanShaw Witch

    Messages:
    69
    Please work with the people who are trying to help you, show us the error and point out line 56.
    PHP:
        public function onJoin(PlayerJoinEvent $ev) {

            
    $player->getInventory()->setItem(1Item::get(330)->setCustomName("§l§1Info"));
        }
    You forgot to define $player here
    PHP:
    public function onCommand(CommandSender $senderCommand $cmdstring $label , array $args){
    You also forgot to add :bool to your onCommand function
     
    OnTheVerge and EdwardHamHam like this.
  10. FunnyBuddys

    FunnyBuddys Spider

    Messages:
    14
    GitHub:
    FunnyBuddys
    I was so kind, and have removed the spelling mistakes, the unnecessary statements and spaces, as well as fixed your bugs. Have fun with it.

    PHP:
    <?php
    /*this is a special way to show your server info to the players !
    by 7awariGamer !!
    */
    namespace info;

    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\Player;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\math\Vector3;
    use 
    PowerNick\NickAPI\NickAPI;
    use 
    PowerNick\PowerNick;

    class 
    Main extends PluginBase implements Listener{

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getLogger()->Info("the ppppp enabled LOL");
            
    $this->getScheduler()->scheduleRepeatingTask(new ItemsLoad($this), 10);
            
    $this->getScheduler()->scheduleRepeatingTask(new TypeType($this), 20);
            
    $this->getServer()->getNetwork()->setName(TextFormat::BOLD TextFormat::GREEN "MineLegends");
            
    $this->getServer()->getDefaultLevel()->setTime(1000);
            
    $this->getServer()->getDefaultLevel()->stopTime();
        }

        public function 
    onDisable(){
            
    $this->getLogger()->Info("the ppppp has fucking error LOL");
        }

        public function 
    onJoin(PlayerJoinEvent $ev) {
            
    $player $ev->getPlayer();
            
    $player->getInventory()->setItem(1Item::get(330)->setCustomName("§l§1Info"));
        }

        public function 
    onCommand(CommandSender $senderCommand $cmdstring $label, array $args) : bool {
            if(
    $sender instanceof Player){
                switch(
    $cmd->getName()){
                    case 
    "hub";
                        
    $item Item::get(330,0,1);
                        
    $inv $sender->getInventory();
                        
    $item->setCustomName("§l§1Info");
                        
    $inv->addItem($item);
                        return 
    true;
                    case 
    "lobby";
                        
    $item Item::get(330,0,1);
                        
    $inv $sender->getInventory();
                        
    $item->setCustomName("§l§1Info");
                        
    $inv->addItem($item);
                        return 
    true;
                }
            }
            return 
    true;
        }
        public function 
    onInteract(PlayerInteractEvent $event) {
            
    $player $event->getPlayer();
            
    $in $player->getInventory()->getItemInHand()->getCustomName();
            if (
    $in == "§l§1Info") {
                
    $this->getServer()->dispatchCommand($player"");
            }
        }
    }
     
  11. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Sends 56 only :facepalm: not full code
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.