WorldGuard

WorldGuard

8M Downloads

Incosistent access to books on Lecterns

Joo200 opened this issue ยท 5 comments

commented

Is your feature request related to a problem? Please describe.
Currently Lecterns are handled that way:

  • You need build permissions to add a written book to a lectern
  • You need interact permissions to read the book. only with chest-access explicitly set to deny it's not possible to take the book.

My current setup on the global region is: "use" to allow, "interact" to allow for group members.

My goal is to let player access lecterns to read books but don't take them.

Describe the solution you'd like
I'd like to change that behavior: chest-access to allow for adding and taking books to/from a lectern
Lecterns should be protected by default for cases where interact is set to allow. Setting chest-access explicitly to deny doesn't match the behavior of chests or furnaces.

Describe alternatives you've considered
Maybe add it to build flag? but chest-access should be the best one for that.

commented

https://github.com/EngineHub/WorldGuard/blob/master/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java#L1085

Yes, WorldGuard handles that. I checked that: If you have use permissions / the use flag is set, you're able to take the book.
The UseBlockEvent doesn't get blocked by the RegionProtectionListener because there has only one flag of use and chest-access has to be set to allow. (logical OR instead of AND)

commented

er, to be clear, use is more specific than interact. what's the goal of allowing use for all but denying interact for nonmembers? you can also just set chest-access deny for nonmembers (the documentation specifically goes over this) to prevent people from taking books.

also if i remember my initial 1.14 testing correctly, adding a book to a lectern fires an entity change block or whatever it's called, so we would probably have to specifically separate that out if we wanted to handle it under chest-access instead.

commented

without the use flag it's not possible to read lecterns. I changed the flag chest-access to deny for non-members on the global region and it seems to solve that issue. but that's a weird setup for that edge case.

I'm not sure why the interact flag is set to allow only for members, that's some year old legacy stuff i didn't touched because it was working. I have to have a closer look at that setup but I don't think it has anything to do with the lectern issue.

commented

does bukkit fire something when the player adds a book to the lectern?
kinda confused at the description because it implies that chest-access isn't already checked for taking it - it has since 1.14 came out.

commented

Okay, I found the issue with that:
The RegionProtectionListener combines the flags interact, use and chest-access for every player removing books from lecterns. Imo that should not be combined, it should only be chest-access. Like the inventory check.
There is currently no method in UseBlockEvent to determine that nicely,

Changing that line from
} else if (Materials.isInventoryBlock(type)) {
to
} else if (Materials.isInventoryBlock(type) || event.getOriginalEvent() instanceof PlayerTakeLecternBookEvent) {
does look dirty and I don't think that's a good way to fix that issue.