73 Commits

Author SHA1 Message Date
Dylan K. Taylor
6375139d0b
DefaultPermissions: improve readability slightly 2022-12-24 17:47:17 +00:00
Dylan T
567bd8abb5
Add .self and .other permissions for gameplay-altering commands (#5470)
I'm not quite sure this is the best way to enable such functionality, but it's already used for some other stuff, so I'm not too worried for now.

This allows the following commands to have their usage limited to self or others:
- /effect
- /enchant
- /gamemode
- /give
- /spawnpoint
- /teleport
- /title

I envision this being useful for creative mode servers, and test servers such as test.pmmp.io.
2022-12-24 17:22:18 +00:00
Dylan K. Taylor
51a684c0ea
PermissionParser: remove hardcoded default strings in defaultFromString() 2022-12-23 16:03:01 +00:00
Dylan K. Taylor
43e69041fc
PermissionParser: use constants for keys 2022-12-23 16:00:38 +00:00
Dylan K. Taylor
dce8bd6d21
CS: Standardize new with braces 2022-08-15 17:16:23 +01:00
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
c0b15de504
Modernize private static property declarations 2022-05-17 21:55:16 +01:00
Dylan K. Taylor
22edca610c
Modernize private property declarations in src/permission 2022-05-17 21:28:42 +01:00
Dylan K. Taylor
15425d01bc
BanEntry: clean up getString() 2022-01-28 21:53:28 +00:00
Dylan K. Taylor
ae03c70dfc
Replace disallowed operators in src/permission/ 2022-01-20 19:20:51 +00:00
Dylan K. Taylor
889d048ca3
Make use of Utils::assumeNotFalse() in a bunch of places
I've stuck to only doing this in the places where I'm sure we should never get false back. Other places I'm less sure of (and I found more bugs along the way).
2021-12-08 19:39:04 +00:00
Dylan K. Taylor
269231c228
Ban foreach(arrayWithStringKeys as k => v)
this is not as good as phpstan/phpstan-src#769 (e.g. array_key_first()/array_key_last() aren't covered by this, nor is array_rand()) but it does eliminate the most infuriating cases where this usually crops up.
2021-11-15 22:52:05 +00:00
Dylan K. Taylor
e34364412b
Replace InvalidStateException usages with InvalidArgument or LogicException 2021-11-02 16:05:54 +00:00
Dylan K. Taylor
aefa0afd7c
DefaultPermissions: Order registrations alphabetically 2021-10-12 22:17:46 +01:00
Dylan K. Taylor
ec2699ffee
DefaultPermissions: fix description of timings command permission 2021-10-12 22:16:20 +01:00
Dylan K. Taylor
7245d15abe
PermissionParser: Throw more specific exceptions 2021-10-05 19:57:26 +01:00
Dylan K. Taylor
ede4d58394
Automatic permission calculation on PermissibleBase construction
thanks to the PermissibleInternal/PermissibleBase architectural change, there's no longer any concern regarding cyclic refs.
2021-06-26 22:15:22 +01:00
Dylan K. Taylor
bf7d69b69e
Stop hardcoding permission names everywhere
using strings for permission names is nearly as shitty, but this is at least cross-referencable and statically analysable.
2021-06-26 19:14:51 +01:00
Dylan K. Taylor
408e29da90
Removed PermissionRemovedExecutor
this interface is just about the most pointless code in all of PM or Bukkit. In over 4 million lines of code on Poggit, a Google search and a GitHub search, I didn't find a single usage of it that wasn't just bukkit internals code copy pasta, a spoon, a port of PM/Bukkit/whatever into a different language, or someone's generated javadoc.
2021-06-12 21:55:59 +01:00
Dylan K. Taylor
b525f45bf8
Fixed CS 2021-06-12 21:51:08 +01:00
Dylan K. Taylor
8e1d27a719
Constrain types to PermissibleInternal on internal permission subscription methods 2021-06-12 21:28:19 +01:00
Dylan K. Taylor
bfcf4a25d4
Automatic cleanup of permission subscriptions on PermissibleBase destructor calls
this has gotten too complex ...
2021-06-12 21:12:39 +01:00
Dylan K. Taylor
666670bc6f
PermissionAttachment may now reference zero or more permissibles
this makes PermissionAttachment more and more like Permission, except that it doesn't have a name.
Right now, the only value of this API change is that it allows breaking references to dead Permissibles, but in the future it should be possible to reuse a single PermissionAttachment on multiple Permissibles.
2021-04-12 15:57:24 +01:00
Dylan K. Taylor
c61f66d973
Removed ext-ds dependency 2021-02-11 15:40:37 +00:00
Dylan K. Taylor
bcc3e87730
Timings: rename core timers to remove 'timer' from the names
this makes them shorter and more consistent.
2020-12-23 17:52:25 +00:00
Dylan K. Taylor
61de84373a PermissionParser: simplify code 2020-12-11 19:09:01 +00:00
Dylan K. Taylor
bee770ebf5 Drop nested permissions support in plugin.yml 2020-12-11 19:03:52 +00:00
Dylan K. Taylor
794bb0a71d PermissionParser: bail on encountering permissions whose names are not strings 2020-12-09 00:32:50 +00:00
Ifera
c4b47c6c06 Implemented /clear command (#3854)
closes #3854
2020-12-06 15:26:12 +00:00
Dylan K. Taylor
0bbceee86d PermissionParser: give permissions default FALSE if they don't specify their own default 2020-12-05 21:06:07 +00:00
Dylan K. Taylor
807474b3fb PermissibleBase: do not assign any permissions by default
there is no longer such a thing as a permission granted to 'everyone', since we're no longer limited to true/false/op/notop, and regular players are now assigned the pocketmine.group.user permission.
It's possible we might want to add more restricted groups than 'user' in the future, in which case it would be behaviour-BC-breaking to change the default assigned permissions when creating a new PermissibleBase. Therefore, it's better to not assign any permissions at all and let the caller decide.
In addition, this solves the problem of implied permission subscriptions and leak on PermissibleBase construction - if base permissions are provided, it should be expected that the permissible will subscribe to those permissions.
2020-12-02 15:56:54 +00:00
Dylan K. Taylor
b51c6e89b3 Introduced pocketmine.group.console
this is only used for /dumpmemory right now, but it's planned to be used for more stuff.
2020-12-02 13:35:48 +00:00
Dylan K. Taylor
c5e12bb11f PermissibleBase: simplify diff calculation 2020-12-02 11:29:45 +00:00
Dylan K. Taylor
506e76917e PermissionAttachmentInfo now includes a reference to the PermissionAttachmentInfo that caused its assignment (if any)
this allows plugins to easily identify which permission group caused a permission to be assigned (particularly if multiple groups might cause it).
2020-12-02 11:23:35 +00:00
Dylan K. Taylor
880635603c PermissibleBase: allow injecting more dynamic base permissions 2020-12-02 10:12:40 +00:00
Dylan K. Taylor
13e8854ec0 PermissibleBase: fixed express denying of a root permission not working
this only took effect when a permission was applied as a root. When overridden with a permission attachment, the problem did not manifest.
2020-12-02 01:39:43 +00:00
Dylan K. Taylor
f5bb5c1208 Permissible->recalculatePermissions() now returns a map of changed permissions with their old values 2020-12-02 01:13:19 +00:00
Dylan K. Taylor
0634426c26 PermissibleBase: compute permission diff, do not fire callbacks when diff is empty
this fixes AvailableCommandsPacket getting sent twice when adding a PermissionAttachment.
2020-12-02 01:09:29 +00:00
Dylan K. Taylor
6720e658bd Remove useless group permission nodes
the only value these have is for convenience, and a permission manager plugin can easily generate them by parsing the permission IDs.
2020-12-02 00:00:21 +00:00
Dylan K. Taylor
1905c01c87 PermissibleBase no longer circularly references its parent permissible
this was used for 2 things:
- to notify parent permissibles on recalculate permissions (not needed anymore thanks to callbacks)
- subscription to chat broadcast permissions (now handled separately, again using callbacks)

therefore, it's no longer needed for PermissibleBase to reference its parent, meaning that we can have one less circular dependency in our lives.
2020-12-01 18:46:39 +00:00
Dylan K. Taylor
8fb74258f4 Implemented a better method for detecting permission recalculation
this allows anyone to listen to permissions being recalculated, which is useful for stuff like broadcast channel subscriptions.
2020-12-01 18:23:42 +00:00
Dylan K. Taylor
c20893aa4b PermissibleBase: more robust cycle destruction 2020-12-01 17:57:55 +00:00
Dylan K. Taylor
d602547941 PermissionAttachmentInfo no longer references Permissible
since the only way to obtain PermissionAttachmentInfo via the API is from the Permissible API, it makes zero sense to ask the attachmentinfo for its permissible, since we obviously already had it to be able to get the info in the first place. Therefore, this is just another useless reference stopping Permissibles from being garbage-collected.
2020-12-01 17:38:30 +00:00
Dylan K. Taylor
d48af3f4ca Merge branch 'stable'
# Conflicts:
#	composer.lock
#	resources/vanilla
#	src/permission/BanEntry.php
#	src/permission/PermissionAttachmentInfo.php
2020-12-01 17:35:30 +00:00
Dylan T
6d8833ccd3
Removal of permission defaults (in favour of permission cascading) (#3937) 2020-12-01 17:13:54 +00:00
Dylan K. Taylor
d56cf35385 Permissions are now always false when permission calculation hasn't been done yet
lack of permission calculation means that child permissions might not have been set correctly, so this might lead to users being able to access things they aren't supposed to.
2020-11-28 21:55:26 +00:00
Dylan K. Taylor
3e9a37ca77 PermissionParser: remove unmaintained code 2020-11-28 20:51:09 +00:00
Dylan K. Taylor
ee7fad2271 PermissibleBase: fixed root permissible being unaware of changes in some cases
for example, Player->recalculatePermissions() was not called when a player's op status changed, nor when a permission attachment altered permissions (potential secvuln for broadcasting).
2020-11-28 19:22:30 +00:00
Dylan K. Taylor
c7961bfe90 Toss ServerOperator; PermissibleBase now tracks its own op status
as well as being simpler, this also allows some nice features, such as granting memory-only op state that goes away when the player quits the server.
2020-11-28 18:22:59 +00:00
Dylan K. Taylor
4439781124 Merge branch 'stable'
# Conflicts:
#	resources/vanilla
#	src/event/player/PlayerCreationEvent.php
2020-11-28 16:16:15 +00:00