Async All in one Lib
1.0-SNAPSHOTAsynchronous API and Utils implementations for your Plugin. | AIO-API
This is an asynchronous implementation of common plugin APIs and Utils.
The Lib is in developement an many features are added in the futures.
Please report bugs in the comment section.
Bundled API and Utils included:
- Asynchronous SQLClient
- Full Asynchronous Mojang-API wrapper with UUIDFetcher, NameFetcher, ProfileFetcher ...
- ItemBuilder
- Skulls with textures
- Player Actionbar
- CoinAPI (File- or SQLBased)
- EffectAPI for Particles (not completed) and Named Sound Effetcs
- A full Asynchronous NickAPI for changing player name and skin (also for the player himself)
- Utils to perform Asynchronous actions Synchronous if needed.
Plans for the future:
- Base for Gamemodes to easify and speed up progress of development
- InventoryAPI to easify work with different types of GUIs
- AND much more (coming soon )
HOW-TO
Handler and AsyncResult
As this is an Async Lib it uses AsyncResults.
An AsyncResult is like a Future but with better Methods.
The result of an method will be handled in Handler, which retrieved the result asynchronous, if an error appears the AsyncResult will give back
an Throwable.
The example shows the retrieving of an SQLConnection
Code
client. getConnection ( res -> {
//checks result is success or not
if ( res. succeed ( ) ) {
//get the sql connection from the AsyncResult
SQLConnection conn = res. result ( ) ;
} else {
//print error if fails
res. cause ( ) . printStackTrace ( ) ;
}
} ) ;
SQLClient
Code
SQLClient client = JDBCClient. create ( datasource ) ;
/** Here you have to specifiy an datasource to point to your jdbc
implementation (mysql/sqlite/..). The best way to implement this is to use
HikariCP, which is the most recommend and fastest jdbc connection pool.
The second point is that you have to add your sql driver to the classpath.
(like 'MySQL Connector/J') */
//To get started you need to get a SQLConnection
client. getConnection ( res -> {
if ( res. succeed ( ) ) {
SQLConnection conn = res. result ( ) ;
//As we have the connection now, we can use it to update, query...
//the database
conn. update ( "INSERT INTO `test` VALUES ('1234', 'ITS A TEST')" , res2 -> {
if ( res2. failed ( ) ) {
//print error if fails
res2. cause ( ) . printStackTrace ( ) ;
}
} ) ;
} else {
res. cause ( ) . printStackTrace ( ) ;
}
} ) ;
//Don't forget to close the SQLClient if the server stops!
client. close ( ) ;
Sync
Works for every asynchronous Method call, but will block the thread
Code
SQLConnection conn = Sync. awaitResult ( h -> client. getConnection ( h ) ) ;
Mojang
Full MojangAPI wrapper
Code
//create instance of api
Mojang mojang = Mojang. create ( ) ;
//get players profile
mojang. getProfile ( ... ) ;
//get uuid for name
mojang. getUUID ( .. ) ;
//get all blocked server
mojang. getBlockedServer ( ) ;
//get name for uuid
mojang. getName ( .. ) ;
//get players name history
mojang. getNameHistory ( .. ) ;
//get status of all mojang/minecraft server
mojang. getStatus ( .. ) ;
//get status of mojang/minecraft server
mojang. getStatusOf ( ... ) ;
//get uuid at time
mojang. getUUIDAt ( ... ) ;
//close mojangapi
mojang. close ( ) ;
ItemBuilder
Build items and their ItemMeta
Code
//Build items and their ItemMeta
ItemStack item = ItemBuilder. newBuilder ( )
. setMaterial ( Material. DIAMOND_SWORD )
. setItemMeta ( ItemMetaBuilder. newBuilder ( )
. setDisplayName ( "&cDisplay" )
. build ( ) )
. build ( ) ;
SkullAPI
Create skull form URL or profile
Code
//create instance of api
SkullAPI skullAPI = SkullAPI. create ( ) ;
//get skull with textures as itemstack
skullAPI. getSkull ( "URL" , res -> {
if ( res. succeed ( ) ) {
ItemStack skull = res. result ( ) ;
}
} ) ;
//close api
skullAPI. close ( ) ;
Actiobar
Code
//create instance of Actionbar
Actionbar actionbar = Actionbar. create ( ) ;
//send actiobar to player(s). You also can send Actionbar laters and at Fixed rate
actionbar. sendActionbar ( player, msg, handler ) ;
//close api
actionbar. close ( ) ;CoinAPI
Code
//create instance of api
CoinAPI coinAPI = CoinAPI. create ( ) ;
//get players coins
coinAPI. getCoins ( .. ) ;
//set players coins
coinAPI. setCoins ( .. ) ;
//add player coins
coinAPI. addCoins ( .. ) ;
//remove player coins
coinAPI. removeCoins ( .. ) ;
//close api
coinAPI. close ( ) ;NickAPI
Code
//create instance of api. MojangAPI is needed
NickAPI nickAPI = NickAPI. create ( mojang ) ;
//get nick from name/uuid/gameprofile
nickAPI. getNick ( .. ) ;
//get players real name
nickAPI. getRealName ( .. ) ;
//nick player with nick (getNick(..))
nickAPI. nickPlayer ( .. ) ;
//reset player
nickAPI. resetPlayer ( .. ) ;
//check wheather player is nicked
nickAPI. hasNick ( .. ) ;
//close nickapi
nickAPI. close ( ) ;EffectAPI
Code
//create instance of api
EffectAPI effectAPI = EffectAPI. create ( ) ;
//play named sound effect
effectAPI. playNamedSound ( .. ) ;
//close api
effectAPI. close ( ) ; MAVEN
<repository>
<id>syst3m.run repo</id>
<url>https://repo.syst3m.run/repository/maven-snapshots/</url>
</repository>
<dependency>
<groupId>run.syst3m</groupId>
<artifactId>allinone</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>[/SIZE]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