UtilityAPI is in a very early stage of development and many features are still to come. If you wand a specific feature let me know and I'll see if I can implement it :)
Current Features:
Crafting
- Add crafting recipes faster and get more control over them
Code
// The Material[] has to have 9 entries. They translate to the 9 slots in a crafting table (left to right)
// There is an overload for this method which takes in all 9 Material items instead of an array
// Material.AIR means the slot in the crafting table will have to be empty
Material[] ingredients = {Material.AIR, Material.COAL, Material.AIR,
Material.COAL, Material.COAL_BLOCK, Material.COAL,
Material.AIR, Material.COAL, Material.AIR};
CraftRecipe recipe = new CraftRecipe(new ItemStack(Material.DIAMOND), ingredients, "DiamondRecipe", this);
recipe.addRecipe();- Add smithing recipes easier and with more control
Code
SmithRecipe recipe = new SmithRecipe(new ItemStack(Material.NETHERITE_PICKAXE), Material.IRON_PICKAXE, Material.DIAMOND, "DiamondPick", this);
recipe.setResult(new ItemStack(Material.DIAMOND_PICKAXE));
recipe.addRecipe();Cooldowns
- Easy to use cooldowns
Code
// First create a cooldown
// Give it a time and TimeScale (Minutes or Seconds)
Cooldown cooldown = new Cooldown(10, TimeScale.SECONDS);
// Add a player to a cooldown
cooldown.addPlayerToCooldown(player);
// Remove a player from a cooldown
cooldown.removePlayerFromCooldown(player);
// Check if player is on cooldown
// Returns true/ false
cooldown.isOnCooldown(player);
// Get remaining time
// Returns an integer
cooldown.getRemainingCooldown(player); // This will always return in the unit that was given when the cooldown was created
cooldown.getRemainingCooldown(player, TimeScale.MINUTES); // This will return in the given unitItem and ItemBuilder
- Item works like ItemStacks but applies the ItemMeta for you.
Code
Item item = new Item(Material.GOLDEN_SWORD);
item.addEnchant(Enchantment.FIRE_ASPECT, 1, true);
item.setName(ChatColor.RED + "Fire Sword");
item.addFlags(ItemFlag.HIDE_ENCHANTS);
item.setUnbreakable(true);
player.getInventory().addItem(item.getItemStack());- ItemBuilder allows you to create ItemStacks in just one line of code. It's perfect for just small Items you need to quickly create or test around with.
Code
ItemStack stack = new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName(ChatColor.BLUE + "Ice Sword").addEnchant(Enchantment.KNOCKBACK, 3).addFlags(ItemFlag.HIDE_ENCHANTS).addToLore(ChatColor.WHITE + "Freezes Players").getItemStack();Inventory
- Remove a certain amount of items from an inventory or player.
Code
utilityAPI.inventory.removeItem(player, Material.STICK, 10);- Check if a player inventory contains certain items.
Code
if(utilityAPI.inventory.containsItems(player, Material.STICK, 10)) {
player.sendMessage(ChatColor.GREEN + "You own at least 10 sticks!");
}Usage
To use UtilityAPI you have to do 3 things:
- Include the UtilityAPI.jar in your project and put it in your plugins folder
- Add a depend to your plugin.yml:
depend: [UtilityAPI] - Put this line of code in your main class:
public static UtilityAPI utilityAPI = (UtilityAPI) Bukkit.getServer().getPluginManager().getPlugin("UtilityAPI");
Now you can access the UtilityAPI's methods!
If you want to create crafting recipes or smithing recipes follow the code examples given in the Crafting category.
If you want to use the inventory methods follow the examples given in the Inventory category.
There is no documentation yet but I'm working on it.
This is my first API so if you have any tips or hints on how to make it better feel free to post them :)
If you need any help you can join myDiscord:
https://discord.gg/AkAdFf8NjB
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