-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the ability to change the text: Click to Unlock. As well as level and cost. #3977
Conversation
…lock - and Levels also Cost Code Changes a little bit with low knowhow it should be worked
Few Translations variables for Slimefun guide.click-unlock guide.cost guide.level
Pro Tip!
If your changes do not fall into any of these categories, don't worry. You can just ignore this message in that case! 👀 |
...main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java
Show resolved
Hide resolved
@@ -289,7 +289,7 @@ private void displaySlimefunItem(ChestMenu menu, ItemGroup itemGroup, Player p, | |||
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNoPermissionItem(), sfitem.getItemName(), message.toArray(new String[0]))); | |||
menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler()); | |||
} else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) { | |||
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)")); | |||
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a>" + Slimefun.getLocalization().getMessage(p, "guide.click-unlock"), "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.Cost") + research.getCost() + Slimefun.getLocalization().getMessage(p, "guide.Level"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the message key should be lowercase and use hyphens (-
) to connect words.
And I don't think string concatenation is good here, better use placeholder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No i should not be Lowercase it works with this setup! :)
After all, I tested everything before the request!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key should be lowercase, or it will break the naming convention.
Also, consider using a placeholder instead of concatenating 3 parts for the cost line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm did you mean "getMessage" or "getMessage(p, "guide.Cost")"
Should it be named getMessage(p, "guide.cost") ?
The red line shows the original.
Below is my slightly changed line
No placeholder was used there either. Do I know any placeholders that are marked with %? correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should be "guide.cost" the whole key should be lowercase.
As for the formatting and placeholders look at the javadocs or some examples for the String#format method to find how it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I need to read about it because the original code, i.e. the red line, doesn't use a placeholder either. It's actually a function query called research.getCost() its not a placeholder so please explain to me exactly what you mean by placeholders?
You can find the right messages.yml in src->main->resources->language->en |
adding 3 new message keys for the code in SurvivalSlimefunGuide.java
… myself as new Author
i hope thats now my taken changes are correct. i'm new in this scene and i do my best to understand the code structure. |
@@ -44,6 +44,9 @@ placeholderapi: | |||
|
|||
guide: | |||
locked: 'LOCKED' | |||
click-unlock: You Must Unlock This! | |||
cost: 'Cost: ' | |||
level: ' Level(s)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally dislike the space here, I think the language file should not include this space and move the space to the code. Not sure how other feels about this one. Any suggestion on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without the spaces the languagewords is combined so in the lore stands without them cost1Level(s)
So i add the Spaces for it.
i dont know how to add spaces in the code by "&7" + Slimefun.getLocalization().getMessage(p, "guide.cost") + research.getCost() + Slimefun.getLocalization().getMessage(p, "guide.level"))) in line 292 at SurvivalSlimefunGuide.java
so i add spaces in the message key to solve this. Even if it's probably wrong.
I'm still pretty new.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java
Outdated
Show resolved
Hide resolved
The "Level(s)" message should be "%level% Level(s)" and then format it like the other messages |
@@ -289,7 +290,7 @@ private void displaySlimefunItem(ChestMenu menu, ItemGroup itemGroup, Player p, | |||
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNoPermissionItem(), sfitem.getItemName(), message.toArray(new String[0]))); | |||
menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler()); | |||
} else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) { | |||
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)")); | |||
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a>" + Slimefun.getLocalization().getMessage(p, "guide.click-unlock"), "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.cost") + research.getCost() + Slimefun.getLocalization().getMessage(p, "guide.level"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add space before guide.click-unlock
would better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is what i whant to know how can i add spaces in the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"&a> " ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That workes with the space in the " " string.. but how can i add spaces in functions with the given code:
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a> " + Slimefun.getLocalization().getMessage(p, "guide.click-unlock"), "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.cost") + research.getCost() + Slimefun.getLocalization().getMessage(p, "guide.level")));
Also the hint from SchnTgaiSpock with the %level% dont work..
@@ -44,6 +44,9 @@ placeholderapi: | |||
|
|||
guide: | |||
locked: 'LOCKED' | |||
click-unlock: You Must Unlock This! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better keep the original Click to unlock
…sage Keys - Thanks to Idra Adding Spaces to the code for Message Keys - Thanks to Idra
…k to Unlock Remove Spaces and add the Orginal Text for Click to Unlock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These suggestions fix everything (tested them already).
click-unlock: Click to unlock | ||
cost: 'Cost:' | ||
level: 'Level(s)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
click-unlock: Click to unlock | |
cost: 'Cost:' | |
level: 'Level(s)' | |
click-unlock: | |
- '&4&lLOCKED' | |
- '' | |
- '&a> Click to unlock' | |
- '' | |
- '&7Cost: &b%cost%' | |
unlock-currency: | |
levels: 'Level(s)' |
@@ -289,7 +290,7 @@ private void displaySlimefunItem(ChestMenu menu, ItemGroup itemGroup, Player p, | |||
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNoPermissionItem(), sfitem.getItemName(), message.toArray(new String[0]))); | |||
menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler()); | |||
} else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) { | |||
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)")); | |||
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a> " + Slimefun.getLocalization().getMessage(p, "guide.click-unlock"), "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.cost") + " " + research.getCost() + " " + Slimefun.getLocalization().getMessage(p, "guide.level"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a> " + Slimefun.getLocalization().getMessage(p, "guide.click-unlock"), "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.cost") + " " + research.getCost() + " " + Slimefun.getLocalization().getMessage(p, "guide.level"))); | |
menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNotResearchedItem().getType(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), Slimefun.getLocalization().getMessages(p, "guide.click-unlock", str -> str.replace("%cost%", research.getCost() + Slimefun.getLocalization().getMessage(p, "guide.unlock-currency.levels"))))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we can use other ways to unlock in the future? i mean this PR: #3942
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would also create merge conflicts with that pr, so we could also make it translatable in that pr and close this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s out of scope tho. Creating merge conflicts isn’t the end of the world. And for bigger PRs like that it would be halted by extensive testing anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I guess we don't have to worry about other unlock methods in this pr and just have the other pr handle the changes to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if the line "Cost: (condition)" should be separated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would agree with that.
Putting these under a single key is more annoying to untangle later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I edited the suggestion. Is this better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not too sure how crowdin works but wouldn't those two empty lines show up as empty strings to translate? wouldnt break anything; just a little confusing
Slimefun preview buildA Slimefun preview build is available for testing! https://preview-builds.walshy.dev/download/Slimefun/3977/837590ef
|
i was going to test this but i couldn't ultimately see what was happening, and it seems to be a change of language, so someone who can read multiple languages would be better off testing |
Marking this as stale |
Closing this as stale |
Description
Because there was no possibility to translate a specific text. I installed IDE Eclipse and imported the repo and made a Maven project from it.
Proposed changes
In the file SurvivalSlimefunGuide.java I changed certain things in line 292.
I also added 3 values to Messages.yml
Related Issues (if applicable)
no Issues was found
Checklist