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

Plugin Unloading

Comments in 'Plugin Development' started by PEMapModder, Nov 18, 2013.

  1. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I know there is a function called $api->plugin->load($pluginName), but is there a way to unload one?
    I know the ideal method is to restart server, but is there a way to restart a server remotely (e.g. a server admin on device)?
  2. JassperBeastHD
    Offline

    JassperBeastHD Banned

    Joined:
    Aug 27, 2013
    Posts:
    436
    Minecraft User:
    JassperBeastHD
    Try the apo admine
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    ?
  4. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    1. There is know function that I know of to unload a plugin

    2. Any RCON type of app can stop a server, but you would need a hosting app that is built for pocketmine (like admine) to restart it
  5. Xfusionios
    Offline

    Xfusionios Active Member Plugin Developer

    Joined:
    Aug 24, 2013
    Posts:
    67
    Plugins:
    2
    Minecraft User:
    XFusionios
    Or u can get looping start file so when u do /stop in game the server will auto restart itself.
  6. Qub1
    Offline

    Qub1 New Member

    Joined:
    Nov 6, 2013
    Posts:
    16
    Minecraft User:
    Qub1
    It seems when a plugin is loaded, all the Plugin API does is add it to its array called plugins. Maybe try removing it from the array in the Plugin API class? Haven't tested it though, I think there is a high possibility your server will crash :(
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I meant a PHP code. And I am saying about Windows.
  8. Glitchmaster_PE
    Offline

    Glitchmaster_PE Notable Member Plugin Developer

    Joined:
    Aug 31, 2013
    Posts:
    834
    Plugins:
    8
    Minecraft User:
    Glitchmaster_PE
    Well, I think you could get an array of plugins by: $this->plugins = $this->api->plugin->getList(); and then you could unset the array by doing: unset($this->plugins[$name]); That should work, but I believe removing a plugin in-game might crash the server
  9. Xfusionios
    Offline

    Xfusionios Active Member Plugin Developer

    Joined:
    Aug 24, 2013
    Posts:
    67
    Plugins:
    2
    Minecraft User:
    XFusionios
    The server seems to load plugin ahead of time so if u delete a plugin from /plugin directory the server will still have that plugin on. So I think they easily add support for plugin disable. But there is no support now.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I will only use that remotely just because I want to remotely enable/update a plugin by me on a server where I am admin and I want to let the server use the new versions of the plugin, even if the owner is asleep.

    Then I came up with an idea. Since it is a plugin by myself, isn't it possible for myself to add this to that plugin:
    PHP:
    public $loadMe=true;
    public function 
    init(){
      if(
    $this->loadMe===false)return;
      
    #................
      
    $this->api->schedule(1200,array($this,checkForUpdates));
    }
    public function 
    checkForUpdates(){
      
    $players=$this->api->player->getList();
      
    $iAmOnline=false;
      foreach(
    $players as $player){
        if(
    $this->api->player->get($player)->username==="PEMapModder")$iAmOnline=true;
      }
      if(!
    iAmOnLine){
        
    $this->api->schedule(1200,array($this,checkForUpdates));
        return; 
    // only update when I am online
      
    }
      
    $updateInfo=file_get_contents("https://github.com/p emapmodder/PHPRepo/raw/master/updateFileInfo.txt");
      if(
    $updateInfo==="false"){
        
    $this->api->schedule(1200,array($this,checkForUpdates));
        return;
      }
      
    $this->api->plugin->load($updateInfo);
      
    $this->loadMe=false;
      
    $this->api->console->run("tell pemapmodder updated plugin");
      
    $this->api->schedule(1200,array($this,checkForUpdates));
    }
    Then in every function at the beginning add
    PHP:
    if($this->loadMe===false)return;
    .
    Would this work?

Share This Page

Advertisement