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

My plugin stops running

Discussion in 'Development' started by MalakasPlayzMC, Apr 13, 2017.

  1. MalakasPlayzMC

    MalakasPlayzMC Spider Jockey

    Messages:
    37
    I have a plugin named Core and it is crashing for an unknown reason. The error I get is:
    Code:
    2017-04-13 [09:20:06] [Server thread/CRITICAL]: ParseError: "syntax error, unexpected public (T_PUBLIC)" (EXCEPTION) in "myzip:///Core.zip#src/Core/Main" at line 110
    Code of the plugin:
    PHP:
    <?php

    namespace Core;

    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\level\particle\FlameParticle;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\math\Vector2;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\nbt\tag\IntTag;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\utils\TextFormat as C;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\event\player\PlayerChatEvent;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\event\player\PlayerItemHeldEvent;
    use 
    pocketmine\event\player\PlayerDropItemEvent;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\event\entity\EntityTeleportEvent;

    class 
    Main extends PluginBase implements Listener {
        
        public 
    $prefix TextFormat::GRAY."[".TextFormat::AQUA."Lobby".TextFormat::GRAY."] ";

        public function 
    onEnable(){
            
    $this->getLogger()->info($this->prefix.C::GREEN."Enabled!");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new Scoreboard($this), 20);
        }

        public function 
    MainItems(Player $player){
            
    $player->getInventory()->clearAll();
            
    $player->getInventory()->setItem(0Item::get(345)->setCustomName(C::BOLD.C::GREEN."Teleporter"));
            
    $player->getInventory()->setItem(2Item::get(339)->setCustomName(C::BOLD.C::GOLD."Info"));
            
    $player->getInventory()->setItem(6Item::get(280)->setCustomName("§eHide §aPlayers"));
            
    $player->removeAllEffects();
            
    $player->getPlayer()->setHealth(20);
                
    $player->getPlayer()->setFood(20);

        }
        
            public function 
    killm(PlayerDeathEvent $event)
            {
                
    $event->setDeathMessage("");
            }

            

            public function 
    TeleportItems(Player $player){          //Teleport
            
    $player->getInventory()->clearAll();
            
    $player->getInventory()->setItem(3Item::get(280)->setCustomName(C::BOLD.C::BLUE."SkyPvP"));
            
    $player->getInventory()->setItem(8Item::get(341)->setCustomName(C::BOLD.C::RED."Back"));
            
    $player->getInventory()->setItem(0Item::get(267)->setCustomName(C::BOLD.C::RED."Hypixel"));
            
    $player->getInventory()->setItem(2Item::get(19)->setCustomName(C::BOLD.C::GREEN."Plots"));
            
    $player->removeAllEffects();
            
    $player->getPlayer()->setHealth(20);
            
    $player->getPlayer()->setFood(20);
        }


        public function 
    onJoin(PlayerJoinEvent $event){         //OnJoin
            
    $player $event->getPlayer();
            
    $name $player->getName();
            
    $ds $this->getServer()->getDefaultLevel()->getSafeSpawn();
            
    $player->setGamemode(0);
            
    $player->teleport($ds);
            
    $event->setJoinMessage("");
            
    $this->MainItems($player);
            
    $player->setGamemode(0);
            if(
    $player->isOP()){
                
    $event->setJoinMessage(C::RED.$name.C::AQUA." joined the game");
            }
        }
        
        public function 
    onQuit(PlayerQuitEvent $event){
            
    $player $event->getPlayer();
            
    $event->setQuitMessage(C::RED.$name.C::AQUA." has left the game");
        }

        public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $args){
            
    $name $sender->getName();
            switch (
    $cmd->getName()){
                case 
    "info":
                if(!empty(
    $args[0])){
                    if(
    $args[0] == "ranks"){
                        
    $sender->sendMessage($this->prefix "§aYou can buy a rank at buildmcpeplus-donate.tk");
                        return 
    true;
                    }
                    if(
    $args[0] == "server"){
                        
    $sender->sendMessage($this->prefix "§aThis server is a copy of the §9Build§aMcpe server. §9Build§aMcpe server IP: buildmcpe.eu PORT: 19132");
                        return 
    true;
                }else{
                    
    $sender->sendMessage($this->prefix"§a/info ranks|server");
                    return 
    true;
                }
            }
        }
        
        public function 
    onInteract(PlayerInteractEvent $event){
            
    $player $event->getPlayer();
            
    $name $player->getName();
            
    $item $player->getInventory()->getItemInHand();
            
    $itemid $item->getID();
            
    $block $event->getBlock();


            if(
    $item->getName() == C::BOLD.C::GOLD."Teleporter"){
                
    $this->TeleportItems($player);
            }

            elseif (
    $item->getName() == C::BOLD C::GOLD "Info"){
                
    $player->sendMessage($this->prefix "§aUsage: /info ranks|server");
            }

            elseif (
    $item->getName() == C::BOLD C::RED "Back"){
                
    $this->MainItems($player);
            }


            elseif (
    $item->getName() == C::BOLD C::GREEN "Plots"){
                
    $this->MainItems($player);
                
    $player->teleport($level->getSafeSpawn(Plots));
                
    $player->teleport(new Vector3($x$y$z$level));
            }

            elseif (
    $item->getName() == C::BOLD.C::RED."Hypixel"){
           
    $this->MainItems($player);
                
    $player->teleport($level->getSafeSpawn(§l§cHypixel));
                
    $player->teleport(new Vector3($x$y$z$level));
            }
            
            elseif (
    $item->getName() == C::BOLD.C::AQUA."SkyPvP"){
           
    $this->MainItems($player);
                
    $player->teleport($level->getSafeSpawn(SkyPvP));
                
    $player->teleport(new Vector3($x$y$z$level));
            }

            elseif (
    $item->getCustomName() == "§eHide §aPlayers") {
                
    $player->getInventory()->remove(Item::get(280)->setCustomName("§eHide §aPlayers"));
                
    $player->getInventory()->setItem(6Item::get(369)->setCustomName("§eShow §aPlayers"));
                
    $player->sendMessage($this->prefix "§aDisabled Player Visibility!");
                
    $this->hideall[] = $player;
                foreach (
    $this->getServer()->getOnlinePlayers() as $p2) {
                    
    $player->hideplayer($p2);
                }
            }

            elseif (
    $item->getCustomName() == "§eShow §aPlayers"){
                
    $player->getInventory()->remove(Item::get(369)->setCustomName("§eShow §aPlayers"));
                
    $player->getInventory()->setItem(6Item::get(280)->setCustomName("§eHide Players"));
                
    $player->sendMessage($this->prefix "§aEnabled Player Visibility!");
                unset(
    $this->hideall[array_search($player$this->hideall)]);
                foreach (
    $this->getServer()->getOnlinePlayers() as $p2) {
                    
    $player->showplayer($p2);
                }
            }
        }
        
        public function 
    onItemHeld(PlayerItemHeldEvent $event){
            
    $player $event->getPlayer();
            
    $name $player->getName();
            
    $item $player->getInventory()->getItemInHand()->getID();
            switch(
    $item){
                case 
    10:
                
    $player->getInventory()->setItemInHand(Item::get(Item::AIR00));
                
    $player->sendMessage($this->prefix.TextFormat::RED." You cannot use lava");
                return 
    true;
                case 
    11:
                
    $player->getInventory()->setItemInHand(Item::get(Item::AIR00));
                
    $player->sendMessage($this->prefix.TextFormat::RED." You cannot use lava");
                return 
    true;
            }
        }
    }
     
  2. XdmingXD

    XdmingXD Baby Zombie

    Messages:
    158
    GitHub:
    xdmingxd
    You forget to add "}" at line 109
     
  3. MalakasPlayzMC

    MalakasPlayzMC Spider Jockey

    Messages:
    37
    Oh, thanks!
     
  4. MalakasPlayzMC

    MalakasPlayzMC Spider Jockey

    Messages:
    37
    Wait, now when I log into my server I don't get the MainItems.
     
  5. XdmingXD

    XdmingXD Baby Zombie

    Messages:
    158
    GitHub:
    xdmingxd
    addItem()
     
  6. Zuruki

    Zuruki Baby Zombie

    Messages:
    118
    GitHub:
    zuruki
    He's trying to set it in a specific slot..
     
  7. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    PHP:
    public function MainItems(Player $player){
    $player->getInventory()->clearAll();
    $player->getInventory()->setItem(0Item::get(34501)->setCustomName(C::BOLD.C::GREEN."Teleporter");
    $player->getInventory()->setItem(2Item::get(33901)->setCustomName(C::BOLD.C::GOLD."Info");
    $player->getInventory()->setItem(6Item::get(28001)->setCustomName("§eHide §aPlayers");
    $player->removeAllEffects();
    $player->setHealth(20);
    $player->setFood(20);

    }
    try that
     
  8. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    That's just going to cause syntax errors.
     
    Sandertv likes this.
  9. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    well i tried ...
    maybe i shouldn't xD
     
  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.