VelixDevelopments / Imperat

Military grade command dispatching framework
Other
20 stars 1 forks source link

[NEW FEATURE] Functional Dependency injection #1

Closed Mqzn closed 1 month ago

Mqzn commented 1 month ago

Functional Dependency injection

Injecting fields as a dependency inside of command classes without the need for adding them to your constructor.

Registering the dependency injector

imperat.registerDependency(SomeDependency.class, ()-> new SomeDependencyClass());

Injecting dependency example:

@Command("test")
public final class TestCmd {

 @Dependency 
 private SomeDependencyClass field;

}
iiAhmedYT commented 1 month ago

It can't be final brother, it just can't

Mqzn commented 1 month ago

It can't be final brother, it just can't

Yea, noticed the mistake here and edited it, thanks for telling me.

Mqzn commented 1 month ago

Added in Commit Added Functional Dependency Injection