SimpleTowns

SimpleTowns

5.5k Downloads

Switch from instantiating permission objects for every permissions check

zml2008 opened this issue · 9 comments

commented

Creating a new permissions object is a fairly expensive operation involving recalculating permissibles for any player. What you use in your plugin is the most inefficient way to access Permission objects, creating a new instance for every check. This is enough of a performance problem that users are opening bugs on PEX complaining about it.
There are (at least) two ways to go about fixing it.
a) Use string lookup for permissions. This is probably the simplest (and what most plugins do)
b) Fetch permission objects from Bukkit's cache -- plugin.getServer().getPluginManager().getPermission(String); This can be helpful if you want to access details of permissions other than the node.

commented
commented

(Apologies, git had a little fun with the whitespaces..)

commented

@zml2008 hows it looking now? :)

commented

I'm half asleep still, check the actual solution.

commented

Looks better, but Bukkit has its own store of Permission objects -- Bukkit.getServer().getPluginManager().get- /addPermission(Permission). Those should be used instead to capture the plugin.yml information about the permissions.

commented

might want to add an additional check to addPermission if the returned
permission is null just to prevent that possibility.

On Thu, May 15, 2014 at 7:40 PM, Mark Hughes [email protected]:

I'm half asleep still, check the actual solution.


Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-43289754
.

commented

oh, didn't see that part. If that's there, then that fix is good.

On Thu, May 15, 2014 at 8:28 PM, Mark Hughes [email protected]:

Do you mean, even though is check is in place?

https://github.com/MarkehMe/SimpleTowns/blob/cfae27350d594688d9863ebbcf84f98305dead25/SimpleTowns/src/com/gmail/jameshealey1994/simpletowns/permissions/STPermission.java#L104-L107


Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-43292518
.

commented

Excellent! Thanks for your help, it's appreciated.