Error saving contexts with a lot of worlds
seb303 opened this issue ยท 9 comments
Description
Seems to be a 200 char limit for the contexts, which then causes an error when trying to set a permission for a large number of worlds.
https://gist.github.com/seb303/5c1dcf1c9c72c67f018dc9608d626a8b
Reproduction Steps
Set a permission context with a large number of worlds.
e.g.
world=blockcity world=creative world=creative_nether world=creative_the_end world=hermitcraft8 world=hermitcraft8_nether world=hermitcraft8_the_end world=piglincraft world=piglincraft_nether world=piglincraft_the_end world=survival world=survival_nether world=survival_the_end
Expected Behaviour
Unless there is a good technical reason to limit the contexts to max 200 chars, I would expect it to accept any reasonable number of worlds.
If the 200 char limit is unavoidable then it should at least catch and warn about the problem in the web-editor, rather than completely remove the permissions being edited.
Server Details
git-Paper-411 (MC: 1.17.1)
LuckPerms Version
v5.4.35
Logs and Configs
https://gist.github.com/seb303/5c1dcf1c9c72c67f018dc9608d626a8b
Extra Details
No response
Why would you set so many contexts if you can set it once globally, and set it another time in false for that one or two worlds you need to deny it in? That would reduce it to two shortened entries.
This is actually the least number of worlds. There's a default value of "false" set for all worlds on the server (which has a lot of worlds), and this is the exception list which should be set to true.
Additionally, from a permission point of view it would be risky to do it the other way around: imagine we add a new bedwars minigame or something and players can use tpa by default because we forgot to adjust the contexts for the tpa command.
Have you considered using world rewrite to bundle worlds together into a group that definitely always have the same set of permissions? If that doesn't seem like something you'd want to do, there is nothing stopping you from increasing the character limit. I've never seen anyone ever hitting 200 so it makes sense to use that as default.
Didn't know about world-rewrite. Sounds perfect for managing sets of similar worlds, thank you :)
I'm not sure how I would increase the character limit though as this seems to be hard-coded into the database schema (it uses VARCHAR(200) for the CONTEXTS column).
In generic terms, you use the ALTER TABLE command followed by the table name, then the MODIFY command followed by the column name and new type and size.
Here is an example: ALTER TABLE tablename MODIFY columnname VARCHAR(600) ;
The maximum width of the column is determined by the number in parentheses. If you use phpmyadmin, you can change it there as well.
World rewrite sounds a little safer to me though. I asked someone who works with this kind of stuff on a daily basis and he says for a varchar one, increasing the limit shouldn't be a problem on a proper database. I won't vouch for it - I never tried that myself. So your pick x)
Thanks for the reply.
I'm using H2 database format so it's not easy to edit the data directly. I also wouldn't feel comfortable changing the default data schema just in case there are other parts of LuckPerms which may be expecting the contexts to be limited to a certain length.
As you say world-rewrite sounds safer :)
Ah, I was thinking you are using mysql. Yea then that's not really an option. H2 is hard to get into. Best of luck with world rewrite ;)
I added:
world-rewrite:
blockcity: tpa_enabled
creative: tpa_enabled
creative_nether: tpa_enabled
creative_the_end: tpa_enabled
hermitcraft8: tpa_enabled
hermitcraft8_nether: tpa_enabled
hermitcraft8_the_end: tpa_enabled
survival: tpa_enabled
survival_nether: tpa_enabled
survival_the_end: tpa_enabled
piglincraft: tpa_enabled
piglincraft_nether: tpa_enabled
piglincraft_the_end: tpa_enabled
Now I can just set context world=tpa_enabled
for all the tpa command perms.