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

Solved How to remove MySQL from a plugin...

Discussion in 'Plugin Help' started by Lazer, Apr 27, 2017.

  1. Lazer

    Lazer Spider

    Messages:
    10
    GitHub:
    Lazerplayz
    dam lazers back at it again with the stupid questions!

    So how do I disable MySQL in a plugin once i added it?













    (Kill me, kill me now :facepalm: )
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    How did you add it? Show your MySQL code.
     
  3. Lazer

    Lazer Spider

    Messages:
    10
    GitHub:
    Lazerplayz
    Well heres the setting for it lol

    mysql:
    host: "null"
    port: null
    user: "null"
    password: "null"
    database: "null"
     
  4. Primus

    Primus Zombie Pigman

    Messages:
    749
    TBH, this should be in facepalm section.

    Every plugin implements MySQL data provider differently! What plugin you're using?
     
  5. Lazer

    Lazer Spider

    Messages:
    10
    GitHub:
    Lazerplayz
    Thing is its a custom plugin lol
     
  6. Primus

    Primus Zombie Pigman

    Messages:
    749
    I don't repeat myself, but as I previously said: "Every plugin implements MySQL data provider differently!"

    This is how I switch data providers in my plugin
    PHP:
    /**
     * @internal
     */
    private function loadDataProvider(): bool
    {
        try {
            switch (
    strtolower(trim($this->getConfig()->get('data-provider')["type"]))) {
                default:
                case 
    'yaml':
                case 
    'yml':
                    
    $this->setDataProvider(new YAMLDataProvider($this));
                    break;
                case 
    'json':
                    
    $this->setDataProvider(new JSONDataProvider($this));
                    break;
                case 
    'sql':
                case 
    'sqlite':
                case 
    'sqlite3':
                    
    $this->setDataProvider(new SQLite3DataProvider($this));
                    break;
                case 
    'mysql':
                    
    $this->setDataProvider(new MySQLDataProvider($this));
                    break;
            }
        } catch (\
    Exception $e) {
            
    $this->getLogger()->critical(Localizer::trans('plugin.dataprovider-error', [$e->getMessage()]));
            
    $this->getServer()->getPluginManager()->disablePlugin($this);
            return 
    false;
        }
        
    $this->getLogger()->info(Localizer::trans('plugin.dataprovider-set', [$this->getDataProvider()->getName()]));
        return 
    true;
    }
    I get a value from config under 'data-provider' key, setting which users can change. Then load appropriate data provider or default one, if that value does not reference any supported data providers. This implementation is widely used, so I assume that you must change one value in the config.
     
  7. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    You can't just "disable MySQL" in a plugin. You could add a simple comment to comment out or delete all the functionality related to MySQL.
     
    jasonwynn10 likes this.
  8. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    some plugin WILL only work with MYSQL and some developer is not bother with implementing providers so it will need someone who have knowledge and willing to deal with these kind of madness to disable it
     
  9. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    I wouldn't use the term 'disable.' MySQL is a php extension, not just something PocketMine has. Plugins developers can choose to implement it as a data provider or not in their plugins.
     
    SOFe likes this.
  10. Lazer

    Lazer Spider

    Messages:
    10
    GitHub:
    Lazerplayz
    Calm calm calm i changed the title o and did you read that last line I wrote!
     
  11. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    to remove just quote it out, BUT good luck programming an alternative for some functions to work
     
    jasonwynn10 likes this.
  12. Lazer

    Lazer Spider

    Messages:
    10
    GitHub:
    Lazerplayz
    Google is my friend "it" will answer my life's questions
     
  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.