-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Refactor Feature to have a common, supporting FeatureBase #60
Conversation
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 few comments
common/src/main/java/com/wynntils/features/SoulPointTimerFeature.java
Outdated
Show resolved
Hide resolved
A few days ago, I was working on automated feature registry with reflection code. I didn't get far though, I only tested a few libraries for scanning for classes ( Do you think that Second thing, in the LR PR (#50) we had disagreements about how we could easily enable and disable features. Maybe we could add framework for that as well. I remember Incompleteusern mentioned that we need an easy way to be able to turn on and off features (for configs), and I agree. Currently we only have the list of the features. In the LR PR, I changed that to be a Map, so we could access feature instances more easily. Do you think there is a better solution to that (as you mentioned that you did not like those changes)? |
I think we should either use the |
@kristofbolyai We can probably revisit how we registers Features. I'm not convinced we should replace the explicit registration, but maybe. In any case, let's do that separately. Feature enabling/disabling will need to be a thing, yes. I think it feels like it's quite tightly coupled to configuration. Like when you enable a feature, you can also chose to configure it. Did anyone look at if we could use any of the existing config frameworks (like Cloth or whatever they are called nowadays), or if we should port over the old? The biggest advantage of the old config system is the visuals, I think. It does not look Vanilla at all, but it ties in quite nicely with the Wynntils/Wynncraft look. The part how this is tied in with the actual variables carrying the configuration could certainly do with some changes, though... |
I am pretty sure we concluded that we should port the old one or make a new one, and that frameworks do not fit our needs. (it's a discussion in the Configs PR, which was closed) |
The problem with the Map for features in the Lootrun PR, I think, is that it's a kind of special thing that we want to "dig up" a Feature instance from the outside. I don't really like that. Nobody should really "depend" on a Feature, so they should not care about getting access to a Feature instance. And if we really, really, need it, this should be solved within the feature. Perhaps the LootrunFeature constructor could set a public static |
if we're going to group config values in their respective Feature classes, i think having some way to access the instance of a feature would be useful regarding our old config stuff, i would disagree that the gui was designed well - it was pretty cramped and difficult to navigate, in my opinion |
@P0keDev The Features are available from the registry. So if you want to loop over all features and setup configurations, that is no problem. The problem is if you want to access the instance of a specific Feature. But I think that is, essentially, misguided. |
Features should be one instance |
well accessing a specific feature would be required to access config variables inside it, no? unless you think the whole idea of keeping config values inside features is misguided (referring to code outside a feature that might depend on its settings) |
@P0keDev @kristofbolyai @Incompleteusern Any more comments, or is this good to be committed? |
Should code outside a feature depend on feature settings? Isn't the whole point of them being separated into wynncraft / Minecraft and feature so that stuff like that wouldn't happen? Could you give an example of where this would happen for example? (if I'm completely wrong sorry I'm a little outside the loop and need to catch-up) |
|
The Features had a lot of duplicated code just to get the framework up. I've created a more useful abstract base class, FeatureBase, which makes the actual features just having to declare if they need key holders or subscribe to events.
Now the simplest features has really obvious and transparent functionality, with all the boilerplate hidden.
I've also applied some additional cleanup/refactoring, like adding {} after if statements, and better enforcing of the "if TEST return" pattern we've been using.