Giving commands in a forge mod permissions compatible with sponge permission system

Hello, I’m working on a small forge mod for my 1.12.2 server that adds in some commands. I am not using sponge to create the plugin, because the server is running the Direwolf20 1.12.2 pack and Sponge is not currently stable enough for the version. I’m curious how I can give commands in my forge mod permission nodes that will be compatible with the Sponge permission system, as I may be using it in the future and I would like there to be compatibility.

SpongeForge takes care of that conversion, which is just one of the reasons why the Sponge API is compatible (mostly :wink:) with Forge. You can take a look at the permissions docs to get an understanding of how permissions work in Sponge fundamentally, but I’ll reiterate two of the main points and add a third of my own below.

  • Your permission should be in the format <mod-id>.<group>.<subgroups>.... All permissions for your plugin should start with your mod id to minimize conflicts with other mods. You should then group related permissions together so it follows a logical pattern and allows users to give permissions for an entire group easily.

  • Sponge does not use wildcard (*) permissions. Some mods have a permission structure such as mod-id.command and mod-id.command.some-admin-perm. By giving a subject mod-id.command, they will also receive that administrator permission because it’s under the same group. I personally use mod-id.command.base for the base permission of the command, but feel free to use whatever you’d like so long as it has the same effect.

  • If you have a permission node that is used for anything other than a single permission, break it up into subgroups. Don’t have a mod-id.admin permission for everything you think is admin worthy - use sub-permissions to allow the user to make that decision for themselves.

I also appreciate the effort you’re taking to make sure that your mod is compatible with Sponge - I think that’s a huge step in the right direction to solving some of the fundamental compatibility issues with Forge mods. Keep up the good work and best of luck to you with your mod!

So, I just need to register the permission via the forge PermissionAPI.registerNode() and it will work?

Not even that, forge permissions are currently not used. Simply having a command is enough for sponge to make a node for it. Though there is an open PR to add direct Forge permission integration https://github.com/SpongePowered/SpongeForge/pull/1660

So you’re saying if I register a command /tpa, sponge will make a permission that is “modid.tpa”?

1 Like

It’s modid.command.tpa.

1 Like

Does this also work with KCauldron by any chance? im trying to make it so my friends can use the veinminer command to switch the mode but permissionsex is blocking the command for them.