Use player name in config.yml

Discussion in 'Plugin Help' started by GeistFan, May 2, 2021.

  1. GeistFan

    GeistFan Spider Jockey

    Messages:
    45
    GitHub:
    GeistFan
    Hi, I have coded an plugin that changes the join and leave messages with an config.yml, but I don't know how to add the player's name to that.
    Can you help me?
    -GeistFan
     
  2. DavyCraft648

    DavyCraft648 Spider Jockey

    Messages:
    34
    GitHub:
    DavyCraft648
  3. Primus

    Primus Zombie Pigman

    Messages:
    627
    This guy has been here for months making that plugin and asking where to put each character, this is going nowhere. Put your own effort into it!

    1. https://forums.pmmp.io/threads/plugin-unexpected.10951/#post-78395
    2. https://forums.pmmp.io/posts/78056/
    3. https://forums.pmmp.io/posts/78043/
    4. https://forums.pmmp.io/threads/my-plugin-doesnt-load-and-it-dont-show-any-error.10802/
    5. https://forums.pmmp.io/threads/solved-my-plugin-joinleave.10301/
    His first thread regarding this particular plugin was in August 21st 2020, 9 months ago!
     
    DavyCraft648 and minijaham like this.
  4. minijaham

    minijaham Zombie Pigman

    Messages:
    476
    GitHub:
    minijaham
    Not sure if he would be able to understand how to use it though.
     
    DavyCraft648 and Primus like this.
  5. GeistFan

    GeistFan Spider Jockey

    Messages:
    45
    GitHub:
    GeistFan
    So you just want to judge me because, as someone who is not very good at programming, I want to make a working plugin, right?
    -GeistFan
     
  6. GeistFan

    GeistFan Spider Jockey

    Messages:
    45
    GitHub:
    GeistFan
    How I can use it in the code?
     
  7. minijaham

    minijaham Zombie Pigman

    Messages:
    476
    GitHub:
    minijaham
    I TOLD YOU LOL I WAS RIGHT
     
    DavyCraft648 and Primus like this.
  8. minijaham

    minijaham Zombie Pigman

    Messages:
    476
    GitHub:
    minijaham
    Search it up yourself for once. There are good examples out there, yet you're asking one by one.
     
    Primus likes this.
  9. Primus

    Primus Zombie Pigman

    Messages:
    627
    You're just looking for someone to hand you the code. What answer is sufficient for your question? Are you expecting a code or an explanation on how to write code?

    I just don't get it. In 9 months you could have learned some common sense, and by now I can tell you that you have absolutely no intentions to learn.

    Please, watch this video:
     
    GeistFan, DavyCraft648 and minijaham like this.
  10. ErikX

    ErikX Spider Jockey

    Messages:
    49
    GitHub:
    ErikX-PMMP
    Here's the code, Also you can check out other plugins on GitHub and learn more about it.
    Here's PMMP documentation: apidoc.pmmp.io
    Here is the PHP documentation about STR_REPLACE: https://www.php.net/manual/en/function.str-replace.php

    PHP:
    public function onJoin(PlayerJoinEvent $event){
        
    $joinMSG $this->getConfig()->get("JoinMSG"); // Get's the JoinMSG value from the config.yml
        
    $playerName $event->getPlayer()->getName(); // Get's the joined Player name
        
    $event->setJoinMessage(str_replace("{name}",$playerName,$joinMSG));
    }
     
    GeistFan likes this.
  11. GeistFan

    GeistFan Spider Jockey

    Messages:
    45
    GitHub:
    GeistFan
    Thank you @Primus for the PHP tutorial and thank you @ErikX for the code.
     
  12. ErikX

    ErikX Spider Jockey

    Messages:
    49
    GitHub:
    ErikX-PMMP
    Anytime! Make sure to mark this thread as Solved. :D
     
  13. minijaham

    minijaham Zombie Pigman

    Messages:
    476
    GitHub:
    minijaham
    Hmm...yeah.
    Maybe try figuring out problems you encounter yourself next time!
    There are lots of search engines you can use! Just type in your problem and add "pmmp" at the end to get some good results!
     

Share This Page

  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.