EasyAPI
Version example:
{Generation}.{BigVersion}.{PatchVersion}
1.1.0 means first generation, version 2, first patch
(Example videos on my bilibili channel: https://space.bilibili.com/197734515)
EasyAPI is a simple api for spigot server
Why so big because plugin jar include libraries
There are some examples
Spoiler: LanguageAPI
Code (Java):
//Create language default first
LanguageDefault languageDefault = new LanguageDefault (YourPluginInstance ) ;
//Add default text, if exists in file it won't be replace
languageDefault. addDefault ( "example.text", "Example Message" ) ;
//Then create a new language, "en_us" is language code, you can find language code in org.ezapi.configuration.LanguageCode or https://minecraft.fandom.com/wiki/Language
Language language = new Language (languageDefault, "en_us" ) ;
//Now regster language
LanguageManager. INSTANCE. register (language ) ;
LanguageDefault languageDefault = new LanguageDefault (YourPluginInstance ) ;
//Add default text, if exists in file it won't be replace
languageDefault. addDefault ( "example.text", "Example Message" ) ;
//Then create a new language, "en_us" is language code, you can find language code in org.ezapi.configuration.LanguageCode or https://minecraft.fandom.com/wiki/Language
Language language = new Language (languageDefault, "en_us" ) ;
//Now regster language
LanguageManager. INSTANCE. register (language ) ;
Spoiler: Command API
Use "then" method to add arguments
Register command:
Code (Java):
//Create a new EzCommand
EzCommand command = new EzCommand ( "command_name" ) ;
//This is execute without arguments
//executes method need a BiFunction so I use lambda as example
//EzCommand is similar to 1.13+ nms command
command. executes ( (sender, argument ) -> {
//sender is org.ezapi.command.EzSender
//ChatMessage is org.ezapi.chat.ChatMessage, the text registered in language can be used right here, the boolean after key is flag, if flag is true it will read "example.text" from language file, or else just send "example.text"
sender. sendMessage ( new ChatMessage ( "example.text", true ) ) ;
//Need return a number, 0 is failed, 1+ is success
return 1 ;
} ) ;
EzCommand command = new EzCommand ( "command_name" ) ;
//This is execute without arguments
//executes method need a BiFunction so I use lambda as example
//EzCommand is similar to 1.13+ nms command
command. executes ( (sender, argument ) -> {
//sender is org.ezapi.command.EzSender
//ChatMessage is org.ezapi.chat.ChatMessage, the text registered in language can be used right here, the boolean after key is flag, if flag is true it will read "example.text" from language file, or else just send "example.text"
sender. sendMessage ( new ChatMessage ( "example.text", true ) ) ;
//Need return a number, 0 is failed, 1+ is success
return 1 ;
} ) ;
Code (Java):
command.
then
(
new EzCommand
(
"reload"
)
. executes ( (sender, argument ) -> {
sender. sendMessage ( new ChatMessage ( "Reloaded", false ) ) ;
return 1 ;
} )
) ;
//Find arguments in "org.ezapi.command.argument" package or org.ezapi.command.argument.EzArgumentTypes class
command. then ( new EzArgument (BaseArguments. string ( ), "string" )
. suggest ( (sender, suggestions ) -> suggestions. suggest ( "test" ). suggest ( "example" ). buildFuture ( ) )
. executes ( (sender, argument ) -> {
sender. sendMessage ( new ChatMessage (argument. getAsString ( "string" ), false ) ) ;
return 1 ;
} )
) ;
. executes ( (sender, argument ) -> {
sender. sendMessage ( new ChatMessage ( "Reloaded", false ) ) ;
return 1 ;
} )
) ;
//Find arguments in "org.ezapi.command.argument" package or org.ezapi.command.argument.EzArgumentTypes class
command. then ( new EzArgument (BaseArguments. string ( ), "string" )
. suggest ( (sender, suggestions ) -> suggestions. suggest ( "test" ). suggest ( "example" ). buildFuture ( ) )
. executes ( (sender, argument ) -> {
sender. sendMessage ( new ChatMessage (argument. getAsString ( "string" ), false ) ) ;
return 1 ;
} )
) ;
Code (Java):
EzCommandManager.
register
(
"prefix", command
)
;
Spoiler: Inventory API
StorageAPI has been removed!
You can create inventory by code:
6 is the amount of lines, supports from 1 to 6
Add a input item by code:
Or add a clickable input (button):
Open to a player:
If you don't need this inventory anymore, please drop it
Or you can make be droped when player closeIt:
Code (Java):
EzInventory inventory
=
new EzInventory
(
this,
6
)
;
EzInventory inventory = new EzInventory ( this, 6, new ChatMessage ( "Title", false ) ) ;
EzInventory inventory = new EzInventory ( this, 6, new ChatMessage ( "Title", false ) ) ;
Add a input item by code:
Code (Java):
inventory.
add
(slotNumber,
new Input
(
)
{
@Override
public void onDraw (Player player, DrawSetting drawSetting ) {
if (player. isOp ( ) ) {
drawSetting. setType (Material. DIAMOND ) ;
drawSetting. setDisplayName ( new ChatMessage ( "Button name", false ) ) ;
}
}
} ) ;
@Override
public void onDraw (Player player, DrawSetting drawSetting ) {
if (player. isOp ( ) ) {
drawSetting. setType (Material. DIAMOND ) ;
drawSetting. setDisplayName ( new ChatMessage ( "Button name", false ) ) ;
}
}
} ) ;
Code (Java):
inventory.
add
(slotNumber,
new
Button
(
)
{
@Override
public void onClick (Player player, ClickType click, InventoryAction action ) {
if (player. isOp ( ) && click. isLeftClick ( ) && action == InventoryAction. PICKUP_ALL ) {
player. sendMessage ( "You clicked a button" ) ;
}
}
@Override
public void onDraw (Player player, DrawSetting drawSetting ) {
if (player. isOp ( ) ) {
drawSetting. setType (Material. DIAMOND ) ;
drawSetting. setDisplayName ( new ChatMessage ( "Button name", false ) ) ;
}
}
} ) ;
@Override
public void onClick (Player player, ClickType click, InventoryAction action ) {
if (player. isOp ( ) && click. isLeftClick ( ) && action == InventoryAction. PICKUP_ALL ) {
player. sendMessage ( "You clicked a button" ) ;
}
}
@Override
public void onDraw (Player player, DrawSetting drawSetting ) {
if (player. isOp ( ) ) {
drawSetting. setType (Material. DIAMOND ) ;
drawSetting. setDisplayName ( new ChatMessage ( "Button name", false ) ) ;
}
}
} ) ;
Code (Java):
inventory.
openToPlayer
(player
)
;
Code (Text):
inventory.drop();
Code (Java):
inventory.
setOnClose
(EzInventory
::drop
)
;
Spoiler: StorageAPI
First, create a storage
Store context need use org.ezapi.storage.StorageContext.
Create a new context by:
You can also get a StorageContext from json object string:
Code (Java):
//Create mysql connection
Mysql mysql = new Mysql (host, port, database, table, username, password ) ;
//Create sqlite connection
Sqlite sqlite = new Sqlite (file, table ) ;
//Create mongoDB connection
//Unsupported in 1.2.9+
MongoDB mongoDB = new MongoDB (host, port, username, password, authDatabase, database ) ;
//Create YamlStorage
YamlStorage yamlStorage = new YamlStorage (file ) ;
//Create JsonStorage
JsonStorage jsonStorage = new JsonStorage (file ) ;
//Create TomlStorage
TomlStorage tomlStorage = new TomlStorage (file ) ;
//Create PropertiesStorage
PropertiesStorage propertiesStorage = new PropertiesStorage (file ) ;
Mysql mysql = new Mysql (host, port, database, table, username, password ) ;
//Create sqlite connection
Sqlite sqlite = new Sqlite (file, table ) ;
//Create mongoDB connection
//Unsupported in 1.2.9+
MongoDB mongoDB = new MongoDB (host, port, username, password, authDatabase, database ) ;
//Create YamlStorage
YamlStorage yamlStorage = new YamlStorage (file ) ;
//Create JsonStorage
JsonStorage jsonStorage = new JsonStorage (file ) ;
//Create TomlStorage
TomlStorage tomlStorage = new TomlStorage (file ) ;
//Create PropertiesStorage
PropertiesStorage propertiesStorage = new PropertiesStorage (file ) ;
Create a new context by:
Code (Java):
StorageContext context
=
new StorageContext
(
)
;
Code (Java):
StorageContext context
= StorageContext.
getByString
(jsonObjectString
)
;
Spoiler: HologramAPI
Code (Text):
//Import org.ezapi.module.hologram.TextHologram to start
TextHologram hologram = new TextHologram(new ChatMessage("example", false), world, location);
//I think you can understand how to create a new hologram
//Using:
//Make a player can see the hologram
hologram.addViewer(player); //org.bukkit.entity.Player
//Remove a player who can see the hologram
hologram.removeViewer(player)
//Refresh hologram to a player
hologram.refresh(player);
//Set the location of hologram
hologram.setLocation(Location location);
//A bug: if you remove a viewer then add him/her to viewers again, then cannot see the hologram
TextHologram hologram = new TextHologram(new ChatMessage("example", false), world, location);
//I think you can understand how to create a new hologram
//Using:
//Make a player can see the hologram
hologram.addViewer(player); //org.bukkit.entity.Player
//Remove a player who can see the hologram
hologram.removeViewer(player)
//Refresh hologram to a player
hologram.refresh(player);
//Set the location of hologram
hologram.setLocation(Location location);
//A bug: if you remove a viewer then add him/her to viewers again, then cannot see the hologram
Spoiler: NPC API
Finally, NPC API was been added in version 1.2.0
NPC in 1.2.0 only has Type Player, more types in future!
Create a NPC first!
NPC in 1.2.0 only has Type Player, more types in future!
Create a NPC first!
Code (Java):
//import org.ezapi.module.npc.EzNPC
//import org.ezapi.module.npc.NPCType
EzNPC npc = new EzNPC (NPCType. PLAYER, new ChatMessage ( "NPC Name" ), location ) ;
//Then add viewer to let a player see it!
//Other methods are same as HologramAPI methods!
npc. addViewer (player ) ;
//Make npc look at player
npc. look ( true ) ;
//Set npc data
//For example, if npc type is player, set data as a string, npc 's skin will be set to the skin of the player named the string
npc. setData ( "Notch" ) ; //Set npc skin to Notch's skin
//Listening on player left or right click the npc
//[S]Known bugs: Every time player right click the npc, will call 5 times.[/S] Fixed in 1.2.2
//Need a function, no return, with two arguments: a player and a ClickType fromorg.ezapi.module.packet.play.in.InteractEntity.ClickType
//You can use lambda instead of extends the function class
npc. setOnClick ( (player, clickType ) -> {
player. sendMessage ( "You clicked the npc" ) ;
} ) ;
//To clear viewer and make the npc cannot be use anymore
npc. drop ( )
//import org.ezapi.module.npc.NPCType
EzNPC npc = new EzNPC (NPCType. PLAYER, new ChatMessage ( "NPC Name" ), location ) ;
//Then add viewer to let a player see it!
//Other methods are same as HologramAPI methods!
npc. addViewer (player ) ;
//Make npc look at player
npc. look ( true ) ;
//Set npc data
//For example, if npc type is player, set data as a string, npc 's skin will be set to the skin of the player named the string
npc. setData ( "Notch" ) ; //Set npc skin to Notch's skin
//Listening on player left or right click the npc
//[S]Known bugs: Every time player right click the npc, will call 5 times.[/S] Fixed in 1.2.2
//Need a function, no return, with two arguments: a player and a ClickType fromorg.ezapi.module.packet.play.in.InteractEntity.ClickType
//You can use lambda instead of extends the function class
npc. setOnClick ( (player, clickType ) -> {
player. sendMessage ( "You clicked the npc" ) ;
} ) ;
//To clear viewer and make the npc cannot be use anymore
npc. drop ( )
Spoiler: Scoreboard API
Scoreboard API released in 1.2.17
Code (Java):
//Create a new scoreboard
EzScoreboard scoreboard = new EzScoreboard ( new ChatMessage ( "&c&lExample", false ) ) ;
//Add text, the int is witch line, line number higher, position higher
scoreboard. setText ( 8, new ChatMessage ( "&b&l| &bThanks for playing!", false ) ) ;
scoreboard. setText ( 7, new ChatMessage ( "&b&l| ", false ) ) ;
scoreboard. setText ( 6, new ChatMessage ( "&b&l| &bPlayer", false ) ) ;
scoreboard. setText ( 5, new ChatMessage ( "&b&l| &e{display_name}", false ) ) ;
scoreboard. setText ( 4, new ChatMessage ( "&b&l| ", false ) ) ;
scoreboard. setText ( 3, new ChatMessage ( "&b&l| ", false ) ) ;
scoreboard. setText ( 2, new ChatMessage ( "&b&l| ", false ) ) ;
scoreboard. setText ( 1, new ChatMessage ( "&b&l|&e example.com", false ) ) ;
//Make a player can see the scoreboard
scoreboard. addViewer (player ) ;
//Remove line witch is 1
scoreboard. removeText ( 1 ) ;
//Make a player cannot see the scoreboard
scoreboard. removeViewer (player ) ;
//Set title display name
scoreboard. setTitle ( new ChatMessage ( "New Display", false ) ) ;
//Drop the scoreboard
scoreboard. drop ( ) ;
EzScoreboard scoreboard = new EzScoreboard ( new ChatMessage ( "&c&lExample", false ) ) ;
//Add text, the int is witch line, line number higher, position higher
scoreboard. setText ( 8, new ChatMessage ( "&b&l| &bThanks for playing!", false ) ) ;
scoreboard. setText ( 7, new ChatMessage ( "&b&l| ", false ) ) ;
scoreboard. setText ( 6, new ChatMessage ( "&b&l| &bPlayer", false ) ) ;
scoreboard. setText ( 5, new ChatMessage ( "&b&l| &e{display_name}", false ) ) ;
scoreboard. setText ( 4, new ChatMessage ( "&b&l| ", false ) ) ;
scoreboard. setText ( 3, new ChatMessage ( "&b&l| ", false ) ) ;
scoreboard. setText ( 2, new ChatMessage ( "&b&l| ", false ) ) ;
scoreboard. setText ( 1, new ChatMessage ( "&b&l|&e example.com", false ) ) ;
//Make a player can see the scoreboard
scoreboard. addViewer (player ) ;
//Remove line witch is 1
scoreboard. removeText ( 1 ) ;
//Make a player cannot see the scoreboard
scoreboard. removeViewer (player ) ;
//Set title display name
scoreboard. setTitle ( new ChatMessage ( "New Display", false ) ) ;
//Drop the scoreboard
scoreboard. drop ( ) ;
Spoiler: Boss Bar API
Code (Java):
//Create a new boss bar
EzBossBar bossBar = new EzBossBar ( new ChatMessage ( "Ender Dragon", false ) ) ;
//Add a new viewer
bossBar. addViewer (player ) ;
//Set boss bar progress
bossBar. setProgress (0.5f ) ;
//Set boss bar color
bossBar. setColor (BarColor. BLUE ) ;
//Set boss bar style
bossBar. setStyle (BarStyle. NOTCHED_20 ) ;
//Make sky dark
bossBar. setDarkenSky ( true ) ;
//Play music to player
bossBar. setPlayMusic ( true ) ;
//Create fog
bossBar. setCreateFog ( true ) ;
//Make player cannot see the boss bar
bossBar. hide (player ) ;
//Make player can see the boss bar
bossBar. show (player ) ;
//Remove a viewer
bossBar. removeViewer (player ) ;
//Drop the boss bar
bossBar. drop ( ) ;
EzBossBar bossBar = new EzBossBar ( new ChatMessage ( "Ender Dragon", false ) ) ;
//Add a new viewer
bossBar. addViewer (player ) ;
//Set boss bar progress
bossBar. setProgress (0.5f ) ;
//Set boss bar color
bossBar. setColor (BarColor. BLUE ) ;
//Set boss bar style
bossBar. setStyle (BarStyle. NOTCHED_20 ) ;
//Make sky dark
bossBar. setDarkenSky ( true ) ;
//Play music to player
bossBar. setPlayMusic ( true ) ;
//Create fog
bossBar. setCreateFog ( true ) ;
//Make player cannot see the boss bar
bossBar. hide (player ) ;
//Make player can see the boss bar
bossBar. show (player ) ;
//Remove a viewer
bossBar. removeViewer (player ) ;
//Drop the boss bar
bossBar. drop ( ) ;
Spoiler: AutoReloadFile
Example
Code (Java):
File file
=
new
File
(
"plugins/EasyAPI/",
"example.yml"
)
;
FileUtils. create (file, true ) ;
AutoReloadFile autoReloadFile = new AutoReloadFile (EasyAPI. getInstance ( ), file ) ;
autoReloadFile. onModified ( ( ) -> {
System. out. println ( "Modified" ) ;
System. out. println ( "content: " + FileUtils. readText (file ) ) ;
} ) ;
autoReloadFile. onDeleted ( ( ) -> {
System. out. println ( "Deleted" ) ;
} ) ;
FileUtils. create (file, true ) ;
AutoReloadFile autoReloadFile = new AutoReloadFile (EasyAPI. getInstance ( ), file ) ;
autoReloadFile. onModified ( ( ) -> {
System. out. println ( "Modified" ) ;
System. out. println ( "content: " + FileUtils. readText (file ) ) ;
} ) ;
autoReloadFile. onDeleted ( ( ) -> {
System. out. println ( "Deleted" ) ;
} ) ;
And there are also a lot Utils in package org.ezapi.util
Spoiler: BuildingUtils
Fill stone from a to b
Fill stone with hollow style from a to b
Fill stone with outline style from a to b
Replace block x to y from a to b
Draw a circle, a as center(Location), r as radius(double), b as block(Material), f as beFilled(boolean)
Draw a line from a to b with block x
BuildingUtils. drawALine (a,b,x )
Code (Java):
BuildingUtils.
fill
(a, b, Material.
STONE
)
;
Code (Java):
BuildingUtils.
hollow
(a, b, Material.
STONE
)
;
Code (Java):
BuildingUtils.
outline
(a, b, Material.
STONE
)
;
Code (Java):
BuildingUtils.
replace
(a, b, x, y
)
;
Code (Java):
BuildingUtils.
circle
(a, r, b, f
)
;
Code (Java):
BuildingUtils. drawALine (a,b,x )
Spoiler: PlayerUtils
Set player skin
Sending title has many methods, this is a easiest example
Sending title and subtitle at the same time:
Sending message
Sending nms packet
Code (Java):
Player player
;
PlyaerUtils. skin (player, "Online player name" ) ;
//You can find online player name on namemc.com
PlyaerUtils. skin (player, "Online player name" ) ;
//You can find online player name on namemc.com
Code (Java):
//EasyAPI ChatMessage
ChatMessage message = new ChatMessage ( "Title", false ) ;
Player player ;
PlayerUtils. title (message, player ) ;
//Subtitle: PlayerUtils.subtitle(message, player);
//Actionbar: PlayerUtils.actionbar(message, player);
ChatMessage message = new ChatMessage ( "Title", false ) ;
Player player ;
PlayerUtils. title (message, player ) ;
//Subtitle: PlayerUtils.subtitle(message, player);
//Actionbar: PlayerUtils.actionbar(message, player);
Code (Java):
//EasyAPI ChatMessage
ChatMessage title = new ChatMessage ( "Title", false ) ;
ChatMessage subtitle = new ChatMessage ( "Subtitle", false ) ;
Player player ;
PlayerUtils. titleWithSubtitle (title, subtitle, player ) ;
ChatMessage title = new ChatMessage ( "Title", false ) ;
ChatMessage subtitle = new ChatMessage ( "Subtitle", false ) ;
Player player ;
PlayerUtils. titleWithSubtitle (title, subtitle, player ) ;
Code (Java):
//EasyAPI ChatMessage
ChatMessage message = new ChatMessage ( "Title", false ) ;
Player player ;
PlayerUtils. sendMessage (message, player ) ;
ChatMessage message = new ChatMessage ( "Title", false ) ;
Player player ;
PlayerUtils. sendMessage (message, player ) ;
Code (Java):
Spoiler: ParticleUtils
Draw outline from a to b with Flame particles as 0.5 distance between every particle
You can also draw a circle with ParticleUtils
Code (Java):
ParticleUtils.
outline
(from, to, Particle.
FLAME,
0.5
)
;
ParticleUtils. asyncOutline (from, to, Particle. FLAME, 0.5 ) ;
ParticleUtils. asyncOutline (from, to, Particle. FLAME, 0.5 ) ;
Spoiler: ItemUtils
Spawn a fake item stack, everybody can see it, but nobody can pick it up
Spawn a fake item stack, only some players can see it, but nobody can pick it up
Spawn a item stack but only one player can see it and pick it up
Spawn a item stack everybody can see but only one player can pick it up
Spawn a item stack only one player can pick up and some players can see
Make a item stack to a JsonObject from Google Gson
Make a item stack to json object string
Get a item stack from JsonObject
Get a item stack from json object string
Code (Java):
ItemUtils.
spawnUnpickItem
(itemStack, location
)
;
Code (Java):
ItemUtils.
spawnUnpickItem
(itemStack, location, players
)
;
Code (Java):
ItemUtils.
spawnPickItemOnlySee
(itemStack, location, player
)
;
Code (Java):
ItemUtils.
spawnPickItem
(itemStack, location, player
)
;
Code (Java):
ItemUtils.
spawnPickItem
(itemStack, location, player, whoCanSee
)
;
Code (Java):
ItemUtils.
toJsonObject
(itemStack
)
;
Code (Java):
ItemUtils.
toJsonObjectString
(itemStack
)
;
Code (Java):
ItemStack itemStack
= ItemUtils.
toItemStack
(jsonObject
)
;
Code (Java):
ItemStack itemStack
= ItemUtils.
toItemStack
(jsonObjectString
)
;
Other utils:
ReflectionUtils
PlayerUtils
Loop
InventoryUtils
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.13, 1.14, 1.15
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
[1.13-1.17] EasyAPI is a free Minecraft Java mod. Compatible with Minecraft 1.13, 1.14, 1.15, 1.16 and newer. Downloaded 2,821 times (via Spigot). Download it and open it directly in the game.