Hello! How to get plugin path? Example: (server-path)/plugins/Example.phar And.... How to create phar, if phar.readonly is enabled? I can use other websites?
Read the docs next time before you post. https://github.com/PocketMine/PocketMine-MP/blob/mcpe-0.12/src/pocketmine/Server.php#L331 #ReadTheDocs #UseTheSearchBar
I want to the plugin creates phar, аnd I can do this with pmt.mcpe.me I think this has other answers..
In your plugin code: PHP: $phar = $this->getFile(); Note that getFile is a protected function so only works on your plugin.
Actually, to get the path of your current running phar, it is simpler to use: PHP: Phar::running(false) Note that it may return something strange if you are not in a phar.
I am not sure, but try this: PHP: /** @var \pocketmine\plugin\Plugin $plugin */$class = new \ReflectionClass($plugin);$filename = $class->getFilename(); So, you should be able to find out the phar file by this: PHP: $path = substr($filename, 7);if(Utils::getOS() !== "win") $path = "/" . ltrim($path, "/");else $path = str_replace("\\", "/", $path);// WINDOWS I HATE YOU$truncated = $path;while(true){ $truncated = substr($truncated, 0, strrpos($truncated, ".phar/") + 5); if(is_file($truncated)) break;}if(is_file($truncated)){ $phar = realpath($truncated); // execute logic}else{ // something really wrong has attempted. android.util.Log.wtf}
Anything. For example, you can create a new plugin loader that loads plugins from the internet (or is that PocketMine-Soft?).
This class has a method that gets the plugin path. https://github.com/alejandroliu/poc...r/GrabBag/src/aliuly/grabbag/CmdPluginMgr.php
Sorry was on a phone, so couldn't get the right link out. See here: https://github.com/alejandroliu/poc...src/aliuly/grabbag/CmdPluginMgr.php#L353-L360
That's hacky. What if the field name is changed from `file` to something else? You can use reflections to make the use of getFile() accessible though, since it is part of the API. But that other plugin has the right to change getFile() into something that does something else, since it is a protected method that is supposed to be used only by that plugin.
Yes, it is hacky. Then again, anything that works around protections is hacky. The proper way is if that the API were to make that function public. BTW, I got this method of obtaining the phar file from DevTools.