This repository has been archived by the owner on Jul 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15397c8
commit fa24e6b
Showing
7 changed files
with
526 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<img src="https://raw.githubusercontent.com/alejandroliu/bad-plugins/master/Media/ZipPlugin-icon.png" style="width:64px;height:64px" width="64" height="64"/> | ||
|
||
ZipPluginLoader | ||
=============== | ||
|
||
* Summary: Load Zip packed plugins | ||
* Dependency Plugins: n/a | ||
* PocketMine-MP version: 1.4 - API 1.10.0 | ||
* DependencyPlugins: - | ||
* OptionalPlugins: - | ||
* Categories: Developer Tools | ||
* Plugin Access: Manages plugins | ||
* WebSite: [github](https://github.com/alejandroliu/bad-plugins/tree/master/ZipPluginLoader) | ||
|
||
Overview | ||
-------- | ||
|
||
**NOTE: This is unlike _DevTools_, as it is focus on only loading Zip files | ||
instead of folders like _DevTools_.** You still need _DevTools_ if | ||
you actually want to do Plugin Development and to create _phar_ file | ||
plugins. | ||
|
||
This plugin Let's you load plugins from zip files. This is | ||
particularly handy when trying out source plugins from | ||
[GitHub](http://github.com) as you can click the **Download ZIP** | ||
button, as you can then place the zip file in the plugins folder. | ||
|
||
Essentially you put your plugin code in a zip file, and this plugin | ||
will look for a **plugin.yml** file in there and load the plugin. | ||
|
||
If there are multiple plugins in a zip file, all the plugins will be | ||
loaded by default. You can control what plugins will be loaded by | ||
creating a control file. For example if you have a: | ||
|
||
example.zip | ||
|
||
You need to create a text file called: | ||
|
||
example.ctl | ||
|
||
In this file you list (one plugin per line) the plugins that you want | ||
to load. Any plugins **not** in listed the control file will **not** be | ||
loaded. | ||
|
||
Changes | ||
------- | ||
|
||
* 1.1.0: Multiple plugins | ||
* Change the way error reporting is done... | ||
* Supports for multiple plugins in a zip file. | ||
* 1.0.0: First release | ||
|
||
Copyright | ||
--------- | ||
|
||
ZipPluginLoader | ||
Copyright (C) 2015 Alejandro Liu | ||
All Rights Reserved. | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: ZipPluginLoader | ||
main: ZipPluginLoader\Main | ||
version: 1.1.0 | ||
api: 1.10.0 | ||
load: STARTUP | ||
author: aliuly | ||
description: Load Zip packed plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
namespace ZipPluginLoader; | ||
use pocketmine\plugin\PluginBase; | ||
|
||
class Dummy extends PluginBase { | ||
public function onEnable(){} | ||
public function onDisable() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
namespace ZipPluginLoader; | ||
use pocketmine\plugin\PluginBase; | ||
use pocketmine\plugin\PluginLoadOrder; | ||
|
||
class Main extends PluginBase { | ||
public function onEnable(){ | ||
if (!in_array("myzip",stream_get_wrappers())) { | ||
if (!stream_wrapper_register("myzip",__NAMESPACE__."\\MyZipStream")) { | ||
$this->getLogger()->error("Unable to register Zip wrapper"); | ||
throw new \RuntimeException("Runtime checks failed"); | ||
return; | ||
} | ||
} | ||
$this->getServer()->getPluginManager()->registerInterface("ZipPluginLoader\\ZipPluginLoader"); | ||
$this->getServer()->getPluginManager()->loadPlugins($this->getServer()->getPluginPath(), ["ZipPluginLoader\\ZipPluginLoader"]); | ||
$this->getServer()->enablePlugins(PluginLoadOrder::STARTUP); | ||
} | ||
public function onDisable() { | ||
if (in_array("myzip",stream_get_wrappers())) { | ||
stream_wrapper_unregister("myzip"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
namespace ZipPluginLoader; | ||
use pocketmine\plugin\PluginBase; | ||
use pocketmine\plugin\PluginLoadOrder; | ||
|
||
class MyZipStream { | ||
// This is needed to work around bugs/incomplete features of the | ||
// built-in PHP Zip wrapper | ||
var $fp; | ||
var $path; | ||
public function stream_open($path,$mode,$opts,&$opened_path) { | ||
$this->path = $path; | ||
$zippath = preg_replace('/^myzip:/','zip:',$path); | ||
$this->fp = @fopen($zippath,$mode); | ||
if ($this->fp == false) return false; | ||
return true; | ||
} | ||
public function stream_close() { | ||
fclose($this->fp); | ||
} | ||
public function stream_read($count) { | ||
return fread($this->fp,$count); | ||
} | ||
public function stream_eof() { | ||
return feof($this->fp); | ||
} | ||
public function url_stat($path,$flags) { | ||
$ret = []; | ||
$zippath = preg_replace('/^myzip:\/\//',"",$path); | ||
$parts = explode('#',$zippath,2); | ||
if (count($parts)!=2) return false; | ||
list($zippath,$subfile) = $parts; | ||
$za = new \ZipArchive(); | ||
if ($za->open($zippath) !== true) return false; | ||
$i = $za->locateName($subfile); | ||
if ($i === false) return false; | ||
$zst = $za->statIndex($i); | ||
$za->close(); | ||
unset($za); | ||
foreach([7=>'size', 8=>'mtime',9=>'mtime',10=>'mtime'] as $a=>$b) { | ||
if (!isset($zst[$b])) continue; | ||
$ret[$a] = $zst[$b]; | ||
} | ||
return $ret; | ||
} | ||
public function stream_stat() { | ||
return $this->url_stat($this->path,0); | ||
} | ||
} |
Oops, something went wrong.