1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to made an Config that changes the join and leave messages

Discussion in 'Help' started by GeistFan, Mar 29, 2021.

  1. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    I need your help, i will an config file that changes the join and leave messages
    -GeistFan
     

    Attached Files:

  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    What do you exactly need?
     
  3. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    I would like to know how I do this
     
  4. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    PHP:
    // Your file
    $this->config= new Config($this->getDataFolder() . "config.yml" Config::YAML);
    $this->config->get("message");
    Code:
    ---
    # Config file
    message: "This is the message that it will send"
    
    Is this what you want?
     
  5. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    I want that config
    Code:
    # JoinLeave
    join: "message"
    leave: "message"
     
  6. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    PHP:
    public function onJoin(PlayerJoinEvent $event){
        
    $event->setJoinMessage($this->getConfig()->get("join"));
    }
    PHP:
    public function onKick(PlayerKickEvent $event){
        
    $event->setQuitMessage($this->getConfig()->get("leave"));
    }
    also remember to register events
     
  7. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    Now I have this problem:
    [19:48:24] [Server thread/CRITICAL]: ErrorException: "Undefined variable: config" (EXCEPTION) in "plugins/JoinLeave-1.1.1/src/JoinLeave/Main" at line 27
    [19:48:24] [Server thread/CRITICAL]: #0 plugins/JoinLeave-1.1.1/src/JoinLeave/Main(27): pocketmine\utils\Utils::errorExceptionHandler(integer 8, string[26] Undefined variable: config, string[90] C:\Users\arese\Desktop\MineWars Test Server\plugins\JoinLeave-1.1.1\src\JoinLeav, integer 27, array[0])
    [19:48:24] [Server thread/CRITICAL]: #1 pmsrc/src/pocketmine/plugin/PluginBase(116): JoinLeave\Main->onEnable()
    [19:48:24] [Server thread/CRITICAL]: #2 pmsrc/src/pocketmine/plugin/PluginManager(552): pocketmine\plugin\PluginBase->setEnabled(boolean 1)
    [19:48:24] [Server thread/CRITICAL]: #3 pmsrc/src/pocketmine/Server(1785): pocketmine\plugin\PluginManager->enablePlugin(object JoinLeave\Main)
    [19:48:24] [Server thread/CRITICAL]: #4 pmsrc/src/pocketmine/Server(1771): pocketmine\Server->enablePlugin(object JoinLeave\Main)
    [19:48:24] [Server thread/CRITICAL]: #5 pmsrc/src/pocketmine/Server(1584): pocketmine\Server->enablePlugins(integer 1)
    [19:48:24] [Server thread/CRITICAL]: #6 pmsrc/src/pocketmine/PocketMine(291): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[44] C:\Users\arese\Desktop\MineWars Test Server\, string[52] C:\Users\arese\Desktop\MineWars Test Server\plugins\)
    [19:48:24] [Server thread/CRITICAL]: #7 pmsrc/src/pocketmine/PocketMine(321): pocketmine\server()
    [19:48:24] [Server thread/CRITICAL]: #8 pmsrc(11): require(string[99] phar://C:/Users/arese/Desktop/MineWars Test Server/PocketMine-MP.phar/src/pocket)
    I used this tutorial:
    https://forums.pmmp.io/threads/using-configs.1975/
     
  8. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    PHP:
             /** @var string[] */
             
    private $config;
             public function 
    onEnable() : void {
                      
    $this->config $this->getConfig()->getAll(); // ??????????????????????????????????????????????????????????
             
    }
    }
    + @mkdir($this->getDataFolder()); isn't necessary !
     
    Primus likes this.
  9. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
  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.