95 Commits

Author SHA1 Message Date
Dylan K. Taylor
48fa19fdcd PermissionAttachmentInfo::__construct() never throws an exception 2020-12-01 17:30:35 +00:00
Dylan K. Taylor
215bac8dd7 phpstan 0.12.58 2020-11-30 22:11:43 +00:00
Dylan K. Taylor
ef034f2d68 PermissionAttachment: better document the apparently nonsensical code responsible for making sure the entire permission system doesn't burn down 2020-11-28 16:05:16 +00:00
Dylan K. Taylor
ab18332572 PermissionManager: fixed nonsensical PHPDoc type 2020-11-27 19:54:05 +00:00
Muqsit Rayyan
189f12a644
PermissionManager: fix timings not being stopped for default calculation (#3502) 2020-05-17 08:55:11 +01:00
Dylan K. Taylor
25bc95cd1e removing more unnecessary casts 2020-02-06 19:33:34 +00:00
Dylan K. Taylor
1a5228e7a6 Fixed property types with missing null PhpDoc types 2020-02-05 20:55:03 +00:00
Dylan K. Taylor
495bfda044 Drop a bunch of invalid null defaults
phpstan doesn't report these out of the box, for reasons I'm not clear on. It's also not clear if having null defaults has any effect on nullability behaviour, so they are best removed. In addition, these would be problematic on 7.4.
2020-02-05 20:53:54 +00:00
Dylan K. Taylor
2f325b8c91 Permission: loadPermission() never returns null 2020-02-05 20:43:40 +00:00
Dylan K. Taylor
260ac47588 add some phpstan array types 2020-01-30 22:23:11 +00:00
Dylan K. Taylor
58bc08838b populate missing array value types in permission namespace 2020-01-30 21:14:18 +00:00
Dylan K. Taylor
f624871b3f strip extra blank lines (php-cs-fixer) 2020-01-22 14:50:29 +00:00
Dylan K. Taylor
9cd6b3e1c7 fix remaining multiline @var annotations 2020-01-22 14:44:36 +00:00
Dylan K. Taylor
9f44adf04a pass 2, manual removal of incorrect non-nullable @param for nullable native types 2020-01-21 15:44:34 +00:00
Dylan K. Taylor
c4793241f5 Mass removal of useless @param/@return PHPDoc annotations, pass 1 2020-01-21 15:10:18 +00:00
Dylan K. Taylor
facca13139 permission: populate missing return type information
PermissibleBase has some redundant phpdoc removed so that the Permissible interface can provide return types.
2020-01-19 17:23:52 +00:00
Dylan K. Taylor
97b6183404 PermissionManager: add native return types to private functions 2020-01-18 17:59:10 +00:00
Dylan K. Taylor
f069df65a8 PermissibleBase: added native returm types to private functions 2020-01-18 17:54:13 +00:00
Dylan K. Taylor
1eedac87b2 added missing @var property types (reported by phpstan) 2020-01-09 14:13:54 +00:00
Dylan K. Taylor
494660102e Replace empty() usages with count() 2019-12-18 11:23:24 +00:00
Dylan K. Taylor
a9fafbc5eb BanEntry: remove nullable return from parseDate()
this function never returns null
2019-12-12 11:59:41 +00:00
Dylan K. Taylor
43ebb23085 Permission: remove dead code from loadPermission() 2019-10-22 10:42:22 +01:00
Dylan K. Taylor
622f93df45 remove usages of deprecated {} string access, closes #3035 2019-07-22 16:39:33 +01:00
Johnmacro
66818e178a DefaultPermissions: Fix typos in permission descriptions (#2918) 2019-05-12 09:20:45 +01:00
Dylan K. Taylor
fdc3faadc9 Register two missing default permissions
this fixes the pocketmine.command node not having the expected effect in some cases.
2019-04-05 18:48:37 +01:00
Dylan K. Taylor
93969197f7 Enable status,gc,dumpmemory OOB
dumpmemory has been confined to console by default due to the hazards it poses to a running server.

closes #2528
2019-01-05 18:56:57 +00:00
Dylan K. Taylor
5dfceeea98 Fix typo in command.op.take permission description 2019-01-04 23:56:29 +00:00
Dylan K. Taylor
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
Dylan K. Taylor
acd7c9b336 Permission: Throw exception on unknown values in getByName()
Previously, writing wrong values into plugin.yml for permission defaults would cause the permission to be silently denied to everyone.
2018-12-01 15:56:44 +00:00
Dylan K. Taylor
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
Dylan K. Taylor
c83d12790e Merge branch 'release/3.1' into release/3.2 2018-09-14 17:09:41 +01:00
Dylan K. Taylor
5863d4c066 Fixed PermissibleBase->clearPermissions() not unsubscribing from permissions that aren't explicitly assigned
This came to light after observing cfb6856634f91930f6e013e7b98edb638dea15d9 in a fresh light. I noticed that this fix should not have been necessary because clearPermissions() should have dealt with it. Unfortunately, permissions can be set without being set in PermissibleBase->permissions, so this misses things.
2018-09-14 17:06:32 +01:00
Dylan K. Taylor
fe6d546190 Merge branch 'release/3.1' into release/3.2 2018-08-25 17:49:21 +01:00
Dylan K. Taylor
7dd53f2397 Replace unnecessary strlen > 0 calls with !== "" checks 2018-08-25 16:07:49 +01:00
Dylan K. Taylor
08be51dc23 Clear permissions on server reload 2018-07-26 10:40:28 +01:00
Dylan K. Taylor
9a2845640b
Permissions management cleanup (#2332)
* Added a new PermissionManager, remove ridiculous cyclic dependencies of Permissions on Server

Aside from all the other ridiculous design problems with the permission system, the biggest problems are its API. This is, once again, a result of poor API design copied from Bukkit.

This pull request removes all permission-related functionality from `PluginManager` and moves it to the `pocketmine\permission\PermissionManager` class.

As can be observed from the removed code in the diff, the permissions system was previously entirely dependent on the Server, because it needed to get the PluginManager for registering permissions. This is utterly ridiculous. This refactor isolates _most_ permission-related functionality within the `permission` namespace.

As mentioned above, this stupid API is a direct result of copying from Bukkit. If you look at the API documentation for Bukkit for `PluginManager` you will see that the methods I'm deprecating here are also in there.

## Changes
- Added a new `PermissionManager` class. This can be accessed via its singleton `getInstance()` static method.
- Deprecated the following `PluginManager` methods - these will be removed no later than 4.0.0:
  - `getPermission()`
  - `addPermission()`
  - `removePermission()`
  - `getDefaultPermissions()`
  - `recalculatePermissionDefaults()`
  - `subscribeToPermission()`
  - `unsubscribeFromPermission()`
  - `getPermissionSubscriptions()`
  - `subscribeToDefaultPerms()`
  - `unsubscribeFromDefaultPerms()`
  - `getDefaultPermSubscriptions()`
  - `getPermissions()`
2018-07-26 10:21:41 +01:00
Dylan K. Taylor
580f71d496 Permission: cosmetic reorg 2018-07-25 20:56:23 +01:00
Dylan K. Taylor
23829952c3 PermissibleBase: removed nonsensical code
it's not possible for this to be null, unless a child class doesn't call the constructor, and anything could break in that case anyway.
2018-07-08 13:04:51 +01:00
Dylan K. Taylor
05af87e1d4 Strip empty lines at the end of classes 2018-06-11 13:19:23 +01:00
Dylan K. Taylor
c4c6c58615 Added some missing typehints 2018-06-10 17:18:55 +01:00
Dylan K. Taylor
2b5e6b790f BanList: rename poorly-named parameter 2018-06-06 18:18:06 +01:00
Dylan K. Taylor
e081b7dffa PermissibleBase: fix typehints of calculateChildPermissions() 2018-06-05 11:14:36 +01:00
SOFe
ae0c1c185f
Fixed wrong doccomment for Permission::$children 2018-05-04 15:31:00 +08:00
Dylan K. Taylor
73e09392b6 Timings: Clean up some terrible code, move namespaces 2018-03-19 19:05:51 +00:00
Dylan K. Taylor
ac5a91b67e Cleaned up bool comparison mess 2018-03-19 14:10:55 +00:00
Dylan K. Taylor
0ad8ea6e92 Remove unused imports 2018-02-24 19:01:09 +00:00
Dylan K. Taylor
37e8c8d324 BanEntry: work around stupid bug in ext/date
https://bugs.php.net/bug.php?id=75992

When plugins do time-limited bans and users enter stupid time values, a shitty bug in ext/date gets triggered, but only when reading the ban entries from disk. DateTime->format() is able to produce formatted strings which have more than 4 digits in the year, which are then considered invalid. This works around it by trying to parse a formatted version on the fly to ensure that it is valid.

This also cleans up and improves ban list loading and handling.
2018-02-22 14:48:53 +00:00
Dylan K. Taylor
687886e70b PermissibleBase: remove useless destructor 2018-02-06 21:10:42 +00:00
Oreo Oreoniv
1b4b832c8c Added a getEntry() to BanList (#1830) 2017-12-21 10:08:56 +00:00
Dylan K. Taylor
4f8e4f0522
Add EOF newlines where missing (bulk) (#1836)
This should solve issues with people making GitHub PRs and having the web editor messing things up. GitHub Web Editor sucks :(
2017-12-20 11:56:36 +00:00