BentoBoxWorld / Border

Adds a world border around islands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Island border perms conflicting with LuckPerms

wellnesscookie opened this issue · comments

Description

Describe the bug

I tried without Luckperms:

  • /is border command toggles the border just fine

With luckperms:

  • You execute /is border once
  • Border becomes disabled
  • You execute /is border for the second time
  • It becomes enabled
  • Execute /is border for the 3rd and every next time:
  • It says "enabled"

Research I've done:

I have been investigating the source code for a while, and I debugged it.

User.java in BentoBox's API:

public boolean removePerm(String name) {
      for (PermissionAttachmentInfo p : player.getEffectivePermissions()) {
          if (p.getPermission().equals(name) && p.getAttachment() != null) {
              player.removeAttachment(p.getAttachment());
              break;
          }
      }
      player.recalculatePermissions();
      return !player.hasPermission(name);
  }

If you have LP running p.getAttachment() will return null for some reason, and it will never get to successfully remove it, but meanwhile checking the /lp user <user> permission checkinherits bskyblock.border.off - will say that the player has the permission set to true, but /lp user <user> permission info will not list it.

I have checked, and my luckperms has enabled:

# If the plugin should apply attachment permissions.
# Other plugins on the server are able to add their own "permission attachments" to players. This
# allows them to grant players additional permissions which last until the end of the session, or
# until they're removed. If this option is set to false, LuckPerms will not include these attachment
# permissions when considering if a player should have access to a certain permission.

apply-bukkit-attachment-permissions: true

Expected behavior

  • It's obviously conflicting with LP, but I tried tinkering with LP config options and I cannot get it to work. I am still not sure if BBox is properly managing the permissions. I have seen the proper usage of removing permission on this site. What they do, when they addAttachment permission to the player, they also store it in a HashMap<UUID, PermissionAttachment>, and later if they wish to remove, they don't stream through effective permissions of a player, but rather access the permissionAttachment value directly from the map according to player's UUID as a key, and then they remove it. I made changes to IslandBorderCommand class to work like so, and I got the problem fixed.

Example of my class IslandBorderCommand class: here

Environment

Output of /bbox version (Mandatory)
[23:07:30 INFO]: Running PAPER 1.16.4.
[23:07:30 INFO]: BentoBox version: 1.15.3-SNAPSHOT-LOCAL
[23:07:30 INFO]: Database: JSON
[23:07:30 INFO]: Loaded Game Worlds:
[23:07:30 INFO]: skyblock (skyblock): Overworld, Nether, The End
[23:07:30 INFO]: Loaded Addons:
[23:07:30 INFO]: Border 2.0.1-SNAPSHOT-LOCAL (ENABLED)
[23:07:30 INFO]: BSkyBlock 1.14.3 (ENABLED)

Plugins (Optional)

[23:07:43 INFO]: Plugins (5): BentoBox, E2, LuckPerms, Multiverse-Core*, VoidGenerator

Additional context (Optional)

  • I have also recompiled BentoBox with changes in User#addPerm method, to recalculate the permissions after adding the attachment, but I am not sure if it was necessary. I was tracing down the problem for hours, I hope you can tell me what is wrong with my setup with LuckPerms and what can be changed, if it's not BentoBox's way of permission managment to blame. If the problem is with luckPerms, I will report the issue to them, and if there's no help, I'll just keep updating a local build of IslandBorder.jar for our own usage.

Thanks. I'm actually going to change the way this is done, because using permissions is not working well and is kind of a misuse of that API. What I plan to use is a new metadata API that I'm adding to BentoBox where it will be possible to set persistent metadata on Users and Islands.

So, please wait a while and you'll see that available soon.

I see you released a new version, so we are good to use it now?

Yes, please do so.

For the time of testing on my local host, I couldn't find a flaw, it's perfect! :3
We are restarting our SkyBlock on 5th of January, and so, players will also stress test this version of border themselves.

If you want, you can keep the task open until then if you wish a better feedback. If not, feel free to close, as I will be sure to reopen it anyway if something is wrong.

PS: Also, this will be the first time we are using Border from BBox and not from external plugin. Expect suggestions and reports on other stuff as well! 😄

Hii,

Just to let you know that everything works perfect for now. More than 200 players stress-tested it and reported no problems for now.