Skip to content

Commit

Permalink
Update config getter to be lazy and avoid constant lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed May 28, 2024
1 parent 8f6c235 commit f331b5e
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,18 @@ default boolean shouldLoad() {
*/
abstract class Base<C extends ModuleConfiguration> implements CamelotModule<C> {
private final Class<C> configType;
private C config;

protected Base(Class<C> configType) {
this.configType = configType;
}

@Override
public C config() {
return CamelotConfig.getInstance().module(configType);
if (config == null) {
config = CamelotConfig.getInstance().module(configType);
}
return config;
}

@Override
Expand Down

0 comments on commit f331b5e

Please sign in to comment.