45 Commits

Author SHA1 Message Date
Dylan K. Taylor
20a5b75622 PluginBase: fixed error always being emitted on saveConfig()
This now throws exceptions... let's let the caller deal with this instead, it makes more sense anyway
2018-07-26 19:14:16 +01:00
Dylan K. Taylor
dc29b4dc3f Merge branch 'release/3.2' 2018-07-21 15:57:56 +01:00
Dylan K. Taylor
40c28f4d26
PluginManager: Automatically create data directories for plugins (#2284) 2018-07-21 15:57:37 +01:00
Dylan K. Taylor
599a64c80c Merge branch 'release/3.1' 2018-07-12 19:32:14 +01:00
Dylan K. Taylor
1d5c741f28
PluginBase: Automatically save default config if it doesn't exist (#2285)
I wasn't sure whether this would be considered a bug fix or a feature. Nonetheless, it's a behavioural change, so it belongs in 3.1 if anywhere.

Prior to this, plugins would be required to call saveDefaultConfig() before calling getConfig() or anything else. Calling getConfig() without saveDefaultConfig() first would generate an empty configuration file. Instead, it now saves the default config before loading it.
2018-07-12 19:25:48 +01:00
Dylan K. Taylor
b23c947060 Merge branch 'release/3.1' 2018-07-06 13:12:22 +01:00
Dylan K. Taylor
34e9e93210 PluginBase: fixed crashing on getConfig() when data dir doesn't exist
I considered making this instead save the default config instead of creating an empty config file, but that would be (albeit minor) a behavioural change which therefore belongs in 3.1.
2018-07-05 19:59:08 +01:00
Dylan K. Taylor
49bca0d5a1
Remove a whole bunch of crap from the Plugin public interface (#2268)
- remove onLoad(), onEnable(), onDisable()
- remove Config related methods
- remove getResource(), saveResource(), getResources()

did I troll any readers so far?

On a more serious note, these methods do not need to be declared in this interface because they are either hooks (`onLoad()`, `onEnable()`, `onDisable()`) or methods only used from within `PluginBase` and its children. They are not intended to be public API, and for this reason they don't need to be exposed in the interface.
2018-06-29 20:04:10 +01:00
Dylan K. Taylor
7b7be9618c PluginBase: fixed plugin task timings showing "Unknown" for plugin name 2018-06-21 12:05:30 +01:00
Dylan K. Taylor
5a55d434ab Nuke plugin loaders from orbit
This features a near-total rewrite of PluginLoaders and some code associated with them.

Highlights:
- PluginManager->registerInterface() does not return anything, and now accepts a PluginLoader instance instead of a string.
- PluginLoader itself is drastically simplified. getPluginFilters(), enablePlugin() and disablePlugin() are now removed. loadPlugin() responsibilities are now solely confined to doing whatever is necessary to make the plugin's classes visible by the server, and does not emit log messages or check for data directories.
- PluginBase->init() and PluginBase->isInitialized() have been removed.
- Plugin interface now declares a signature for the constructor which implementations must comply with.
- Plugin interface now declares setEnabled().
2018-06-12 10:23:49 +01:00
SOFe
8704d378d4 PluginBase::getResources() returns associative array (#2193)
Now, it has string keys, which is the path of the resource file relative to the resources folder.
2018-06-11 11:06:54 +01:00
Dylan K. Taylor
c4c6c58615 Added some missing typehints 2018-06-10 17:18:55 +01:00
Dylan K. Taylor
51f43fb375 Removed global ServerScheduler - plugins now get their own isolated schedulers
This change breaks pretty much all API pertaining to synchronous task scheduling.

Significant changes:
- Server->getScheduler() has been removed
- Plugin->getScheduler() has been added - every plugin now has its own scheduler
- Because schedulers are now per-plugin, it is now unnecessary for PluginTask to exist because stopping plugin tasks on plugin disable is as simple as destroying the plugin's scheduler. Therefore PluginTask has now been removed and it is expected for things to now use the base Task class instead.

For the most part, plugins will simply need to change Plugin->getServer()->getScheduler()->... to Plugin->getScheduler()->...
Another highlight is that plugin tasks now no longer have global IDs - they are unique to each scheduler.
2018-05-30 14:11:11 +01:00
SOFe
5552704922
PluginBase->getResources() should only return files
Directories should not be returned. Previously it even returns resources\.. according to my test on Windows.
2018-05-21 17:25:57 +08:00
SOFe
c7ac5dfd4b
Fixed the doc comment in Plugin::getResources()
It returns SplFileInfo[] not string[]
2018-05-21 17:24:12 +08:00
Dylan K. Taylor
ac5a91b67e Cleaned up bool comparison mess 2018-03-19 14:10:55 +00:00
Dylan K. Taylor
dbb92096e4 More typehints, documentation fixes and static analysis cleanup 2017-07-15 12:12:06 +01:00
Dylan K. Taylor
c3b8be3f60 and more typehints 2017-07-14 10:56:51 +01:00
Dylan K. Taylor
46a2e6cbf8 Some breaking changes for plugins >:D 2017-07-14 08:52:27 +01:00
Dylan K. Taylor
2a7b736f18 Heap of bugfixes, cleanup and PHP 7 upgrades 2017-07-13 19:18:56 +01:00
Dylan K. Taylor
a73c6f1861 Fixed some unnecessary FQNs in docs 2017-06-25 12:43:04 +01:00
Dylan K. Taylor
a365c831a8 Fixed some doc problems 2017-06-25 12:07:28 +01:00
Dylan K. Taylor
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
Sandertv
1c7773c5f1 Visibility keyword before final or abstract keyword. (#814) 2017-04-13 20:58:53 +08:00
Dylan K. Taylor
1cb96d24ce Some fixes, thanks PhpStorm 2017-01-04 11:29:24 +00:00
SOFe
175dd0efa6 PhpStorm inspections
Fixed some minor bugs and dropped some obsolete code

pocketmine\level\generator namespace is ignored in this commit
2016-12-14 21:49:35 +00:00
PEMapModder
b766b969e2 Merge pull request #3387 from PEMapModder/patch-6
Allow saving resources with parent directory being recursively created
2016-02-27 20:52:03 +08:00
PEMapModder
b66ce90c94 Add return value for PluginBase::saveDefaultConfig() 2016-01-16 11:39:11 +08:00
PEMapModder
4e0fc6d1de Allow saving resources with parent directory being recursively created 2015-08-18 10:20:04 +08:00
Shoghi Cervantes
24c6cca664
Updated RakLib, fixed help message not showing command, added documentation to Plugin->getResource() 2015-01-14 17:23:16 +01:00
Shoghi Cervantes
ed02026815
Improved file resource usage 2015-01-06 19:04:24 +01:00
Shoghi Cervantes
f46473bbe8
Removed all @mkdir() calls 2015-01-02 18:52:45 +01:00
PEMapModder
1bd9cbd4d3 Update documentation of PluginBase::getCommand() for IDEs' auto completion 2014-12-13 20:42:23 +08:00
Shoghi Cervantes
79e864f4f1 Added far-generated loaded chunk to garbage collection 2014-07-14 12:46:03 +02:00
Shoghi Cervantes
694ccf2bc5 Fixed /reload 2014-06-14 18:46:40 +02:00
Shoghi Cervantes
7bd6f2ed91 Added Logger interface, threaded MainLogger and updated PluginLogger 2014-05-28 23:46:56 +02:00
Shoghi Cervantes
6cbd39de9b Added Inventory interfaces and types, updated long array() to [] 2014-05-22 18:59:16 +02:00
Shoghi Cervantes
6328834681 Make PluginBase::getResource() return a file pointer instead of the file contents 2014-05-19 20:14:31 +02:00
Shoghi Cervantes
4098252ec7 Use CommandExecutor by default on plugins :P 2014-04-05 21:44:29 +02:00
Shoghi Cervantes
6d58f32c91 Added PluginLogger 2014-04-05 00:20:09 +02:00
Shoghi Cervantes
80f9093875 Added /reload command (does not reload source code) 2014-04-03 15:49:00 +02:00
Shoghi Cervantes
04917ecd5a Added correct PluginIdentifiableCommand 2014-04-03 13:08:11 +02:00
Shoghi Cervantes
83eb032393 Fixed plugin resources 2014-04-02 23:48:00 +02:00
Shoghi Cervantes
a38d300616 Updated PluginBase::getResources() for Phar plugins 2014-04-01 12:18:27 +02:00
Shoghi Cervantes
dd17652aca Fixed wrong paths 2014-04-01 05:06:12 +02:00