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

Explosive Projectiles

Comments in 'Plugin Development' started by Skullex, Feb 11, 2016.

  1. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    I have recently coded this and apon submitting it to pmt.mcpe.me I saw errors EVERYWHERE :eek:
    I seriously need help with this plugin. Here's the errors, the code and plugin.yml

    PHP:
    <?php

    namespace EP;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandExecutor;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\PluginCommand;
    use 
    pocketmine\event\entity\ProjectileLaunchEvent;
    use 
    pocketmine\event\entity\ProjectileHitEvent;
    use 
    pocketmine\event\player\PlayerQuitEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\level\Explosion;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\Player;

    class 
    ExplosiveProjectiles extends PluginBase implements Listener {

      private 
    $players;

      public function 
    onEnable(){
      @
    mkdir($this->getDataFolder());
      
    $this->config = new Config($this->getDataFolder()."config.yml"Config::YAML, [
      
    "BlockBreaking" => false,
      
    "size" => 10
      
    ]);
      
    $this->players = new \SplObjectStorage();
      
    $command = new PluginCommand("ExplosiveProjectiles"$this);
      
    $command->setAliases(["ep"]);
      
    $command->setExecutor($this);
      
    $this->getServer()->getCommandMap()->register("ExplosiveProjectiles"$command);
      
    $this->getServer()->getPluginManager()->registerEvents($this$this);
      }

      public function 
    explode(Position $position){
      
    $explosion = new Explosion($position, (int) $this->getConfig()->get("size"));
      if(
    $this->getConfig()->get("blockBreaking")){
      
    $explosion->explode();
      }
      else{
      
    $explosion->explodeB();
      }
      }

      public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
      if(
    $sender instanceof Player){
      if(
    $sender->isOp()){
      if(
    $this->isActive($sender)){
      
    $this->setActive($senderfalse);
      
    $sender->sendMessage(TextFormat::RED."EP disabled! You can no longer blow things up with projectiles.");
      }
      else{
      
    $this->setActive($sendertrue);
      
    $sender->sendMessage(TextFormat::GREEN."EP enabled! Throw a projectile to blow someone up");
      }
      }
      else{
      
    $sender->sendMessage(TextFormat::RED."You don't have permissions to use this command.");
      }
      }
      else{
      
    $sender->sendMessage(TextFormat::RED."Please run this command in-game.");
      }
      return 
    true;
      }

      public function 
    onProjectileHit(ProjectileHitEvent $event){
      if(
    $event instanceof ProjectileLaunchEvent){
      if(
    $event->getProjectile() instanceof Player){
      
    $this->explode($event->getEntity());
      }
      }
      }

      public function 
    onPlayerQuit(PlayerQuitEvent $event){
      if(
    $this->isActive($event->getPlayer())){
      
    $this->setActive($event->getPlayer(), false);
      }
      }
      }
    }
    Plugin.yml

    PHP:
    nameExplosiveProjectiles
    main
    EP\ExplosiveProjectiles
    version
    1.0
    api
    1.1.0
    load
    POSTWORLD
    author
    Skullex
    description
    Explosive Projectilesthat simple!
    commands:
      
    ExplosiveProjectiles:
      
    aliasesep
      
    default: op
    Errors

    Code:
    Classpath
    Inspection result: Error
    Errors
    Error parsing plugin.yml
    Bad practice
    Inspection result: Error
    Errors
    Error parsing plugin.yml
    Syntax errors
    Inspection result: Error
    Errors
    PHP Parse error: syntax error, unexpected '}', expecting end of file in /var/www/tmp/5/ExplosiveProjectiles/src/EP/ExplosiveProjectiles.php on line 84
    Errors parsing /var/www/tmp/5/ExplosiveProjectiles/src/EP/ExplosiveProjectiles.php
    Info
    0 good PHP file(s) and 1 bad PHP file(s) found.
    
    Thanks in advance :)
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    plugin.yml: first line should not be indented with one space, last two lines should be indented with two units of indent (4 spaces in your case)
    Main: It appears that you already registered the command in plugin.yml. You don't need to do that again in plugin PHP code.
    Syntax errors: please point out line 84
    Skullex likes this.
  3. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Oh, ok. Makes sense... Thanks! :D
  4. MichaelM04
    Offline

    MichaelM04 Active Member Plugin Developer

    Joined:
    Nov 12, 2015
    Posts:
    213
    Plugins:
    1
    Minecraft User:
    Michael
    I'm sorry but can't you read the errors yourself and fix them!?
    PocketKiller and PEMapModder like this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    In some people's mind, errors generated from machines need to be interpreted by humans, just like oracle messages (in Chinese culture) need to be interpreted by specialists (even though the messages are written in Chinese).
    PocketKiller, Skullex and MichaelM04 like this.
  6. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    The projectilehitevent code makes me a bit wondering, how can a hit event be an instamnce of a launch event? Btw you also forgot the ! (Is not) on if($event->getEntity() instanceof Player){
    Skullex likes this.

Share This Page

Advertisement