[1.13-1.17] EasyAPI icon

[1.13-1.17] EasyAPI -----

Language, AutoReloadFile, Command from Vanilla, NPC, Hologram, ItemUtils, PlayerUtils and more!



Easy.png 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

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 ) ;
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 ;
        } ) ;
Use "then" method to add arguments
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 ;
                } )
        ) ;
Register command:
Code (Java):
EzCommandManager. register ( "prefix", command ) ;

You can create inventory by code:
Code (Java):
EzInventory inventory = new EzInventory ( this, 6 ) ;
        EzInventory inventory = new EzInventory ( this, 6, new ChatMessage ( "Title", false ) ) ;
6 is the amount of lines, supports from 1 to 6
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 ) ) ;
                }
            }
        } ) ;
Or add a clickable input (button):
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 ) ) ;
                }
            }
        } ) ;
Open to a player:
Code (Java):
inventory. openToPlayer (player ) ;
If you don't need this inventory anymore, please drop it
Code (Text):
inventory.drop();
Or you can make be droped when player closeIt:
Code (Java):
inventory. setOnClose (EzInventory ::drop ) ;
StorageAPI has been removed!
First, create a storage
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 ) ;
Store context need use org.ezapi.storage.StorageContext.
Create a new context by:
Code (Java):
StorageContext context = new StorageContext ( ) ;
You can also get a StorageContext from json object string:
Code (Java):
StorageContext context = StorageContext. getByString (jsonObjectString ) ;

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

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!
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 ( )

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 ( ) ;

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 ( ) ;

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" ) ;
} ) ;

And there are also a lot Utils in package org.ezapi.util
Fill stone from a to b
Code (Java):
 BuildingUtils. fill (a, b, Material. STONE ) ;
Fill stone with hollow style from a to b
Code (Java):
 BuildingUtils. hollow (a, b, Material. STONE ) ;
Fill stone with outline style from a to b
Code (Java):
 BuildingUtils. outline (a, b, Material. STONE ) ;
Replace block x to y from a to b
Code (Java):
 BuildingUtils. replace (a, b, x, y ) ;
Draw a circle, a as center(Location), r as radius(double), b as block(Material), f as beFilled(boolean)
Code (Java):
 BuildingUtils. circle (a, r, b, f ) ;
Draw a line from a to b with block x
Code (Java):

BuildingUtils. drawALine (a,b,x )
 

Set player skin
Code (Java):
Player player ;
PlyaerUtils. skin (player, "Online player name" ) ;
//You can find online player name on namemc.com
Sending title has many methods, this is a easiest example
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);
 
Sending title and subtitle at the same time:
Code (Java):
//EasyAPI ChatMessage
ChatMessage title = new ChatMessage ( "Title", false ) ;
ChatMessage subtitle = new ChatMessage ( "Subtitle", false ) ;
Player player ;
PlayerUtils. titleWithSubtitle (title, subtitle, player ) ;
 
Sending message
Code (Java):
//EasyAPI ChatMessage
ChatMessage message = new ChatMessage ( "Title", false ) ;
Player player ;
PlayerUtils. sendMessage (message, player ) ;
 
Sending nms packet
Code (Java):

Player player ;
Object nmsPacket ;
PlayerUtils. sendPacket (player, nmsPacket ) ;
 

Draw outline from a to b with Flame particles as 0.5 distance between every particle
Code (Java):
ParticleUtils. outline (from, to, Particle. FLAME, 0.5 ) ;
        ParticleUtils. asyncOutline (from, to, Particle. FLAME, 0.5 ) ;
You can also draw a circle with ParticleUtils

Spawn a fake item stack, everybody can see it, but nobody can pick it up
Code (Java):
ItemUtils. spawnUnpickItem (itemStack, location ) ;
Spawn a fake item stack, only some players can see it, but nobody can pick it up
Code (Java):
ItemUtils. spawnUnpickItem (itemStack, location, players ) ;
Spawn a item stack but only one player can see it and pick it up
Code (Java):
ItemUtils. spawnPickItemOnlySee (itemStack, location, player ) ;
Spawn a item stack everybody can see but only one player can pick it up
Code (Java):
ItemUtils. spawnPickItem (itemStack, location, player ) ;
Spawn a item stack only one player can pick up and some players can see
Code (Java):
ItemUtils. spawnPickItem (itemStack, location, player, whoCanSee ) ;
Make a item stack to a JsonObject from Google Gson
Code (Java):
ItemUtils. toJsonObject (itemStack ) ;
Make a item stack to json object string
Code (Java):
ItemUtils. toJsonObjectString (itemStack ) ;
Get a item stack from JsonObject
Code (Java):
ItemStack itemStack = ItemUtils. toItemStack (jsonObject ) ;
Get a item stack from json object string
Code (Java):
ItemStack itemStack = ItemUtils. toItemStack (jsonObjectString ) ;

Other utils:
ReflectionUtils
PlayerUtils
Loop
InventoryUtils
Resource Information
Author:
----------
Total Downloads: 2,477
First Release: Jul 19, 2021
Last Update: Aug 8, 2021
Category: ---------------
All-Time Rating:
3 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings