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

Plugin noot reading

Discussion in 'Development' started by Doxestic, Mar 7, 2020.

  1. Doxestic

    Doxestic Spider Jockey

    Messages:
    41
    hi i have a plugin(a training plugin:p) but its not reading and problem is in the end of main.php when i put ?> at end it say : ((
    syntax error, unexpected '?>', expecting function (T_FUNCTION) or const (T_CONST)" (EXCEPTION) in "plugins/Cure_v 1.0 (by doxestic)/src/doxestic/main" at line 83
    )) and when i put nothink it say
    syntax error, unexpected end of file, expecting function (T_FUNCTION) or const (T_CONST)" (EXCEPTION) in "plugins/Cure_v 1.0 (by amirTBM)/src/amirTBM/main" at line 83
    and when i put } for class main extends pluginbase{ it can't find class main =|
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Check if all semicolons are there and all brackets match up. You should not use ?> anywhere, unless you inline php inside of html when making a website
     
  3. Doxestic

    Doxestic Spider Jockey

    Messages:
    41
    tnx very much i will check it
     
  4. Doxestic

    Doxestic Spider Jockey

    Messages:
    41
    Code:
    <?php
    
     namespace doxestic\main;
    
     use pocketmine\command\Command;
     use pocketmine\command\CommandSender;
     use pocketmine\event\Cancellable;
     use pocketmine\event\player\PlayerCommandPreprocessEvent;
     use pocketmine\level\particle\DestroyBlockParticle as BloodParticle;
     use pocketmine\level\particle\FlameParticle as WeaponShootParticle;
     use pocketmine\level\sound\AnvilFallSound as DropBombSound;
     use pocketmine\level\sound\BlazeShootSound as WeaponShootSound;
     use pocketmine\level\sound\DoorCrashSound as ExplodeSound;
     use pocketmine\level\Explosion;
     use pocketmine\level\Position;
     use pocketmine\event\Listener;
     use pocketmine\Player;
     use pocketmine\block\Air;
     use pocketmine\block\Block;
     use pocketmine\item\Item;
     use pocketmine\item\Snowball as Bullet;
     use pocketmine\entity\Entity;
     use pocketmine\entity\Snowball;
     use pocketmine\entity\Egg;
     use pocketmine\entity\PrimedTNT;
     use pocketmine\nbt\tag\CompoundTag;
     use pocketmine\nbt\tag\DoubleTag;
     use pocketmine\nbt\tag\StringTag;
     use pocketmine\event\CommandExecutor;
     use pocketmine\nbt\tag\ListTag;
     use pocketmine\nbt\tag\FloatTag;
     use pocketmine\event\player\PlayerMoveEvent as PlayerWalkEvent;
     use pocketmine\event\player\PlayerInteractEvent as PlayerUseWeaponEvent;
     use pocketmine\event\player\cheat\PlayerCheatEvent;
     use pocketmine\event\player\PlayerItemHeldEvent;
     use pocketmine\event\player\PlayerDeathEvent;
     use pocketmine\event\entity\EntityDamageEvent;
     use pocketmine\event\entity\EntityDamageByEntityEvent;
     use pocketmine\event\entity\EntityDamageByChildEntityEvent;
     use pocketmine\event\entity\ExplosionPrimeEvent;
     use pocketmine\plugin\PluginBase;
     use pocketmine\Server;
     use pocketmine\math\Vector3;
     use pocketmine\inventory\Inventory;
     use pocketmine\utils\TextFormat;
     use pocketmine\utils\Config;
     use pocketmine\utils\TextFormat as TF;
     use pocketmine\utils\TextFormat as C;
     use pocketmine\event\player\PlayerJoinEvent;
     use pocketmine\event\player\PlayerLoginEvent;
     use pocketmine\event\block\BlockBreakEvent;
     use pocketmine\event\player\PlayerMoveEvent;
     use pocketmine\network\mcpe\protocol\LoginPacket;
     use pocketmine\event\server\DataPacketReceiveEvent;
     use onebone\economyapi\EconomyAPI;
     use pocketmine\entity\Effect;
     use pocketmine\entity\EffectInstance;
     use pocketmine\inventory\playerinventory;
     use pocketmine\event\player\PlayerItemConsumeEvent;
    
     class main extends pluginbase{
        
    
         public function onenable()
         {
             $this->getlogger()->info("§a plugin enabled");
         }
    
         public function on_hit()
         {
             $this->player = $player;
             $this->$player->getname();
             if ($player->PlayerItemConsumeEvent($player, apple)) {
                 $this->$player->setAutoJump(500);
                 return true;
             }
         }
     }
    
    its code and eror is not reading main how can i fix it?
     
  5. Doxestic

    Doxestic Spider Jockey

    Messages:
    41
    why???????????
     
  6. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    That code is very wrong and I suggest you learn at least the basics of php before writing a PocketMine plugin.

    As for the syntax error, that doesn't appear in your code, however I found a lot of other mistakes.

    1. Your namespace makes no sense, unless your plugin is called main
    2. That's a lot of unused use statements
    3. PluginBase should be written in CamelCase
    4. onEnable, too
    5. Your on_hit function will never get executed
    6. Why are you setting $player as a class property
    7. getName should also be written in camelCase
    8. $player->PlayerItemConsumeEvent($player, apple) is complete nonsense
    9. why return true?
    https://www.php.net/manual/en/language.basic-syntax.phptags.php
     
    ethaniccc and GamakCZ like this.
  7. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    :facepalm:
     
    ethaniccc likes this.
  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.