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

Adding a plugin ina plugin

Comments in 'Plugin Development' started by Radix, Dec 4, 2015.

  1. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    How can I add a plugin into my plugin so I can use pre defined functions set by that plugin like {faction}
  2. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    PHP:


        
    public function renderNameTag($player){
            
    $username $player->getName();
           
            if(
    $this->isEnabled){
                
    $player->setNameTag("DARKREALMS"TextFormat::GRAY.$player->getName().TextFormat::WHITE." ".$player->getHealth().TextFormat::RED."❤");
            }else{
                
    $player->setNameTag($player->getName());
            }
        }
    I want to be able to add {faction} from my factions plugin
  3. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    And can you show me your factions plugin and what {faction} is, and how you are planning to call on it?
    deot likes this.
  4. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    U need to have an API to get Faction Name first, then use that API in setNameTag :)

    In Faction Plugin, the getFaction API
    PHP:
    public function getFaction($p){
        
    // Code to return Player's Faction Name
    }
    Example Usage:
    PHP:
    setNameTag($this->getFaction($p).$p->getName())
    And... actually, i found out that the code is 99% similar to this:
    https://github.com/EnderKenji/HealthTag/blob/master/src/HealthTag/HealthTag.php#L34-L42

    Wondering if you're the one copying or he is the one copying... xD :p
    Gamecrafter likes this.
  5. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    Yes , Im editing it to have Factions name in the tag
  6. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Do u want to replace "{faction}" in the config?
  7. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    PHP:

        
    public function getFaction($p){
    // Code to return Player's Faction Name
    }

        public function 
    renderNameTag($player){
            
    $username $player->getName();
           
            if(
    $this->isEnabled){
                
    $player->setNameTag($this->getFaction($p).$p->getName() ." DARKREALMS "TextFormat::GRAY.$player->getName().TextFormat::WHITE." ".$player->getHealth().TextFormat::RED."❤");
            }else{
                
    $player->setNameTag($player->getName());
            }
        }
  8. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    If u dont separate your Faction and SetNameTag plugin, then that code is correct, if u separated, it's wrong
  9. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    Want it separted
  10. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    I dont think he coded all those things...
  11. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    Modifed FactionsPro
  12. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    I don't really code , @BalAnce is my dev :D
  13. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Then u have to get Plugin in your setNameTag plugin

    $this->getServer()->getPluginManager()->getPlugin("FactionsPro")->getFaction($p);
  14. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    Looks + Factions Chat + 2K to Make a factions little stuff
  15. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
  16. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Easy. I'm assuming you're going to add the code to the main class, so the following code should work:
    PHP:
    //$p would be the player object, put the following code into your method: getFaction() exactly the way it is below
    $this->getServer()->getPluginManager()->getPlugin("FactionsPro")->getSession($p)->getFactionName();
  17. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    Fatal error: Call to undefined method FactionsPro\FactionMain::getSession() in /root/server/plugins/HealthTag-master/src/HealthTag/HealthTag.php on
    line 39

    http://hastebin.com/galagucoju.tex
  18. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Did you even read my instructions? Put in in the getFaction method.

Share This Page

Advertisement