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

ColorTag

Comments in 'Plugin Development' started by FlamingGenius, Oct 5, 2015.

  1. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Is there anything wrong with this?
    PHP:
    <?php

    namespace FlamingGenius\ColorTag;

    use 
    pocketmine\utils\Config;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Player;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\event\PlayerJoinEvent;
    use 
    pocketmine\event\PlayerQuitEvent;
    use 
    pocketmine\event\Listener;

    class 
    ColorTag extends PluginBase implements Listener{
    $playerConfig = new Config($this->getDataFolder() . $player ".yml" Config::YAML);
    public function 
    onEnable(){
      
    $this->saveDefaultConfig();
      
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    }

    public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
    $player $this->getServer()->getPlayer();
    $cmd $this->command->getName();
    $tag $args;
    $config $this->getConfig()->get("tags");
    if(
    $tag == $config){
      if(
    strtolower($cmd) == "st"){
       
    $setTag $this->getConfig()->get($tag);
       
    $player->setNameTag($setTag);
      }
    }
      else{
       
    $sender->sendMessage("§bTag not reconized");
      }
    }

    public function 
    onJoinGame(PlayerJoinEvent $event){
      
    $players $event->getServer()->getOnlinePlayers();
      foreach(
    $players as $player){
       
    $playerConfig;
      
      }
    }

    public function 
    onQuitGame(PlayerQuitEvent $event){
      
    $player $this->getServer()->getPlayer()->getName();
      
    $playerConfig->set($player $player->getNameTag());
     
    $playerConfig->save();
    }


    }


    ?>
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    How about testing it?
    PianoPlayer38 and PEMapModder like this.
  3. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Cant afford downtime on my server and i dont have a test server
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Make a test server. THATS why you need a PC :rolleyes:
  5. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Yea i know but since this is just a hobby i have to put other things first before getting a laptop
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    How I test/debug:
    Install a new PM instance, then run all testing plugins there.
  7. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Ugh crash :/
    PHP:
    ErrorDeclaration of FlamingGenius\ColoredTags\ColoredTags::onCommand() must be compatible with pocketmine\command\CommandExecutor::onCommand(pocketmine\command\CommandSender $senderpocketmine\command\Command $command$label, array $args)
    File: /phar_ColoredTags-master (1)_VHbd7_sxPG8WixV.phar/src/FlamingGenius/ColoredTags/ColoredTags
    Line
    13
    Type
    E_COMPILE_ERROR

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code
    :
    [
    4
    [
    5] use pocketmine\utils\Config;
    [
    6] use pocketmine\plugin\PluginBase;
    [
    7] use pocketmine\Player;
    [
    8] use pocketmine\entity\Entity;
    [
    9] use pocketmine\event\PlayerJoinEvent;
    [
    10] use pocketmine\event\PlayerQuitEvent;
    [
    11] use pocketmine\event\Listener;
    [
    12
    [
    13] class ColoredTags extends PluginBase implements Listener{
    [
    14
    [
    15]  public function onEnable(){
    [
    16]   $this->saveDefaultConfig();
    [
    17]   $this->getServer()->getPluginManager()->registerEvents($this$this);
    [
    18]  }
  8. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Read the error. Add a line use pocketmine\command\CommandSender and use pocketmine\command\Command.
  9. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    OMG :confused: I added the imports as i added the functions i cant believe i actually missed putting the command imports in....:oops: This is kinda embarrassing cant believe i missed something so simple as an import
  10. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    ...
    It is not embarrassing at all.
  11. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    I cant win :/

    PHP:
    ErrorCall to undefined method pocketmine\event\player\PlayerJoinEvent::getServer()
    File: /phar_ColoredTags-master_GZjq2mD9XiDJFmp.phar/src/FlamingGenius/ColoredTags/ColoredTags
    Line
    39
    Type
    E_ERROR

    THIS CRASH WAS CAUSED BY A PLUGIN
    BAD PLUGIN
    ColoredTags v1.0.0

    Code
    :
    [
    30]    $player->setNameTag($setTag);
    [
    31]   }
    [
    32]  }
    [
    33]   else{
    [
    34]    $sender->sendMessage("§bTag not reconized");
    [
    35]   }
    [
    36]  }
    [
    37]  
    [
    38]  public function onJoinGame(PlayerJoinEvent $event){
    [
    39]   $players $event->getServer()->getOnlinePlayers();
    [
    40]   foreach($players as $player){
    [
    41]   $playerConfig = new Config($this->getDataFolder() . $player ".yml" Config::YAML);
    [
    42]   $playerConfig->save();
    [
    43]    
    [
    44]   }
    [
    45]  }
  12. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    $this->getServer(), Not $event->getServer().
    LEARN OOP
    Taha_The_Hacker likes this.
  13. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Many more errors. I highly recommend you to learn PHP and the PocketMine API.
  14. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    If you are coding on your phone/tablet why not donwload the pocketmine app and test your plugins on that?
  15. CavinMiana
    Offline

    CavinMiana Active Member

    Joined:
    Aug 26, 2015
    Posts:
    101
    Minecraft User:
    CavinMiana
    Lel

Share This Page

Advertisement