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

two config files

Comments in 'Plugin Development' started by amiremad, May 9, 2016.

  1. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    how to make it 2 config files and make the plugin read both

    is this code correct

    PHP:
    <?php

    namespace mcrafters;

    use 
    pocketmine\utils\Config;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\TextFormat as SM;
    use 
    pocketmine\command\PluginCommand;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\CommandExecutor;
    use 
    pocketmine\Server;
    use 
    pocketmine\IPlayer;
    use 
    pocketmine\Player;
    use 
    pocketmine\event\block\BlockBreakEvent;
    use 
    pocketmine\event\block\BlockPlaceEvent;
    use 
    pocketmine\event\player\PlayerChatEvent;
    use 
    pocketmine\event\player\PlayerDropItemEvent;
    use 
    pocketmine\event\player\PlayerCommandPreprocessEvent;
    use 
    pocketmine\event\player\PlayerDeathEvent;
    use 
    pocketmine\event\player\PlayerGameModeChangeEvent;
    use 
    pocketmine\event\player\PlayerToggleSneakEvent;

    class 
    ServerManager extends PluginBase implements Listener
    {
       
        public function 
    onEnable()
        {
                
    $this->getServer()->getPluginManager()->registerEvents($this$this);
                
    $this->getServer()->getLogger()->info(SM::GRAY "[" SM::BOLD SM::AQUA "Server" SM::GRAY "-" SM::YELLOW "Manager" SM::GRAY "] " SM::GREEN " has enabled");
                
    $this->getServer()->getLogger()->info(SM::GRAY "[" SM::BOLD SM::AQUA "Server" SM::GRAY "-" SM::YELLOW "Manager" SM::GRAY "] " SM::DARK_PURPLE " The Plugin Is Still In Development So for now it is not working check back later");
                @
    mkdir($this->getDataFolder());
                
    $this->saveResource("config.yml");
                
    $this->cfg = new Config ($this->getDataFolder() . "config.yml"Config::YAML);
                
    $this->mcfg = new Config ($this->getDataFolder() . "messages.yml"Config::YAML);
            }
        public function 
    onBreak(BlockBreakEvent $bbe){
            if(
    $this->cfg->get("BlockBreaking") == false){
                
    $ome->getPlayer()->sendMessage(SM::GRAY "[" SM::AQUA "Sevrer-" SM::YELLOW "Manager" SM::GRAY "] " $this->mcfg->get("Block_Break_Disabled"));
                
    $bbe->setcancelled();
            }
        }
        public function 
    onDisable()
        {
            
    $this->getLogger()->info(SM::GRAY "[" SM::BOLD SM::GREEN "Server - " SM::YELLOW "Manager" SM::GRAY "] " SM::RED " has disabled");
        }
    }
  2. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    It's mostly right, but there are a few errors.
    1: You can either use the new config function like you did in your code, or you can use
    PHP:
    $this->saveDefaultConfig();
    2: In your onBreak function, $ome is an undefined variable
    3: You spelled Server wrong in your onBreak function
    Last edited: May 10, 2016
  3. amiremad
    Offline

    amiremad Active Member

    Joined:
    Sep 8, 2015
    Posts:
    192
    Minecraft User:
    amir107
    thx
  4. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    No problem :D

Share This Page

Advertisement