[1.13-1.17] EasyAPI
1.3.0Language, AutoReloadFile, Command from Vanilla, NPC, Hologram, ItemUtils, PlayerUtils and more!
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
LanguageAPI
//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);Command API
//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
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:
EzCommandManager.register("prefix", command);Inventory API
You can create inventory by code:
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:
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):
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:
inventory.openToPlayer(player);If you don't need this inventory anymore, please drop it
inventory.drop();Or you can make be droped when player closeIt:
inventory.setOnClose(EzInventory::drop);StorageAPI has been removed!
StorageAPI
First, create a storage
//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:
StorageContext context = new StorageContext();You can also get a StorageContext from json object string:
StorageContext context = StorageContext.getByString(jsonObjectString);HologramAPI
//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 hologramNPC 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!
//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
Scoreboard API released in 1.2.17
//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();Boss Bar API
//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();AutoReloadFile
Example
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
BuildingUtils
Fill stone from a to b
BuildingUtils.fill(a, b, Material.STONE);Fill stone with hollow style from a to b
BuildingUtils.hollow(a, b, Material.STONE);Fill stone with outline style from a to b
BuildingUtils.outline(a, b, Material.STONE);Replace block x to y from a to b
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)
BuildingUtils.circle(a, r, b, f);Draw a line from a to b with block x
BuildingUtils.drawALine(a,b,x)PlayerUtils
Set player skin
Player player;
PlyaerUtils.skin(player, "Online player name");
//You can find online player name on namemc.comSending title has many methods, this is a easiest example
//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:
//EasyAPI ChatMessage
ChatMessage title = new ChatMessage("Title", false);
ChatMessage subtitle = new ChatMessage("Subtitle", false);
Player player;
PlayerUtils.titleWithSubtitle(title, subtitle, player);Sending message
//EasyAPI ChatMessage
ChatMessage message = new ChatMessage("Title", false);
Player player;
PlayerUtils.sendMessage(message, player);Sending nms packet
Player player;
Object nmsPacket;
PlayerUtils.sendPacket(player, nmsPacket);ParticleUtils
Draw outline from a to b with Flame particles as 0.5 distance between every particle
ParticleUtils.outline(from, to, Particle.FLAME, 0.5);
ParticleUtils.asyncOutline(from, to, Particle.FLAME, 0.5);You can also draw a circle with ParticleUtils
ItemUtils
Spawn a fake item stack, everybody can see it, but nobody can pick it up
ItemUtils.spawnUnpickItem(itemStack, location);Spawn a fake item stack, only some players can see it, but nobody can pick it up
ItemUtils.spawnUnpickItem(itemStack, location, players);Spawn a item stack but only one player can see it and pick it up
ItemUtils.spawnPickItemOnlySee(itemStack, location, player);Spawn a item stack everybody can see but only one player can pick it up
ItemUtils.spawnPickItem(itemStack, location, player);Spawn a item stack only one player can pick up and some players can see
ItemUtils.spawnPickItem(itemStack, location, player, whoCanSee);Make a item stack to a JsonObject from Google Gson
ItemUtils.toJsonObject(itemStack);Make a item stack to json object string
ItemUtils.toJsonObjectString(itemStack);Get a item stack from JsonObject
ItemStack itemStack = ItemUtils.toItemStack(jsonObject);Get a item stack from json object string
ItemStack itemStack = ItemUtils.toItemStack(jsonObjectString); Other utils:
ReflectionUtils
PlayerUtils
Loop
InventoryUtils
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