Reworking protection system (test-event & move-location check) - #545
RedstoneFuture wants to merge 4 commits into
Conversation
| player.getActiveItem(), player, false, player.getActiveItemHand()); | ||
|
|
||
| // Checking build permission by test-event. (The block is generally not placed via 'callEvent()' method.) | ||
| Bukkit.getServer().getPluginManager().callEvent(placeEvent); |
There was a problem hiding this comment.
Might need to do something here for Folia users, since I dont think calling events directly like that works in their API... Something to check and investigate I think?
There was a problem hiding this comment.
Good point. Since you also support Folia, I'll have to find out about this first. I am not familiar with it.
|
I’m currently working on a framework to add a protection check for known restriction plugins. The plan is to support all currently implemented protection plugins (and more in the future). Support for Event-Call and Folia, as well as checks for PlotSquared and WorldGuard, has already been implemented. Once it’s finished, it’s up to you to decide whether you want to outsource the protection part. If not, I can understand that. You’ve already invested a lot of time in that part. The goal of my framework is to simplify the check and ensure that not every plugin has to go through the hassle of integrating with the restriction APIs. That’s the current status. https://github.com/RedstoneWorld/RedRestrictionHelper (work in progress) |
Description
With this PR I would like to suggest a different approach to checking building rights. Querying all rights plugins is currently inperformant and not completely correct due to the different scenarios (e.g. misc flags like
block-buildon WorldGuard; custom flags for WorldGuard & PlotSquared via add-ons; or custom features via add-ons for BentoBox). At the end, we are interested in whether the player is allowed to build at the corresponding location or not, right? So, I used a test event to check whether the player is allowed to build at the current Armorstand position and whether he is allowed to build at the target location of a Move event (if performed).I can see you had a lot of work to support the large number of protection plugins, but the current test seems to work well. The new check may be more correct for some cases, as it simply reflects the test result and does not refer to the theoretical processes of the individual restriction plugins.
Some other notes
By movements in the Y-achse the "lower block" is checked here. This is the same behavior as normal building protections (e.g. with WorldGuard).
The only weak point of this concept is that logging systems log the test-event. For example, it's logged by CoreProtect on location without AIR, by default. I don't see any good way to get around this.
Once the restriction has been tested for a while, we can minimize the
/protectionsfolder. Only the permission check ofasedit.ignoreProtection.<plugin>would then be necessary. (An OP check is not necessary, as the permission is already queried)./src/main/java/io/github/rypofalem/armorstandeditor/protections/WorldGuardProtection.java#L48-L49
I would like to point out that I am primarily looking for the best and safest option. In this case, it also seems to be the simplest solution. Provided it works equally well with all supported plugins.
[CORE] Changes
Changes to the core of the plugin - Performance Fixes, Bug Fixes, New Features, New Permission Nodes, New Config Options etc.
BlockPlaceEventtest event (performance and restriction improvements)canEditcheck for Move and Reverse-Move to prevent armorstands from leaving the region[CI] Changes
Changes relating to the Continuous Integration of other Plugin APIs, Github Workflows, Issue Templates etc.
[DOC] Changes
Changes relating to plugin Documentation - See the Wiki for more info
[MISC] Changes
Changes that does not fit in the above list
Dev-Test
Tested with:
1.20.6ArmorStandEditor-Reborn v. 1.20.6-46.2PlotSquared v. 7.3.8andWorldGuard v. 7.0.9forX,YandZmovements of armorstandsI am not familiar with all of the supported protection systems. Please feel free to report any errors you find with other plugins.
By making this pull request, I represent that I have the right to waive copyright and related rights to my contribution, and agree that all copyright and related rights in my contributions are waived, and I acknowledge that the ArmorStandEditor Project Owners have the copyright to use and modify my contribution under the ArmorStandEditor License for perpetuity.