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

Code not working

Comments in 'Plugin Development' started by Artide, May 2, 2015.

  1. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    I'm making my first pocketmine plugin but doesn't work, please tell me what I did wrong, thanks.

    PHP:
    <?php

    namespace KillCheck;

    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\Player;
    use 
    pocketmine\server;
    use 
    pocketmine\level;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\math\Vector3;
    use 
    onebone\economyapi\EconomyAPI;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;

        class 
    Main extends PluginBase{
    /*******************************************************************************************************/
           
            
    public function onEnable(){
                
    $this->saveDefaultConfig();
                
    $this->reloadConfig();
                
    $v "0.1";
                
    $c "Artide";
                
    $this->getServer()->getPluginManager()->registerEvents($this,$this);
                
    $this->player EconomyAPI::getInstance();
                
    $this->getLogger()->info("Plugin loaded! v_".$v." By ".$c);
            }
    /*******************************************************************************************************/
       
            
    public function onPlayerDeathEvent(PlayerDeathEvent $event){
                
    $player $event->getEntity();
                
    $name strtolower($player->getName());
                if(
    $player instanceof Player){
                    
    $cause $player->getLastDamageCause();
                    if(
    $cause instanceof EntityDamageByEntityEvent){
                        
    $killer $cause->getDamager();
                        if(
    $killer instanceof Player){
                            
    $killer->sendMessage($this->getConfig()->get("Killer-Message"));
                              
    $this->player->addMoney($killer$this->getConfig()->get("Added-Coins"));
                                if(
    $this->getConfig()-get("Disable-Killer-Coins") === true){
                                   
    $this->player->addMoney($killer0);
                                    
    $player->sendMessage($this->getConfig()->get("Player-Message"));
                                      
    $this->player->reduceMoney($player$this->getConfig()->get("Reduced-Coins"));
                                 if(
    $this->getConfig()->get("Disable-Coin-Reduction") === true){
                                    
    $this->player->reduceMoney($player0);
                    return 
    true;
                   
            }else{
              return 
    true;

                }

             }
                    
          }
          
        }
           
      }
       
    }
    /*******************************************************************************************************/
           
            
    public function onDisable(){
                
    $this->getLogger()->info("Plugin unloaded!");
            }
           
    }
    ?>
  2. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    What is the error? Does a part of it not run? Does it crash the server entirely?
  3. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Nothing happened, it just disabled for nothing...
  4. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    The opposite of that :p
  5. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    You must implement the PocketMine Listener interface
    PEMapModder likes this.
  6. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Halkwise likes this.

Share This Page

Advertisement