An easy way to create plugins. it will easy your plugin development as never before. Everyone who has used Spring may be familiar with annotation development, which this API gives you!
To be able to use this resource, first of all, you must add the dependency to it
depend: [AdvancedPluginApi]
In your onEnable method, you must register this plugin to the API and it will handle the rest work
final Plugin advancedPluginApi = Bukkit. getPluginManager ( ) . getPlugin ( "AdvancedPluginApi" ) ;
if ( advancedPluginApi != null ) {
final AdvancedPlugin pluginApi = ( AdvancedPlugin ) advancedPluginApi ;
pluginApi. registerPlugin ( this ) ;
}
- Dependency Injection
You can use this plugin's integrated dependency injection.
you will have to annotate all Singleton classes with @ Component.
You may or may not include constructor. It doesn't matter
as long as you don't have a constructor that accepts non-component parameters.
like so
@ Component
public class Boss {
private Boss ( ) {
//Do not remove me plox
//I am sexy <3
}
public void doSmthng ( .. ) {
..
}
}
Now you can do that with any other class using annotation Component, RegisterListener, RegisterCommand or the main class of your plugin and it will work fine.
public class CoolPlugin extends JavaPlugin {
@AutoInject
private Boss boss ;
@Override
public void onEnable ( ) {
//register this plugin to the api(shown above)
boss. doSmthng ( ) ;
}
}
You can see the example usages there:
https://github.com/ablax/AdvancedPluginApi/tree/master/examples/
You don't need to manually register listeners, for every listener class, you just need to add
@ RegisterListener annotation.
You don't need to manually set command executors, for every listener class, you just need to add
@ RegisterCommand(commandName = "cmdName") annotation.
You can add as many components as you want in the components' constructors, as long as you have just one constructor, and they will be auto injected as well.
- Caching
This API provides caching functionality out of the box. What does that mean? Let's say that you are making a lot of calls to the database and it's costly for you. And most of the time the results are the same.
Instead of calling the database every time, you can get an OptionalCache implementation and make it do it for you, and save all the received records and not repeat the database calls.
How to do that?
Well let's say that this is your database call method:
public String getNameFromDb ( UUID uuid ) {
return db. connect ( ) . getName ( uuid ) ;
}
if you are using this repeatedly, with repeating uuids' it may be real performance bad.
You can create an OptionalCache variable in your class with getNameFromDb doing so.
OptionalCache < UUID, String > optionalCache = CacheFactory. buildOptionalCache ( 15 ( max cache size ) , 1 ( time ) , TimeUnit. HOURS ( time unit ) ;
Now you must initialize this OptionalCache providing with function to fetch from DB. You can do it in any constructor/init method/onEnable
like so:
@Override
public void onEnable ( ) {
optionalCache. init ( uuid -> Optional. ofNullable ( getNameFromDb ( uuid ) ) ) ;
}
and every time you call optionalCache.loadAndGetByKey(uuid)
it will give you the cached value if there is one. If it doesn't contain cached value, then it will call the database and cache the given value.
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta