Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Add Forge permission handler #1660

Merged
merged 4 commits into from Jul 29, 2019
Merged

Add Forge permission handler #1660

merged 4 commits into from Jul 29, 2019

Conversation

kashike
Copy link
Contributor

@kashike kashike commented Jul 18, 2017

SpongeCommon | SpongeForge
#1049

@kashike
Copy link
Contributor Author

kashike commented Jul 18, 2017

@luacs1998: Could I get your input here? You're familiar with the Forge permission API.


@Override
public void registerNode(final String node, final DefaultPermissionLevel level, final String desc) {
// TODO

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Sponge have the concept of registering permissions?

Still trying to acquaint myself with the Sponge PermissionService, so...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the concept of creating descriptions which requires the mod/plugin, the permission node, and a description.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add on to this, descriptions can designate generic like permissions with placeholders for variable permissions. e.g. nucleus.teleport.world. to have per dimension permissions.

@yuuka-miya
Copy link

Looks okay to me, but if you want a second opinion - @LatvianModder?

return false;
}

// TODO contexts?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should we handle this? Sponge has a Context concept as well, not sure if we want to convert IContext data to a Context?


@Override
public Collection<String> getRegisteredNodes() {
return Collections.emptySet(); // TODO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep track of this, just for Forge mods wishing to get this?

@LatvianModder
Copy link

I guess this works. I wouldnt use that many lambdas in getNodeDescription, but that isn't used frequently anyway, so I guess its fine. Im ok, as long as it properly handles registered permissions. Only not sure why is that try{}catch{} required, just register your handler in PREINIT, and it will be fine, because mods are expected to register nodes in INIT+

try {
PermissionAPI.setPermissionHandler(this);
} catch (IllegalStateException ignored) {
RegistryHelper.setFinalStatic(PermissionAPI.class, "permissionHandler", this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is bad, if setting the permission handler fails then log it to the console as that likely means someone else is doing so. Let the server admin figure out how to proceed but don't blindly blow away another mod whose purpose is to do permissions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I actually agree with Sponge being the strongest permission handler (Config option for this would be nice tho), but I dont agree with aggressively changing the private field. You only should set permission handler in PREINIT state, as I said earlier. Hopefully this is changed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luacs1998 also suggested that we be the strongest. There's the possibility that another mod will replace our handler, so my thought was to do it after pre-init. I can add a config option to disable our replacing of other permission handlers if one is registered before Sponge.

@phit
Copy link
Contributor

phit commented Feb 10, 2018

@kashike status of this?

@BrainStone
Copy link

Yes, what’s the status on this? We still need a plugin for this.

@BrainStone
Copy link

Bump...

@tonnic
Copy link

tonnic commented Feb 15, 2019

please add this....we need this implemented

@maxanier
Copy link

maxanier commented Jun 7, 2019

What exactly has to be tested?
I could try to verify the general functionality by adding some Forge permission checks to a mod of mine. Then build this branch, setup a server with it, my mod and LuckPerms and check if LuckPerms can access the mod's permissions?

@gabizou
Copy link
Member

gabizou commented Jun 7, 2019

I could try to verify the general functionality by adding some Forge permission checks to a mod of mine. Then build this branch, setup a server with it, my mod and LuckPerms and check if LuckPerms can access the mod's permissions?

Correct

@maxanier
Copy link

maxanier commented Jun 8, 2019

So, I did that and (after I found out I have to enable this in the Sponge configuration) it works fine. I can give/deny the permissions registered by my mod using LuckPerms and they are correctly identified.

Only issue is that, the default permission level passed to the registerNode method is ignored and instead the default permission level is undefined (which results in deny).
Most, if not all, permissions introduced by my mod should be available to all players. So one would have to manually grant "vampirism.*" to every player/group. Before they are actually able to play the mod with this enabled.

However, since this has to be manually enabled anyway, I guess that is ok.
I am very happy there is finally a way to integrate mods with permission plugins.

@phit
Copy link
Contributor

phit commented Jun 8, 2019

you could already do so https://docs.spongepowered.org/stable/en/plugin/permissions.html#for-forge-mods you don't need this PR for that

@LatvianModder
Copy link

If I had known about this way before the Forge PermissionAPI PR was merged, I would have simply just added a hook in checkPermission() method for forge mods, which would make things 10000x easier. That's why I suggest to try this approach in 1.13/1.14+ and basically just not care about it in 1.12. Mods would most likely not care about it this late anyway, but if new PR was made for 1.13, maybe then things can change

@BrainStone
Copy link

BrainStone commented Jun 9, 2019

The Forge Permission API is pretty well used already on 1.12.2. So it would make sense to already implement it in API 7, so people don't have to use an unreleased version of an abandonned plugin that bridges the gap.
Keep in mind that 1.12.2 will be a long term version for modded MC.

@BrainStone
Copy link

@gabizou what's the holdup? This PR is a strict improvement of the project, has been confirmed to work and been reviewed by several people.

@Zidane
Copy link
Member

Zidane commented Jun 30, 2019

@phit has objections to merging this and can elaborate why.

@BrainStone
Copy link

Sure. Let's keep it rotting until it can't be merged anymore.

@pie-flavor
Copy link

@BrainStone oy. No need to be rude.

Copy link
Contributor

@ImMorpheus ImMorpheus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with FTB Utilities.
Tried to change ftbutilities.chat.nickname.set with Luckperms, everything is working as intended.

@ImMorpheus ImMorpheus merged commit 65f05e0 into stable-7 Jul 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet