Quick Start
This page are going to teach you how to create your first plugin via ELD.
If you are using maven, you can follow the xml instruction as below.
<repositories>
<repository>
<id>nexus</id>
<url>https://nexus.chu77.xyz/repository/plugins/</url>
</repository>
</repositories><dependencies>
<dependency>
<groupId>org.eldependenci</groupId>
<artifactId>eldependenci-framework</artifactId>
<version>{最新版本}</version>
<scope>provided</scope>
</dependency>
</dependencies>At first you need to create two classes, the first is a registry class which for registering commands and listeners.
The second if a lifecycle class which to replcae the feature of JavaPlugin (to injectable lifecycle instance)
LifeCycle class and Registry class must be no arg constructor.
Start to create your main class.
Finally, create plugin.yml and point your main into your class which extended ELDBukkitPlugin, then your first plugin will be done.
Command Creation
Below examples showing how to create sub commands
Finally, define the parent-child relationship from registry class.
Event Listener (ELD ver)
You can instantly register bukkit listener into your registry class, but you can also register an eld listener which shows like below.
Finally register in registry class
Yaml Configuration
This framework are using ORM as configuration based. If you have the yaml below
The mapping object should set like this.
Finally add your mapping object class in main.
You can inject the mapping object after registration.
Instance injection
Injecting yaml mapping object
example from sub commands
example from listeners
Injecting your own singleton
register singleton
example from lifecycle
@Inject can also use in constructor.
You can't use @inject on uninjectable instance or it will throw an error.
Injecting Service
Services and Singleton are different that services are using interface while singleton are using instance. Using interface can avoid the high coupling problem and commonly use for API, or with different implementations.
You can inject instance from any instance which allow injection.
injectable instances as below
yaml mapping object
Service
Singleton
instance which allow injection as below
Command (which extended Command Node)
Listeners (which extended Listener or ELDListener)
Singleton (which registered from ServiceCollection)
Services (which registered from ServiceCollection)
LifeCycle (which extended ELDLifeCycle)
最后更新于