Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Timongcraft
Copy link
Contributor

@Timongcraft Timongcraft commented Feb 24, 2024

Made the optional string permission and negation state in the CommandPermission public

Made the optional string permission in the CommandPermission public
Copy link
Collaborator

@willkroboth willkroboth left a comment

Choose a reason for hiding this comment

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

Definitely works as expected.

Would it be useful to make these other methods in CommandPermission public?

https://github.com/JorelAli/CommandAPI/blob/46d1fa14990f9d3b6b9611e08f4e953f886291c9/commandapi-core/src/main/java/dev/jorel/commandapi/CommandPermission.java#L128-L143

I'm not sure if it is necessary to mention this method in the docs: https://commandapi.jorel.dev/9.3.0/permissions.html. Maybe at least add javadocs to the method now that it's public.

You could also add this change to the Changelog in the README:

https://github.com/JorelAli/CommandAPI/blob/46d1fa14990f9d3b6b9611e08f4e953f886291c9/README.md?plain=1#L418-L425

@Timongcraft
Copy link
Contributor Author

Probably don't, because the permissionNode can be null, and nullables should not be exposed according to the contribution guide and Skepter on Discord.
Also, does it make sense to update it in the 9.3.0 documentation since it is meant for 9.4.0? Should this even be documented?
And where would you want to add a Javadoc about this?

@willkroboth
Copy link
Collaborator

willkroboth commented Feb 24, 2024

Probably don't, because the permissionNode can be null, and nullables should not be exposed according to the contribution guide and Skepter on Discord.

Makes sense. I suppose you could also change the method signature of getPermissionNode to be an Optional. It might be helpful in the case when you want to check if the permission is OP or NONE. Although, CommandPermission objects with a non-null permissionNode should only be these constant fields since the constructor is private. So, a developer could just check if their CommandPermission object is equal to one of these.

https://github.com/JorelAli/CommandAPI/blob/46d1fa14990f9d3b6b9611e08f4e953f886291c9/commandapi-core/src/main/java/dev/jorel/commandapi/CommandPermission.java#L44-L52

The isNegated method is probably important though for telling the difference between has permissionA and does not have permissionA

Also, does it make sense to update it in the 9.3.0 documentation since it is meant for 9.4.0? Should this even be documented?

Yeah, you wouldn't change the old docs since the method wouldn't be public in 9.3.0. You'd change the source file here: https://github.com/JorelAli/CommandAPI/blob/46d1fa14990f9d3b6b9611e08f4e953f886291c9/docssrc/src/permissions.md. Then once the 9.4.0 docs are generated from the source files the change will be visible.

But also yeah, I'm not sure if it's a big enough deal to mention?

And where would you want to add a Javadoc about this?

I meant a Javadoc on the getPermission method. Public members should probably all have Javadocs, though I'm sure there's some places where they don't :P.

@Timongcraft
Copy link
Contributor Author

Timongcraft commented Feb 24, 2024

Makes sense. I suppose you could also change the method signature of getPermissionNode to be an Optional. It might be helpful in the case when you want to check if the permission is OP or NONE. Although, CommandPermission objects with a non-null permissionNode should only be these constant fields since the constructor is private. So, a developer could just check if their CommandPermission object is equal to one of these.

I wouldn't change the signature of getPermissionNode because, as you mentioned, they could just check with the static instances. And for those who, for any reason, use reflection to access it, it remains accessible.

The isNegated method is probably important though for telling the difference between has permissionA and does not have permissionA

Yea, makes sense.

Yeah, you wouldn't change the old docs since the method wouldn't be public in 9.3.0. You'd change the source file here: https://github.com/JorelAli/CommandAPI/blob/46d1fa14990f9d3b6b9611e08f4e953f886291c9/docssrc/src/permissions.md. Then once the 9.4.0 docs are generated from the source files the change will be visible.

But also yeah, I'm not sure if it's a big enough deal to mention?

It doesn't really fit in the docs, so I would just not mention it there.

I meant a Javadoc on the getPermission method. Public members should probably all have Javadocs, though I'm sure there's some places where they don't :P.

Makes sense. I thought you meant we should mention the change somewhere in the Javadocs.

@Timongcraft Timongcraft changed the title Exposed the string permission Exposed details of the CommandPermission Feb 24, 2024
/**
* Returns if the permission is negated
*
* @return the permissions negation state
Copy link
Member

Choose a reason for hiding this comment

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

"permissions" is missing an apostrophe.

@JorelAli JorelAli merged commit c1399a1 into CommandAPI:dev/dev Feb 26, 2024
@Timongcraft Timongcraft deleted the dev/expose-string-permission branch February 26, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants