Closed NewbieOrange closed 3 years ago
Hi @AtriusX, any thoughts?
@NewbieOrange Thanks for the interest in the project! I'll take a look over this one shortly, going to get to the smaller PRs you sent first.
Added a comment to commit 0abd193
Does commit 8118eae break expected behaviour?
Does commit 8118eae break expected behaviour?
I can't really confirm but I don't see why it would break. Should test it just to be safe though.
Will be going offline shortly, so any changes afterward will be looked at in the morning. 👋🏼
We still have to add an update to the README file, but otherwise we can try testing things as they are. @Sepshun mind giving this a look?
This is taking a while as I'm trying to rather extensively test it, since this is a decent sized system being implemented. So, a few points:
I'm noticing one small inconsistency though, not sure if this is intentional or not but upon changing the localization value through /ws config localization [language]
, it doesn't reload and take effect immediately, though every other config value type does.
You could just run the reload command to and that'd take care of it, but afaik it does this for every value other than localization.
Potentially unrelated to this PR but rather the way we have the WarpState system setup, but no error is being displayed at all on a warp that has been severed/broken.
Other than this, everything else functions incredibly well!
Yes, I noticed that no message is displayed when the link is severed, a seperated issue tho (not caused by this PR, hopefully).
I'm noticing one small inconsistency though, not sure if this is intentional or not but upon changing the localization value through
/ws config localization [language]
, it doesn't reload and take effect immediately, though every other config value type does. You could just run the reload command to and that'd take care of it, but afaik it does this for every value other than localization.
Maybe this has to do with the localization class not being stored within the config itself? A solution to this might be to retrieve the current locale within the get
operator of the class and reload if it is different. Otherwise we can just assign the update by moving the storage of the class into the configuration instead of using Locale
.
@NewbieOrange Any thoughts on updating LocaleParser
to store Localization
objects instead? This would remove the need to manually reload it since the object would be regenerated each time the option is updated.
I am thinking about make Property have something like onUpdate() and we can pass localization.reload() as an argument, which the Property will call on update.
That could work too actually, try that out if you'd like
@NewbieOrange Looking at the code you might just need to apply this to the relevant files?
class Property<T>(
property: String,
default: T,
private val parser: ArgumentParser<T>,
private val onUpdate: () -> Unit = {}
) {
// ..........
operator fun invoke(input: String?): Boolean {
value = parser.parse(input) ?: return false
onUpdate()
return true
}
And then apply this to the configuration:
val localization: Property<Locale> =
Property("localization", Locale.ENGLISH, LocaleParser) {
localization.reload()
}
From what I can tell, this might also remove the need to explicitly call localization.reload()
in the reload command based off how the ConfigManager
reloads data. (It might actually call onUpdate
automatically as a result.
I have updated the code as you suggested, was busy working on other stuff.
I don't have time to test whether it work or not yet.
That's fine, @Sepshun can test the update for us again. Once we know that this works then we just need an update to the README
file I think.
Seems to be working perfectly!
@NewbieOrange can you add the option to the README file? I think that should finish things off.
Added the option to README. Note that English is not my first language, feel free to update the description.
Make all messages / actionbars / item displayname and lore customizable.
Some minor modifications were done to internal data classes to facilitate this.
This PR will close #3.